From 7fca134f01da9f0b110fddf7fc6a997b260b932a Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 21 Jul 2022 11:57:52 +0200 Subject: [PATCH 001/260] fix: include default pipeline --- .github/workflows/release.yml | 50 ++++++++++++++++++++++++++ .goreleaser.yml | 60 ++++++++++++++++++++++++++++++++ .releaserc.js | 9 +++++ terraform-registry-manifest.json | 8 +++++ 4 files changed, 127 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100644 .releaserc.js create mode 100644 terraform-registry-manifest.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..615d75a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +# This GitHub action can publish assets for release when a tag is created. +# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). +# +# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your +# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` +# secret. If you would rather own your own GPG handling, please fork this action +# or use an alternative one for key handling. +# +# You will need to pass the `--batch` flag to `gpg` in your signing step +# in `goreleaser` to indicate this is being used in a non-interactive mode. +# +name: release +on: + push: + tags: + - 'v*' +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Unshallow + run: git fetch --prune --unshallow + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version-file: 'go.mod' + cache: true + - + name: Import GPG key + id: import_gpg + uses: hashicorp/ghaction-import-gpg@v2.1.0 + env: + # These secrets will need to be configured for the repository: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3.0.0 + with: + version: latest + args: release --rm-dist + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + # GitHub sets this automatically + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..a5a2af13 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,60 @@ +# Visit https://goreleaser.com for documentation on how to customize this +# behavior. +before: + hooks: + # this is just an example and not a requirement for provider building/publishing + - go mod tidy +builds: + - env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like Terraform Cloud where + # they are unable to install libraries. + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - '386' + - arm + - arm64 + ignore: + - goos: darwin + goarch: '386' + binary: '{{ .ProjectName }}_v{{ .Version }}' +archives: + - format: zip + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' +checksum: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + algorithm: sha256 +signs: + - artifacts: checksum + args: + # if you are using this in a GitHub action or some other automated pipeline, you + # need to pass the batch flag to indicate its not interactive. + - "--batch" + - "--local-user" + - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" +release: + extra_files: + - glob: 'terraform-registry-manifest.json' + name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + # If you want to manually examine the release before its live, uncomment this line: + draft: true +changelog: + skip: true \ No newline at end of file diff --git a/.releaserc.js b/.releaserc.js new file mode 100644 index 00000000..64fe52d3 --- /dev/null +++ b/.releaserc.js @@ -0,0 +1,9 @@ +module.exports = { + branches: [ + {name: 'main'}, + {name: 'alpha', prerelease: true}, + ], + plugins: [ + "@semantic-release/commit-analyzer" + ] +}; diff --git a/terraform-registry-manifest.json b/terraform-registry-manifest.json new file mode 100644 index 00000000..8f423732 --- /dev/null +++ b/terraform-registry-manifest.json @@ -0,0 +1,8 @@ +{ + "version": 1, + "metadata": { + "protocol_versions": [ + "6.0" + ] + } +} \ No newline at end of file From 95425e996664e53cc938464ec859544a14110c7a Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 21 Jul 2022 12:45:38 +0200 Subject: [PATCH 002/260] fix: add go.sum --- go.sum | 673 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 673 insertions(+) create mode 100644 go.sum diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..04d70ccf --- /dev/null +++ b/go.sum @@ -0,0 +1,673 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= +github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +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/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= +github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= +github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= +github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= +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/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.7 h1:qcZcULcd/abmQg6dwigimCNEyi4gg31M/xaciQlDml8= +github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/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.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +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/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= +github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= +github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= +github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1/go.mod h1:chrfS3YoLAlKTRE5cFWvCbt8uGAjshktT4PveTUpsFQ= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 h1:BGNSrTRW4rwfhJiFwvwF4XQ0Y72Jj9YEgxVrtovbD5o= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3/go.mod h1:VHn7KgNsRriXa4mcgtkpR00OXyQY6g67JWMvn+R27A4= +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/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= +github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +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.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= +github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= +github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= +github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs= +github.com/hashicorp/hcl/v2 v2.12.0 h1:PsYxySWpMD4KPaoJLnsHwtK5Qptvj/4Q6s0t4sUxZf4= +github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +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.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M= +github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= +github.com/hashicorp/terraform-plugin-go v0.9.0 h1:FvLY/3z4SNVatPZdoFcyrlNbCar+WyyOTv5X4Tp+WZc= +github.com/hashicorp/terraform-plugin-go v0.9.0/go.mod h1:EawBkgjBWNf7jiKnVoyDyF39OSV+u6KUX+Y73EPj3oM= +github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps= +github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc= +github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 h1:9fjPgCenJqnbjo95SDcbJ+YdLyEC1N35cwKWcRWhJTQ= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0/go.mod h1:hLa0sTiySU/AWEgV2GxJh0/pQIqcCmm30IPja9N9lTg= +github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= +github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= +github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= +github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +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/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +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/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= +github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM= +github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +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.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= +github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zitadel/logging v0.3.3/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= +github.com/zitadel/oidc v1.5.1 h1:e7VqNgrwE9I8FqDvxnd4YqCS0BAeKbgQSOVJ727ShxU= +github.com/zitadel/oidc v1.5.1/go.mod h1:s/hyqXVzchd3Y3XA2STBv2g4UKc5HeFf4Og/Mu98AYs= +github.com/zitadel/zitadel-go v0.3.5 h1:j0rWIs/jC39BkKUSIYzKbFhr1NQ/0KBAvC0LfsiNX4o= +github.com/zitadel/zitadel-go v0.3.5/go.mod h1:EFtsbJQRt7cjIK6zV+wwo7OWVjtxD5HaBfJ+9VxBwtI= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.2 h1:ABaR8jMayo3KlXSYVwZ4ukwE9RJroklz8ztgYbnV2ik= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.2/go.mod h1:ZZcNXlWlE1DIB8BBDMq+J0m0hTTq/C46w2NjAkoRzpg= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +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/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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/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= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc= +golang.org/x/sys v0.0.0-20220207234003-57398862261d/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/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= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= +gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +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= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= From d7647a28a91b696dbbdff27edd5a7dca5fc028f2 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 21 Jul 2022 13:08:30 +0200 Subject: [PATCH 003/260] fix: fix gpgkey import --- .github/workflows/release.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 615d75a9..e5180d35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,28 +18,23 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Unshallow + - name: Unshallow run: git fetch --prune --unshallow - - - name: Set up Go + - name: Set up Go uses: actions/setup-go@v3 with: go-version-file: 'go.mod' cache: true - - - name: Import GPG key + - name: Import GPG key id: import_gpg - uses: hashicorp/ghaction-import-gpg@v2.1.0 - env: - # These secrets will need to be configured for the repository: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - PASSPHRASE: ${{ secrets.PASSPHRASE }} - - - name: Run GoReleaser + #https://github.com/hashicorp/ghaction-import-gpg/issues/11 + uses: crazy-max/ghaction-import-gpg@v5.0.0 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3.0.0 with: version: latest From 2337081aa18f79d6248c36a0d306db03ce66bd4b Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 22 Jul 2022 19:09:50 +0200 Subject: [PATCH 004/260] fix: policies and add some documentation examples --- .releaserc.js | 9 --- docs/index.md | 47 ++++++++++++ docs/resources/action.md | 31 ++++++++ docs/resources/application_api.md | 29 ++++++++ docs/resources/application_oidc.md | 45 +++++++++++ docs/resources/domain.md | 30 ++++++++ docs/resources/domain_policy.md | 30 ++++++++ docs/resources/human_user.md | 44 +++++++++++ docs/resources/label_policy.md | 42 +++++++++++ docs/resources/lockout_policy.md | 31 ++++++++ docs/resources/login_policy.md | 40 ++++++++++ docs/resources/machine_user.md | 35 +++++++++ docs/resources/org.md | 31 ++++++++ docs/resources/org_member.md | 28 +++++++ docs/resources/password_complexity_policy.md | 32 ++++++++ docs/resources/privacy_policy.md | 30 ++++++++ docs/resources/project.md | 35 +++++++++ docs/resources/project_grant.md | 32 ++++++++ docs/resources/project_grant_member.md | 30 ++++++++ docs/resources/project_member.md | 29 ++++++++ docs/resources/project_role.md | 33 +++++++++ docs/resources/user_grant.md | 33 +++++++++ examples/provider/action.tf | 11 +++ examples/provider/application_api.tf | 9 +++ examples/provider/application_oidc.tf | 23 ++++++ examples/provider/domain.tf | 7 ++ examples/provider/domain_policy.tf | 9 +++ examples/provider/granted_human_user.tf | 17 +++++ examples/provider/granted_org.tf | 4 + examples/provider/human_user.tf | 17 +++++ examples/provider/label_policy.tf | 16 ++++ examples/provider/lockout_policy.tf | 7 ++ examples/provider/login_policy.tf | 19 +++++ examples/provider/machine_user.tf | 9 +++ examples/provider/org.tf | 3 + examples/provider/org_member.tf | 8 ++ .../provider/password_complexity_policy.tf | 11 +++ examples/provider/privacy_policy.tf | 9 +++ examples/provider/project.tf | 11 +++ examples/provider/project_grant.tf | 8 ++ examples/provider/project_grant_member.tf | 10 +++ examples/provider/project_member.tf | 9 +++ examples/provider/project_role.tf | 10 +++ examples/provider/provider.tf | 15 ++++ examples/provider/user_grant.tf | 9 +++ templates/index.md.tmpl | 23 ++++++ templates/resources/org.md.tmpl | 18 +++++ zitadel/provider.go | 66 ++++++++--------- zitadel/v2/client.go | 74 ++++++++----------- zitadel/v2/domain_policy.go | 4 +- zitadel/v2/label_policy.go | 6 +- zitadel/v2/lockout_policy.go | 8 +- zitadel/v2/login_policy.go | 22 +++--- zitadel/v2/password_complexity_policy.go | 8 +- zitadel/v2/privacy_policy.go | 4 +- zitadel/v2/user.go | 1 - zitadel/v2/user_grant.go | 14 ++-- 57 files changed, 1110 insertions(+), 115 deletions(-) delete mode 100644 .releaserc.js create mode 100644 docs/index.md create mode 100644 docs/resources/action.md create mode 100644 docs/resources/application_api.md create mode 100644 docs/resources/application_oidc.md create mode 100644 docs/resources/domain.md create mode 100644 docs/resources/domain_policy.md create mode 100644 docs/resources/human_user.md create mode 100644 docs/resources/label_policy.md create mode 100644 docs/resources/lockout_policy.md create mode 100644 docs/resources/login_policy.md create mode 100644 docs/resources/machine_user.md create mode 100644 docs/resources/org.md create mode 100644 docs/resources/org_member.md create mode 100644 docs/resources/password_complexity_policy.md create mode 100644 docs/resources/privacy_policy.md create mode 100644 docs/resources/project.md create mode 100644 docs/resources/project_grant.md create mode 100644 docs/resources/project_grant_member.md create mode 100644 docs/resources/project_member.md create mode 100644 docs/resources/project_role.md create mode 100644 docs/resources/user_grant.md create mode 100644 examples/provider/action.tf create mode 100644 examples/provider/application_api.tf create mode 100644 examples/provider/application_oidc.tf create mode 100644 examples/provider/domain.tf create mode 100644 examples/provider/domain_policy.tf create mode 100644 examples/provider/granted_human_user.tf create mode 100644 examples/provider/granted_org.tf create mode 100644 examples/provider/human_user.tf create mode 100644 examples/provider/label_policy.tf create mode 100644 examples/provider/lockout_policy.tf create mode 100644 examples/provider/login_policy.tf create mode 100644 examples/provider/machine_user.tf create mode 100644 examples/provider/org.tf create mode 100644 examples/provider/org_member.tf create mode 100644 examples/provider/password_complexity_policy.tf create mode 100644 examples/provider/privacy_policy.tf create mode 100644 examples/provider/project.tf create mode 100644 examples/provider/project_grant.tf create mode 100644 examples/provider/project_grant_member.tf create mode 100644 examples/provider/project_member.tf create mode 100644 examples/provider/project_role.tf create mode 100644 examples/provider/provider.tf create mode 100644 examples/provider/user_grant.tf create mode 100644 templates/index.md.tmpl create mode 100644 templates/resources/org.md.tmpl diff --git a/.releaserc.js b/.releaserc.js deleted file mode 100644 index 64fe52d3..00000000 --- a/.releaserc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - branches: [ - {name: 'main'}, - {name: 'alpha', prerelease: true}, - ], - plugins: [ - "@semantic-release/commit-analyzer" - ] -}; diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..82abda2e --- /dev/null +++ b/docs/index.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Provider: ZITADEL" +description: |- + Provider to manage resources on ZITADEL + +--- + +# ZITADEL Provider + +This provider allows the management of different resources on a ZITADEL instance. + +Through this provider it is possible to interact with the [ZITADEL API](https://docs.zitadel.com/docs/apis/introduction) to configure different aspects of the instance. + +## Configuring the provider + +```terraform +terraform { + required_providers { + zitadel = { + source = "zitadel/zitadel" + version = "1.0.0-alpha.1" + } + } +} + +provider zitadel { + domain = "localhost:8080" + insecure = "true" + project = "170832731415117995" + token = "local-token" +} +``` + + +## Schema + +### Required + +- `domain` (String) +- `insecure` (Boolean) +- `project` (String) +- `token` (String) + +## Limitations + +The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file diff --git a/docs/resources/action.md b/docs/resources/action.md new file mode 100644 index 00000000..afc8e54f --- /dev/null +++ b/docs/resources/action.md @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_action Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_action (Resource) + + + + + + +## Schema + +### Required + +- `allowed_to_fail` (Boolean) when true, the next action will be called even if this action fails +- `name` (String) +- `org_id` (String) ID of the organization +- `script` (String) +- `timeout` (String) after which time the action will be terminated if not finished + +### Read-Only + +- `id` (String) The ID of this resource. +- `state` (Number) the state of the action + + diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md new file mode 100644 index 00000000..1d5a1645 --- /dev/null +++ b/docs/resources/application_api.md @@ -0,0 +1,29 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_application_api Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_application_api (Resource) + + + + + + +## Schema + +### Required + +- `auth_method_type` (String) Auth method type +- `name` (String) Name of the application +- `org_id` (String) orgID of the application +- `project_id` (String) ID of the project + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md new file mode 100644 index 00000000..111e981e --- /dev/null +++ b/docs/resources/application_oidc.md @@ -0,0 +1,45 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_application_oidc Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_application_oidc (Resource) + + + + + + +## Schema + +### Required + +- `app_type` (String) App type +- `auth_method_type` (String) Auth method type +- `clock_skew` (String) Clockskew +- `grant_types` (List of String) Grant types +- `name` (String) Name of the application +- `org_id` (String) orgID of the application +- `project_id` (String) ID of the project +- `redirect_uris` (List of String) RedirectURIs +- `response_types` (List of String) Response type + +### Optional + +- `access_token_role_assertion` (Boolean) Access token role assertion +- `access_token_type` (String) Access token type +- `additional_origins` (List of String) Additional origins +- `dev_mode` (Boolean) Dev mode +- `id_token_role_assertion` (Boolean) ID token role assertion +- `id_token_userinfo_assertion` (Boolean) Token userinfo assertion +- `post_logout_redirect_uris` (List of String) Post logout redirect URIs +- `version` (String) Version + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/domain.md b/docs/resources/domain.md new file mode 100644 index 00000000..7e1a0d1e --- /dev/null +++ b/docs/resources/domain.md @@ -0,0 +1,30 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_domain Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_domain (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) Name of the domain +- `org_id` (String) ID of the organization + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_primary` (Boolean) Is domain primary +- `is_verified` (Boolean) Is domain verified +- `validation_type` (Number) Validation type + + diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md new file mode 100644 index 00000000..447846f7 --- /dev/null +++ b/docs/resources/domain_policy.md @@ -0,0 +1,30 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_domain_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_domain_policy (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) Id for the organization +- `smtp_sender_address_matches_instance_domain` (Boolean) +- `user_login_must_be_domain` (Boolean) User login must be domain +- `validate_org_domains` (Boolean) Validate organization domains + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) Is this policy the default + + diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md new file mode 100644 index 00000000..0c8b097e --- /dev/null +++ b/docs/resources/human_user.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_human_user Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_human_user (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `user_name` (String) Username + +### Optional + +- `display_name` (String) DIsplay name of the user +- `email` (String) Email of the user +- `first_name` (String) First name of the user +- `gender` (String) Gender of the user +- `initial_password` (String) Initially set password for the user +- `is_email_verified` (Boolean) Is the email verified of the user +- `is_phone_verified` (Boolean) Is the phone verified of the user +- `last_name` (String) Last name of the user +- `nick_name` (String) Nick name of the user +- `phone` (String) Phone of the user +- `preferred_language` (String) Preferred language of the user + +### Read-Only + +- `id` (String) The ID of this resource. +- `login_names` (List of String) Loginnames +- `preferred_login_name` (String) Preferred login name +- `state` (String) State of the user + + diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md new file mode 100644 index 00000000..4598533d --- /dev/null +++ b/docs/resources/label_policy.md @@ -0,0 +1,42 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_label_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_label_policy (Resource) + + + + + + +## Schema + +### Required + +- `background_color` (String) hex value for background color +- `background_color_dark` (String) hex value for background color dark theme +- `disable_watermark` (Boolean) disable watermark +- `font_color` (String) hex value for font color +- `font_color_dark` (String) hex value for font color dark theme +- `hide_login_name_suffix` (Boolean) hides the org suffix on the login form if the scope "urn:zitadel:iam:org:domain:primary:{domainname}" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes +- `org_id` (String) Id for the organization +- `primary_color` (String) hex value for primary color +- `primary_color_dark` (String) hex value for primary color dark theme +- `warn_color` (String) hex value for warn color +- `warn_color_dark` (String) hex value for warn color dark theme + +### Read-Only + +- `font_url` (String) +- `icon_url` (String) +- `icon_url_dark` (String) +- `id` (String) The ID of this resource. +- `is_default` (Boolean) defines if the organisation's admin changed the policy +- `logo_url` (String) +- `logo_url_dark` (String) + + diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md new file mode 100644 index 00000000..9cb1304f --- /dev/null +++ b/docs/resources/lockout_policy.md @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_lockout_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_lockout_policy (Resource) + + + + + + +## Schema + +### Required + +- `max_password_attempts` (Number) Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset. + +### Optional + +- `org_id` (String) Id for the organization + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) defines if the organisation's admin changed the policy + + diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md new file mode 100644 index 00000000..8347e613 --- /dev/null +++ b/docs/resources/login_policy.md @@ -0,0 +1,40 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_login_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_login_policy (Resource) + + + + + + +## Schema + +### Required + +- `allow_external_idp` (Boolean) defines if a user is allowed to add a defined identity provider. E.g. Google auth +- `allow_register` (Boolean) defines if a person is allowed to register a user on this organisation +- `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) +- `external_login_check_lifetime` (String) +- `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in +- `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen +- `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen +- `mfa_init_skip_lifetime` (String) +- `multi_factor_check_lifetime` (String) +- `org_id` (String) Id for the organization +- `password_check_lifetime` (String) +- `passwordless_type` (String) defines if passwordless is allowed for users +- `second_factor_check_lifetime` (String) +- `user_login` (Boolean) defines if a user is allowed to login with his username and password + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) defines if the organisation's admin changed the policy + + diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md new file mode 100644 index 00000000..acd2c884 --- /dev/null +++ b/docs/resources/machine_user.md @@ -0,0 +1,35 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_machine_user Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_machine_user (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `user_name` (String) Username + +### Optional + +- `description` (String) Description of the user +- `name` (String) Name of the machine user + +### Read-Only + +- `id` (String) The ID of this resource. +- `login_names` (List of String) Loginnames +- `preferred_login_name` (String) Preferred login name +- `state` (String) State of the user + + diff --git a/docs/resources/org.md b/docs/resources/org.md new file mode 100644 index 00000000..77492a6b --- /dev/null +++ b/docs/resources/org.md @@ -0,0 +1,31 @@ + 20 lines (13 sloc) 472 Bytes + +--- +page_title: "zitadel_org Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_org (Resource) + + + +## Example Usage + +```terraform +resource zitadel_org org { + name = "terraform-test" +} +``` + + +## Schema + +### Required + +- `name` (String) Name of the org + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md new file mode 100644 index 00000000..740da9c2 --- /dev/null +++ b/docs/resources/org_member.md @@ -0,0 +1,28 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_org_member Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_org_member (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `roles` (Set of String) List of roles granted +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md new file mode 100644 index 00000000..81d10ced --- /dev/null +++ b/docs/resources/password_complexity_policy.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_password_complexity_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_password_complexity_policy (Resource) + + + + + + +## Schema + +### Required + +- `has_lowercase` (Boolean) defines if the password MUST contain a lower case letter +- `has_number` (Boolean) defines if the password MUST contain a number +- `has_symbol` (Boolean) defines if the password MUST contain a symbol. E.g. "$" +- `has_uppercase` (Boolean) defines if the password MUST contain an upper case letter +- `min_length` (Number) Minimal length for the password +- `org_id` (String) Id for the organization + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) defines if the organisation's admin changed the policy + + diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md new file mode 100644 index 00000000..6c05c85f --- /dev/null +++ b/docs/resources/privacy_policy.md @@ -0,0 +1,30 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_privacy_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_privacy_policy (Resource) + + + + + + +## Schema + +### Required + +- `help_link` (String) +- `org_id` (String) Id for the organization +- `privacy_link` (String) +- `tos_link` (String) + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_default` (Boolean) + + diff --git a/docs/resources/project.md b/docs/resources/project.md new file mode 100644 index 00000000..bb628ff3 --- /dev/null +++ b/docs/resources/project.md @@ -0,0 +1,35 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_project Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_project (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) Name of the project +- `org_id` (String) Organization in which the project is located + +### Optional + +- `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered +- `project_role_assertion` (Boolean) describes if roles of user should be added in token +- `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project + +### Read-Only + +- `id` (String) ID of the project +- `state` (String) State of the project + + diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md new file mode 100644 index 00000000..4d5ee736 --- /dev/null +++ b/docs/resources/project_grant.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_project_grant Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_project_grant (Resource) + + + + + + +## Schema + +### Required + +- `granted_org_id` (String) ID of the organization granted the project +- `org_id` (String) ID of the organization which owns the resource +- `project_id` (String) ID of the project + +### Optional + +- `role_keys` (Set of String) List of roles granted + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md new file mode 100644 index 00000000..945a72cb --- /dev/null +++ b/docs/resources/project_grant_member.md @@ -0,0 +1,30 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_project_grant_member Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_project_grant_member (Resource) + + + + + + +## Schema + +### Required + +- `grant_id` (String) ID of the grant +- `org_id` (String) ID of the organization which owns the resource +- `project_id` (String) ID of the project +- `roles` (Set of String) List of roles granted +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md new file mode 100644 index 00000000..e548023f --- /dev/null +++ b/docs/resources/project_member.md @@ -0,0 +1,29 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_project_member Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_project_member (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) ID of the organization which owns the resource +- `project_id` (String) ID of the project +- `roles` (Set of String) List of roles granted +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md new file mode 100644 index 00000000..dc088a5c --- /dev/null +++ b/docs/resources/project_role.md @@ -0,0 +1,33 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_project_role Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_project_role (Resource) + + + + + + +## Schema + +### Required + +- `display_name` (String) Name used for project role +- `org_id` (String) ID of the organization +- `project_id` (String) ID of the project +- `role_key` (String) Key used for project role + +### Optional + +- `group` (String) Group used for project role + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md new file mode 100644 index 00000000..f9e207c0 --- /dev/null +++ b/docs/resources/user_grant.md @@ -0,0 +1,33 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_user_grant Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_user_grant (Resource) + + + + + + +## Schema + +### Required + +- `org_id` (String) ID of the organization which owns the resource +- `project_id` (String) ID of the project +- `role_keys` (Set of String) List of roles granted +- `user_id` (String) ID of the user + +### Optional + +- `project_grant_id` (String) ID of the granted project + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/examples/provider/action.tf b/examples/provider/action.tf new file mode 100644 index 00000000..03f1d103 --- /dev/null +++ b/examples/provider/action.tf @@ -0,0 +1,11 @@ + +resource zitadel_action action { + depends_on = [zitadel_org.org] + provider = zitadel + + org_id = zitadel_org.org.id + name = "actionname" + script = "testscript" + timeout = "10s" + allowed_to_fail = "true" +} \ No newline at end of file diff --git a/examples/provider/application_api.tf b/examples/provider/application_api.tf new file mode 100644 index 00000000..8c893bcd --- /dev/null +++ b/examples/provider/application_api.tf @@ -0,0 +1,9 @@ + +resource zitadel_application_api application_api { + depends_on = [zitadel_org.org, zitadel_project.project] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + name = "applicationapi" + auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" +} \ No newline at end of file diff --git a/examples/provider/application_oidc.tf b/examples/provider/application_oidc.tf new file mode 100644 index 00000000..33bcbe58 --- /dev/null +++ b/examples/provider/application_oidc.tf @@ -0,0 +1,23 @@ + +resource zitadel_application_oidc application_oidc { + depends_on = [zitadel_org.org, zitadel_project.project] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + + name = "applicationoidc" + redirect_uris = ["https://localhost.com"] + response_types = ["OIDC_RESPONSE_TYPE_CODE"] + grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] + post_logout_redirect_uris = ["https://localhost.com"] + app_type = "OIDC_APP_TYPE_WEB" + auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" + version = "OIDC_VERSION_1_0" + clock_skew = "0s" + dev_mode = "true" + access_token_type = "OIDC_TOKEN_TYPE_BEARER" + access_token_role_assertion = "false" + id_token_role_assertion = "false" + id_token_userinfo_assertion = "false" + additional_origins = [] +} \ No newline at end of file diff --git a/examples/provider/domain.tf b/examples/provider/domain.tf new file mode 100644 index 00000000..6ffca369 --- /dev/null +++ b/examples/provider/domain.tf @@ -0,0 +1,7 @@ + +resource zitadel_domain domain { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + name = "localhost.com" +} \ No newline at end of file diff --git a/examples/provider/domain_policy.tf b/examples/provider/domain_policy.tf new file mode 100644 index 00000000..56df20d9 --- /dev/null +++ b/examples/provider/domain_policy.tf @@ -0,0 +1,9 @@ + +resource zitadel_domain_policy domain_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_login_must_be_domain = "false" + validate_org_domains = "false" + smtp_sender_address_matches_instance_domain = "false" +} \ No newline at end of file diff --git a/examples/provider/granted_human_user.tf b/examples/provider/granted_human_user.tf new file mode 100644 index 00000000..80e29a17 --- /dev/null +++ b/examples/provider/granted_human_user.tf @@ -0,0 +1,17 @@ + +resource zitadel_human_user granted_human_user { + depends_on = [zitadel_org.grantedorg] + + org_id = zitadel_org.grantedorg.id + user_name = "human" + first_name = "firstname" + last_name = "lastname" + nick_name = "nickname" + display_name = "displayname" + preferred_language = "de" + gender = "GENDER_MALE" + phone = "+41799999999" + is_phone_verified = "true" + email = "test@zitadel.com" + is_email_verified = "false" +} diff --git a/examples/provider/granted_org.tf b/examples/provider/granted_org.tf new file mode 100644 index 00000000..ddcd2ac3 --- /dev/null +++ b/examples/provider/granted_org.tf @@ -0,0 +1,4 @@ + +resource zitadel_org grantedorg { + name = "terraform-test-granted" +} diff --git a/examples/provider/human_user.tf b/examples/provider/human_user.tf new file mode 100644 index 00000000..78028fec --- /dev/null +++ b/examples/provider/human_user.tf @@ -0,0 +1,17 @@ + +resource zitadel_human_user human_user { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_name = "human" + first_name = "firstname" + last_name = "lastname" + nick_name = "nickname" + display_name = "displayname" + preferred_language = "de" + gender = "GENDER_MALE" + phone = "+41799999999" + is_phone_verified = "true" + email = "test@zitadel.com" + is_email_verified = "false" +} diff --git a/examples/provider/label_policy.tf b/examples/provider/label_policy.tf new file mode 100644 index 00000000..30370689 --- /dev/null +++ b/examples/provider/label_policy.tf @@ -0,0 +1,16 @@ + +resource zitadel_label_policy label_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + primary_color = "#5469d4" + hide_login_name_suffix = "true" + warn_color = "#cd3d56" + background_color = "#fafafa" + font_color = "#000000" + primary_color_dark = "#a5b4fc" + background_color_dark = "#111827" + warn_color_dark = "#ff3b5b" + font_color_dark = "#ffffff" + disable_watermark = "false" +} \ No newline at end of file diff --git a/examples/provider/lockout_policy.tf b/examples/provider/lockout_policy.tf new file mode 100644 index 00000000..ffb69e35 --- /dev/null +++ b/examples/provider/lockout_policy.tf @@ -0,0 +1,7 @@ + +resource zitadel_lockout_policy lockout_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + max_password_attempts = "5" +} \ No newline at end of file diff --git a/examples/provider/login_policy.tf b/examples/provider/login_policy.tf new file mode 100644 index 00000000..98fbfb6b --- /dev/null +++ b/examples/provider/login_policy.tf @@ -0,0 +1,19 @@ + +resource zitadel_login_policy login_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_login = "true" + allow_register = "true" + allow_external_idp = "true" + force_mfa = "false" + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h" + external_login_check_lifetime = "240h" + multi_factor_check_lifetime = "720h" + mfa_init_skip_lifetime = "24h" + second_factor_check_lifetime = "24h" + ignore_unknown_usernames = "true" + default_redirect_uri = "localhost:8080" +} \ No newline at end of file diff --git a/examples/provider/machine_user.tf b/examples/provider/machine_user.tf new file mode 100644 index 00000000..31687733 --- /dev/null +++ b/examples/provider/machine_user.tf @@ -0,0 +1,9 @@ + +resource zitadel_machine_user machine_user { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_name = "machine" + name = "name" + description = "description" +} \ No newline at end of file diff --git a/examples/provider/org.tf b/examples/provider/org.tf new file mode 100644 index 00000000..c79c899d --- /dev/null +++ b/examples/provider/org.tf @@ -0,0 +1,3 @@ +resource zitadel_org org { + name = "terraform-test" +} \ No newline at end of file diff --git a/examples/provider/org_member.tf b/examples/provider/org_member.tf new file mode 100644 index 00000000..f0d1bd5e --- /dev/null +++ b/examples/provider/org_member.tf @@ -0,0 +1,8 @@ + +resource zitadel_org_member org_member { + depends_on = [zitadel_org.org, zitadel_human_user.human_user] + + org_id = zitadel_org.org.id + user_id = zitadel_human_user.human_user.id + roles = ["ORG_OWNER"] +} \ No newline at end of file diff --git a/examples/provider/password_complexity_policy.tf b/examples/provider/password_complexity_policy.tf new file mode 100644 index 00000000..b9d273b6 --- /dev/null +++ b/examples/provider/password_complexity_policy.tf @@ -0,0 +1,11 @@ + +resource zitadel_password_complexity_policy password_complexity_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + min_length = "8" + has_uppercase = "true" + has_lowercase = "true" + has_number = "true" + has_symbol = "true" +} \ No newline at end of file diff --git a/examples/provider/privacy_policy.tf b/examples/provider/privacy_policy.tf new file mode 100644 index 00000000..5b13c971 --- /dev/null +++ b/examples/provider/privacy_policy.tf @@ -0,0 +1,9 @@ + +resource zitadel_privacy_policy privacy_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" +} \ No newline at end of file diff --git a/examples/provider/project.tf b/examples/provider/project.tf new file mode 100644 index 00000000..e433930d --- /dev/null +++ b/examples/provider/project.tf @@ -0,0 +1,11 @@ + +resource zitadel_project project { + depends_on = [zitadel_org.org] + + name = "projectname" + org_id = zitadel_org.org.id + project_role_assertion = "true" + project_role_check = "true" + has_project_check = "true" + private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" +} \ No newline at end of file diff --git a/examples/provider/project_grant.tf b/examples/provider/project_grant.tf new file mode 100644 index 00000000..33ace401 --- /dev/null +++ b/examples/provider/project_grant.tf @@ -0,0 +1,8 @@ + +resource zitadel_project_grant project_grant { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + granted_org_id = zitadel_org.grantedorg.id +} \ No newline at end of file diff --git a/examples/provider/project_grant_member.tf b/examples/provider/project_grant_member.tf new file mode 100644 index 00000000..58e9427b --- /dev/null +++ b/examples/provider/project_grant_member.tf @@ -0,0 +1,10 @@ + +resource zitadel_project_grant_member project_grant_member { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_project_grant.project_grant, zitadel_human_user.granted_human_user] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + grant_id = zitadel_project_grant.project_grant.id + user_id = zitadel_human_user.granted_human_user.id + roles = ["PROJECT_GRANT_OWNER"] +} \ No newline at end of file diff --git a/examples/provider/project_member.tf b/examples/provider/project_member.tf new file mode 100644 index 00000000..683ca6fc --- /dev/null +++ b/examples/provider/project_member.tf @@ -0,0 +1,9 @@ + +resource zitadel_project_member project_member { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_human_user.human_user] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + user_id = zitadel_human_user.human_user.id + roles = ["PROJECT_OWNER"] +} \ No newline at end of file diff --git a/examples/provider/project_role.tf b/examples/provider/project_role.tf new file mode 100644 index 00000000..6a461c01 --- /dev/null +++ b/examples/provider/project_role.tf @@ -0,0 +1,10 @@ + +resource zitadel_project_role project_role { + depends_on = [zitadel_org.org, zitadel_project.project] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + role_key = "key" + display_name = "display_name2" + group = "role_group" +} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf new file mode 100644 index 00000000..ed92ad30 --- /dev/null +++ b/examples/provider/provider.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + zitadel = { + source = "zitadel/zitadel" + version = "1.0.0-alpha.1" + } + } +} + +provider zitadel { + domain = "localhost:8080" + insecure = "true" + project = "170832731415117995" + token = "local-token" +} \ No newline at end of file diff --git a/examples/provider/user_grant.tf b/examples/provider/user_grant.tf new file mode 100644 index 00000000..34e2501d --- /dev/null +++ b/examples/provider/user_grant.tf @@ -0,0 +1,9 @@ + +resource zitade_user_grant user_grant{ + depends_on = ["zitadel_project.project", "zitadel_org.org", "zitadel_human_user.human_user"] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + role_keys = [""] + user_id = zitadel_human_user.granted_human_user +} \ No newline at end of file diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl new file mode 100644 index 00000000..5a826ebf --- /dev/null +++ b/templates/index.md.tmpl @@ -0,0 +1,23 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Provider: ZITADEL" +description: |- + Provider to manage resources on ZITADEL + +--- + +# {{ .ProviderShortName | upper }} Provider + +This provider allows the management of different resources on a ZITADEL instance. + +Through this provider it is possible to interact with the [ZITADEL API](https://docs.zitadel.com/docs/apis/introduction) to configure different aspects of the instance. + +## Configuring the provider + +{{ tffile "examples/provider/provider.tf" }} + +{{ .SchemaMarkdown | trimspace }} + +## Limitations + +The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file diff --git a/templates/resources/org.md.tmpl b/templates/resources/org.md.tmpl new file mode 100644 index 00000000..0c223bb2 --- /dev/null +++ b/templates/resources/org.md.tmpl @@ -0,0 +1,18 @@ + 20 lines (13 sloc) 472 Bytes + +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/org.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index b14437ea..03f069f8 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -13,50 +13,44 @@ func Provider() *schema.Provider { // "zitadelV1Org": v1.GetOrgDatasource(), }, Schema: map[string]*schema.Schema{ - v2.IssuerVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("ISSUER", ""), + v2.DomainVar: { + Type: schema.TypeString, + Required: true, }, - v2.AddressVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("ADDRESS", ""), + v2.InsecureVar: { + Type: schema.TypeBool, + Required: true, }, v2.ProjectVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("PROJECT", ""), + Type: schema.TypeString, + Required: true, }, v2.TokenVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("TOKEN", ""), + Type: schema.TypeString, + Required: true, }, }, ResourcesMap: map[string]*schema.Resource{ - "org": v2.OrgResource(), - "human_user": v2.GetHumanUser(), - "machine_user": v2.GetMachineUser(), - "project": v2.GetProject(), - "project_role": v2.GetProjectRole(), - "domain": v2.GetDomain(), - "action": v2.GetAction(), - "application_oidc": v2.GetApplicationOIDC(), - "application_api": v2.GetApplicationAPI(), - "project_grant": v2.GetProjectGrant(), - "user_grant": v2.GetUserGrant(), - "org_member": v2.GetOrgMember(), - "project_member": v2.GetProjectMember(), - "project_grant_member": v2.GetProjectGrantMember(), - /* - "domain_policy": v2.GetDomainPolicy(), - "label_policy": v2.GetLabelPolicy(), - "lockout_policy": v2.GetLockoutPolicy(), - "login_policy": v2.GetLoginPolicy(), - "password_complexity_policy": v2.GetPasswordComplexityPolicy(), - "privacy_policy": v2.GetPrivacyPolicy(), - */ + "zitadel_org": v2.OrgResource(), + "zitadel_human_user": v2.GetHumanUser(), + "zitadel_machine_user": v2.GetMachineUser(), + "zitadel_project": v2.GetProject(), + "zitadel_project_role": v2.GetProjectRole(), + "zitadel_domain": v2.GetDomain(), + "zitadel_action": v2.GetAction(), + "zitadel_application_oidc": v2.GetApplicationOIDC(), + "zitadel_application_api": v2.GetApplicationAPI(), + "zitadel_project_grant": v2.GetProjectGrant(), + "zitadel_user_grant": v2.GetUserGrant(), + "zitadel_org_member": v2.GetOrgMember(), + "zitadel_project_member": v2.GetProjectMember(), + "zitadel_project_grant_member": v2.GetProjectGrantMember(), + "zitadel_domain_policy": v2.GetDomainPolicy(), + "zitadel_label_policy": v2.GetLabelPolicy(), + "zitadel_lockout_policy": v2.GetLockoutPolicy(), + "zitadel_login_policy": v2.GetLoginPolicy(), + "zitadel_password_complexity_policy": v2.GetPasswordComplexityPolicy(), + "zitadel_privacy_policy": v2.GetPrivacyPolicy(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/client.go b/zitadel/v2/client.go index 554410af..536c4272 100644 --- a/zitadel/v2/client.go +++ b/zitadel/v2/client.go @@ -5,61 +5,48 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/oidc/pkg/oidc" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/auth" "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/middleware" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel" ) const ( - IssuerVar = "issuer" - AddressVar = "address" - ProjectVar = "project" - TokenVar = "token" + DomainVar = "domain" + InsecureVar = "insecure" + ProjectVar = "project" + TokenVar = "token" ) type ClientInfo struct { - Issuer string - Address string - Project string - Token string + Domain string + Insecure bool + Project string + Token string } func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { - issuer := d.Get(IssuerVar).(string) - address := d.Get(AddressVar).(string) - projectID := d.Get(ProjectVar).(string) - token := d.Get(TokenVar).(string) - return &ClientInfo{ - issuer, - address, - projectID, - token, + d.Get(DomainVar).(string), + d.Get(InsecureVar).(bool), + d.Get(ProjectVar).(string), + d.Get(TokenVar).(string), }, nil } -func getAuthClient(info *ClientInfo) (*auth.Client, error) { - client, err := auth.NewClient( - info.Issuer, info.Address, - []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, - zitadel.WithCustomURL(info.Issuer, info.Address), - zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token)), - zitadel.WithInsecure(), - ) - if err != nil { - return nil, fmt.Errorf("failed to start zitadel client: %v", err) +func getAdminClient(info *ClientInfo) (*admin.Client, error) { + options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token))} + issuer := info.Domain + if info.Insecure { + options = append(options, zitadel.WithInsecure()) + issuer = "http://" + issuer + } else { + issuer = "https://" + issuer } - return client, nil -} -func getAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( - info.Issuer, info.Address, + issuer, info.Domain, []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, - //zitadel.WithCustomURL(info.Issuer, info.Address), - zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token)), - zitadel.WithInsecure(), + options..., ) if err != nil { return nil, fmt.Errorf("failed to start zitadel client: %v", err) @@ -68,19 +55,22 @@ func getAdminClient(info *ClientInfo) (*admin.Client, error) { } func getManagementClient(info *ClientInfo, orgID string) (*management.Client, error) { - opts := []zitadel.Option{ - zitadel.WithInsecure(), - //zitadel.WithCustomURL(info.Issuer, info.Address), - zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token)), + options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token))} + issuer := info.Domain + if info.Insecure { + options = append(options, zitadel.WithInsecure()) + issuer = "http://" + issuer + } else { + issuer = "https://" + issuer } if orgID != "" { - opts = append(opts, zitadel.WithOrgID(orgID)) + options = append(options, zitadel.WithOrgID(orgID)) } client, err := management.NewClient( - info.Issuer, info.Address, + issuer, info.Domain, []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, - opts..., + options..., ) if err != nil { return nil, fmt.Errorf("failed to start zitadel client: %v", err) diff --git a/zitadel/v2/domain_policy.go b/zitadel/v2/domain_policy.go index bf9f18d8..e81c97d0 100644 --- a/zitadel/v2/domain_policy.go +++ b/zitadel/v2/domain_policy.go @@ -148,7 +148,9 @@ func readDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{} resp, err := client.GetDomainPolicy(ctx, &management2.GetDomainPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get domain policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get domain policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/label_policy.go b/zitadel/v2/label_policy.go index 4c6ef10f..d90f8b46 100644 --- a/zitadel/v2/label_policy.go +++ b/zitadel/v2/label_policy.go @@ -90,7 +90,7 @@ func GetLabelPolicy() *schema.Resource { labelPolicyDisableWatermark: { Type: schema.TypeBool, Required: true, - Description: "", + Description: "disable watermark", }, labelPolicyLogoURL: { Type: schema.TypeString, @@ -229,7 +229,9 @@ func readLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) resp, err := client.GetLabelPolicy(ctx, &management2.GetLabelPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get domain policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get domain policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/lockout_policy.go b/zitadel/v2/lockout_policy.go index dc3503f1..212605a7 100644 --- a/zitadel/v2/lockout_policy.go +++ b/zitadel/v2/lockout_policy.go @@ -79,7 +79,7 @@ func updateLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interfac } _, err = client.UpdateCustomLockoutPolicy(ctx, &management2.UpdateCustomLockoutPolicyRequest{ - MaxPasswordAttempts: d.Get(lockoutPolicyMaxPasswordAttempts).(uint32), + MaxPasswordAttempts: uint32(d.Get(lockoutPolicyMaxPasswordAttempts).(int)), }) if err != nil { return diag.Errorf("failed to update lockout policy: %v", err) @@ -103,7 +103,7 @@ func createLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interfac } _, err = client.AddCustomLockoutPolicy(ctx, &management2.AddCustomLockoutPolicyRequest{ - MaxPasswordAttempts: d.Get(lockoutPolicyMaxPasswordAttempts).(uint32), + MaxPasswordAttempts: uint32(d.Get(lockoutPolicyMaxPasswordAttempts).(int)), }) if err != nil { return diag.Errorf("failed to create lockout policy: %v", err) @@ -128,7 +128,9 @@ func readLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{ resp, err := client.GetLockoutPolicy(ctx, &management2.GetLockoutPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get lockout policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get lockout policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go index 6d46df9a..3c2e02d3 100644 --- a/zitadel/v2/login_policy.go +++ b/zitadel/v2/login_policy.go @@ -59,7 +59,7 @@ func GetLoginPolicy() *schema.Resource { Description: "defines if a user MUST use a multi factor to log in", }, loginPolicyPasswordlessType: { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, Description: "defines if passwordless is allowed for users", }, @@ -178,7 +178,7 @@ func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ AllowRegister: d.Get(loginPolicyAllowRegister).(bool), AllowExternalIdp: d.Get(loginPolicyAllowExternalIDP).(bool), ForceMfa: d.Get(loginPolicyForceMFA).(bool), - PasswordlessType: d.Get(loginPolicyPasswordlessType).(policy.PasswordlessType), + PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]), HidePasswordReset: d.Get(loginPolicyHidePasswordReset).(bool), IgnoreUnknownUsernames: d.Get(loginPolicyIgnoreUnknownUsernames).(bool), DefaultRedirectUri: d.Get(loginPolicyDefaultRedirectURI).(string), @@ -235,7 +235,7 @@ func createLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ AllowRegister: d.Get(loginPolicyAllowRegister).(bool), AllowExternalIdp: d.Get(loginPolicyAllowExternalIDP).(bool), ForceMfa: d.Get(loginPolicyForceMFA).(bool), - PasswordlessType: d.Get(loginPolicyPasswordlessType).(policy.PasswordlessType), + PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]), HidePasswordReset: d.Get(loginPolicyHidePasswordReset).(bool), IgnoreUnknownUsernames: d.Get(loginPolicyIgnoreUnknownUsernames).(bool), DefaultRedirectUri: d.Get(loginPolicyDefaultRedirectURI).(string), @@ -268,7 +268,9 @@ func readLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) resp, err := client.GetLoginPolicy(ctx, &management2.GetLoginPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get login policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get login policy: %v", err) } policy := resp.Policy @@ -279,13 +281,13 @@ func readLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) loginPolicyAllowRegister: policy.GetAllowRegister(), loginPolicyAllowExternalIDP: policy.GetAllowExternalIdp(), loginPolicyForceMFA: policy.GetForceMfa(), - loginPolicyPasswordlessType: policy.GetPasswordlessType(), + loginPolicyPasswordlessType: policy.GetPasswordlessType().String(), loginPolicyHidePasswordReset: policy.GetHidePasswordReset(), - loginPolicyPasswordCheckLifetime: policy.GetPasswordCheckLifetime(), - loginPolicyExternalLoginCheckLifetime: policy.GetExternalLoginCheckLifetime(), - loginPolicyMFAInitSkipLifetime: policy.GetMfaInitSkipLifetime(), - loginPolicySecondFactorCheckLifetime: policy.GetSecondFactorCheckLifetime(), - loginPolicyMultiFactorCheckLifetime: policy.GetMultiFactorCheckLifetime(), + loginPolicyPasswordCheckLifetime: policy.GetPasswordCheckLifetime().AsDuration().String(), + loginPolicyExternalLoginCheckLifetime: policy.GetExternalLoginCheckLifetime().AsDuration().String(), + loginPolicyMFAInitSkipLifetime: policy.GetMfaInitSkipLifetime().AsDuration().String(), + loginPolicySecondFactorCheckLifetime: policy.GetSecondFactorCheckLifetime().AsDuration().String(), + loginPolicyMultiFactorCheckLifetime: policy.GetMultiFactorCheckLifetime().AsDuration().String(), } for k, v := range set { diff --git a/zitadel/v2/password_complexity_policy.go b/zitadel/v2/password_complexity_policy.go index 7c85726e..68cf45eb 100644 --- a/zitadel/v2/password_complexity_policy.go +++ b/zitadel/v2/password_complexity_policy.go @@ -102,7 +102,7 @@ func updatePasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, } _, err = client.UpdateCustomPasswordComplexityPolicy(ctx, &management2.UpdateCustomPasswordComplexityPolicyRequest{ - MinLength: d.Get(passwordCompPolicyMinLength).(uint64), + MinLength: uint64(d.Get(passwordCompPolicyMinLength).(int)), HasUppercase: d.Get(passwordCompPolicyHasUppercase).(bool), HasLowercase: d.Get(passwordCompPolicyHasLowercase).(bool), HasNumber: d.Get(passwordCompPolicyHasNumber).(bool), @@ -130,7 +130,7 @@ func createPasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, } _, err = client.AddCustomPasswordComplexityPolicy(ctx, &management2.AddCustomPasswordComplexityPolicyRequest{ - MinLength: d.Get(passwordCompPolicyMinLength).(uint64), + MinLength: uint64(d.Get(passwordCompPolicyMinLength).(int)), HasUppercase: d.Get(passwordCompPolicyHasUppercase).(bool), HasLowercase: d.Get(passwordCompPolicyHasLowercase).(bool), HasNumber: d.Get(passwordCompPolicyHasNumber).(bool), @@ -159,7 +159,9 @@ func readPasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m resp, err := client.GetPasswordComplexityPolicy(ctx, &management2.GetPasswordComplexityPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get password complexity policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get password complexity policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/privacy_policy.go b/zitadel/v2/privacy_policy.go index 67e17f44..7e30d732 100644 --- a/zitadel/v2/privacy_policy.go +++ b/zitadel/v2/privacy_policy.go @@ -143,7 +143,9 @@ func readPrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{ resp, err := client.GetPrivacyPolicy(ctx, &management2.GetPrivacyPolicyRequest{}) if err != nil { - return diag.Errorf("failed to get privacy policy: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to get privacy policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/user.go b/zitadel/v2/user.go index 7228ad7b..b934d1dc 100644 --- a/zitadel/v2/user.go +++ b/zitadel/v2/user.go @@ -272,7 +272,6 @@ func createMachineUser(ctx context.Context, d *schema.ResourceData, m interface{ return diag.Errorf("failed to create machine user: %v", err) } d.SetId(respUser.UserId) - return nil } diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant.go index 8d7bc467..ee3a3b15 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant.go @@ -13,7 +13,7 @@ const ( userGrantProjectGrantIDVar = "project_grant_id" userGrantUserIDVar = "user_id" userGrantRoleKeysVar = "role_keys" - userGrantResourceOwnerVar = "resource_owner" + userGrantOrgIDVar = "org_id" ) func GetUserGrant() *schema.Resource { @@ -45,7 +45,7 @@ func GetUserGrant() *schema.Resource { Required: true, Description: "List of roles granted", }, - userGrantResourceOwnerVar: { + userGrantOrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization which owns the resource", @@ -66,7 +66,7 @@ func deleteUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantResourceOwnerVar).(string)) + client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -89,7 +89,7 @@ func updateUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantResourceOwnerVar).(string)) + client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -113,7 +113,7 @@ func createUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantResourceOwnerVar).(string)) + client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -139,7 +139,7 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantResourceOwnerVar).(string)) + client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -157,7 +157,7 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d userGrantProjectIDVar: grant.GetProjectId(), userGrantProjectGrantIDVar: grant.GetProjectGrantId(), userGrantRoleKeysVar: grant.GetRoleKeys(), - userGrantResourceOwnerVar: grant.GetDetails().GetResourceOwner(), + userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), } for k, v := range set { if err := d.Set(k, v); err != nil { From a830718a9ce5ea5569c9fe48f5657e0ceaf8799a Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 25 Jul 2022 15:07:47 +0200 Subject: [PATCH 005/260] fix: correct provider configuration with port and domain --- docs/index.md | 18 +++++---- docs/resources/org.md | 2 - examples/provider/provider.tf | 5 ++- examples/provider/user_grant.tf | 6 +-- templates/index.md.tmpl | 1 - templates/resources/org.md.tmpl | 2 - zitadel/provider.go | 25 ++++++++---- zitadel/v2/client.go | 67 ++++++++++++++++++++------------- zitadel/v2/org.go | 2 +- 9 files changed, 76 insertions(+), 52 deletions(-) diff --git a/docs/index.md b/docs/index.md index 82abda2e..13887f6a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "Provider: ZITADEL" description: |- Provider to manage resources on ZITADEL @@ -19,14 +18,15 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.1" + version = "1.0.0-alpha.3" } } } provider zitadel { - domain = "localhost:8080" + domain = "localhost" insecure = "true" + port = "8080" project = "170832731415117995" token = "local-token" } @@ -37,10 +37,14 @@ provider zitadel { ### Required -- `domain` (String) -- `insecure` (Boolean) -- `project` (String) -- `token` (String) +- `domain` (String) Domain used to connect to the ZITADEL instance +- `project` (String) ID of the ZITADEL project on your ZITADEL instance, for the audience-scope +- `token` (String) Path to the file containing credentials to connect to ZITADEL + +### Optional + +- `insecure` (Boolean) Use insecure connection +- `port` (String) Used port if not the default ports 80 or 443 are configured ## Limitations diff --git a/docs/resources/org.md b/docs/resources/org.md index 77492a6b..2dc8b962 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -1,5 +1,3 @@ - 20 lines (13 sloc) 472 Bytes - --- page_title: "zitadel_org Resource - terraform-provider-zitadel" subcategory: "" diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index ed92ad30..5a401824 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,14 +2,15 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.1" + version = "1.0.0-alpha.3" } } } provider zitadel { - domain = "localhost:8080" + domain = "localhost" insecure = "true" + port = "8080" project = "170832731415117995" token = "local-token" } \ No newline at end of file diff --git a/examples/provider/user_grant.tf b/examples/provider/user_grant.tf index 34e2501d..c2c8f4da 100644 --- a/examples/provider/user_grant.tf +++ b/examples/provider/user_grant.tf @@ -1,9 +1,9 @@ -resource zitade_user_grant user_grant{ - depends_on = ["zitadel_project.project", "zitadel_org.org", "zitadel_human_user.human_user"] +resource zitadel_user_grant user_grant{ + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.human_user] project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = [""] - user_id = zitadel_human_user.granted_human_user + user_id = zitadel_human_user.granted_human_user.id } \ No newline at end of file diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 5a826ebf..60e16150 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "Provider: ZITADEL" description: |- Provider to manage resources on ZITADEL diff --git a/templates/resources/org.md.tmpl b/templates/resources/org.md.tmpl index 0c223bb2..533d3c52 100644 --- a/templates/resources/org.md.tmpl +++ b/templates/resources/org.md.tmpl @@ -1,5 +1,3 @@ - 20 lines (13 sloc) 472 Bytes - --- page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" subcategory: "" diff --git a/zitadel/provider.go b/zitadel/provider.go index 03f069f8..b0f08801 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -14,20 +14,29 @@ func Provider() *schema.Provider { }, Schema: map[string]*schema.Schema{ v2.DomainVar: { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "Domain used to connect to the ZITADEL instance", }, v2.InsecureVar: { - Type: schema.TypeBool, - Required: true, + Type: schema.TypeBool, + Optional: true, + Description: "Use insecure connection", }, v2.ProjectVar: { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "ID of the ZITADEL project on your ZITADEL instance, for the audience-scope", }, v2.TokenVar: { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Description: "Path to the file containing credentials to connect to ZITADEL", + }, + v2.PortVar: { + Type: schema.TypeString, + Optional: true, + Description: "Used port if not the default ports 80 or 443 are configured", }, }, ResourcesMap: map[string]*schema.Resource{ diff --git a/zitadel/v2/client.go b/zitadel/v2/client.go index 536c4272..c2ffe6f3 100644 --- a/zitadel/v2/client.go +++ b/zitadel/v2/client.go @@ -15,38 +15,60 @@ const ( InsecureVar = "insecure" ProjectVar = "project" TokenVar = "token" + PortVar = "port" ) type ClientInfo struct { - Domain string - Insecure bool - Project string - Token string + Domain string + Issuer string + Options []zitadel.Option + Project string } func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { - return &ClientInfo{ - d.Get(DomainVar).(string), - d.Get(InsecureVar).(bool), - d.Get(ProjectVar).(string), - d.Get(TokenVar).(string), - }, nil -} + insecure := d.Get(InsecureVar).(bool) + domain := d.Get(DomainVar).(string) + options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(d.Get(TokenVar).(string)))} -func getAdminClient(info *ClientInfo) (*admin.Client, error) { - options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token))} - issuer := info.Domain - if info.Insecure { + portStr := "" + port := d.Get(PortVar) + if port != nil { + portStr = port.(string) + } + + issuer := "" + if portStr != "" { + domain = domain + ":" + portStr + issuer = domain + } else { + issuer = domain + if insecure { + domain = domain + ":80" + } else { + domain = domain + ":443" + } + } + + if insecure { options = append(options, zitadel.WithInsecure()) issuer = "http://" + issuer } else { issuer = "https://" + issuer } + return &ClientInfo{ + domain, + issuer, + options, + d.Get(ProjectVar).(string), + }, nil +} + +func getAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( - issuer, info.Domain, + info.Issuer, info.Domain, []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, - options..., + info.Options..., ) if err != nil { return nil, fmt.Errorf("failed to start zitadel client: %v", err) @@ -55,20 +77,13 @@ func getAdminClient(info *ClientInfo) (*admin.Client, error) { } func getManagementClient(info *ClientInfo, orgID string) (*management.Client, error) { - options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(info.Token))} - issuer := info.Domain - if info.Insecure { - options = append(options, zitadel.WithInsecure()) - issuer = "http://" + issuer - } else { - issuer = "https://" + issuer - } + options := info.Options if orgID != "" { options = append(options, zitadel.WithOrgID(orgID)) } client, err := management.NewClient( - issuer, info.Domain, + info.Issuer, info.Domain, []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, options..., ) diff --git a/zitadel/v2/org.go b/zitadel/v2/org.go index 480b38b4..109d4659 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org.go @@ -84,7 +84,7 @@ func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di resp, err := client.ListOrgs(ctx, &admin2.ListOrgsRequest{}) if err != nil { - return diag.FromErr(err) + return diag.Errorf("error while listing orgs: %v", err) } tflog.Debug(ctx, "found orgs", map[string]interface{}{ "orglist": resp.Result, From 951475639e663da6208995ce19493ea646181f07 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 25 Jul 2022 17:11:00 +0200 Subject: [PATCH 006/260] fix: add basic documentation and corrections for human user --- docs/index.md | 2 +- docs/resources/action.md | 20 +++- docs/resources/application_api.md | 18 ++- docs/resources/application_oidc.md | 32 +++++- docs/resources/domain.md | 16 ++- docs/resources/domain_policy.md | 18 ++- docs/resources/human_user.md | 36 ++++-- docs/resources/label_policy.md | 25 ++++- docs/resources/lockout_policy.md | 16 ++- docs/resources/login_policy.md | 34 ++++-- docs/resources/machine_user.md | 18 ++- docs/resources/org.md | 4 +- docs/resources/org_member.md | 17 ++- docs/resources/password_complexity_policy.md | 20 +++- docs/resources/privacy_policy.md | 18 ++- docs/resources/project.md | 20 +++- docs/resources/project_grant.md | 17 ++- docs/resources/project_grant_member.md | 19 +++- docs/resources/project_member.md | 18 ++- docs/resources/project_role.md | 19 +++- docs/resources/user_grant.md | 18 ++- examples/provider/provider.tf | 2 +- templates/resources/action.md.tmpl | 16 +++ templates/resources/application_api.md.tmpl | 16 +++ templates/resources/application_oidc.md.tmpl | 16 +++ templates/resources/domain.md.tmpl | 16 +++ templates/resources/domain_policy.md.tmpl | 16 +++ templates/resources/human_user.md.tmpl | 16 +++ templates/resources/label_policy.md.tmpl | 16 +++ templates/resources/lockout_policy.md.tmpl | 16 +++ templates/resources/login_policy.md.tmpl | 16 +++ templates/resources/machine_user.md.tmpl | 16 +++ templates/resources/org_member.md.tmpl | 16 +++ .../password_complexity_policy.md.tmpl | 16 +++ templates/resources/privacy_policy.md.tmpl | 16 +++ templates/resources/project.md.tmpl | 16 +++ templates/resources/project_grant.md.tmpl | 16 +++ .../resources/project_grant_member.md.tmpl | 16 +++ templates/resources/project_member.md.tmpl | 16 +++ templates/resources/project_role.md.tmpl | 16 +++ templates/resources/user_grant.md.tmpl | 16 +++ zitadel/v2/action.go | 1 + zitadel/v2/application_api.go | 1 + zitadel/v2/application_oidc.go | 1 + zitadel/v2/domain.go | 1 + zitadel/v2/domain_policy.go | 1 + zitadel/v2/label_policy.go | 1 + zitadel/v2/lockout_policy.go | 1 + zitadel/v2/login_policy.go | 1 + zitadel/v2/org.go | 1 + zitadel/v2/org_member.go | 1 + zitadel/v2/password_complexity_policy.go | 1 + zitadel/v2/privacy_policy.go | 1 + zitadel/v2/project.go | 1 + zitadel/v2/project_grant.go | 1 + zitadel/v2/project_grant_member.go | 1 + zitadel/v2/project_member.go | 1 + zitadel/v2/project_role.go | 1 + zitadel/v2/user.go | 106 +++++++++++++----- zitadel/v2/user_grant.go | 1 + 60 files changed, 697 insertions(+), 138 deletions(-) create mode 100644 templates/resources/action.md.tmpl create mode 100644 templates/resources/application_api.md.tmpl create mode 100644 templates/resources/application_oidc.md.tmpl create mode 100644 templates/resources/domain.md.tmpl create mode 100644 templates/resources/domain_policy.md.tmpl create mode 100644 templates/resources/human_user.md.tmpl create mode 100644 templates/resources/label_policy.md.tmpl create mode 100644 templates/resources/lockout_policy.md.tmpl create mode 100644 templates/resources/login_policy.md.tmpl create mode 100644 templates/resources/machine_user.md.tmpl create mode 100644 templates/resources/org_member.md.tmpl create mode 100644 templates/resources/password_complexity_policy.md.tmpl create mode 100644 templates/resources/privacy_policy.md.tmpl create mode 100644 templates/resources/project.md.tmpl create mode 100644 templates/resources/project_grant.md.tmpl create mode 100644 templates/resources/project_grant_member.md.tmpl create mode 100644 templates/resources/project_member.md.tmpl create mode 100644 templates/resources/project_role.md.tmpl create mode 100644 templates/resources/user_grant.md.tmpl diff --git a/docs/index.md b/docs/index.md index 13887f6a..69ba6bbd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,7 +18,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.3" + version = "1.0.0-alpha.4" } } } diff --git a/docs/resources/action.md b/docs/resources/action.md index afc8e54f..ffb34837 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -1,16 +1,28 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_action Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing an action belonging to an organization. --- # zitadel_action (Resource) +Resource representing an action belonging to an organization. +## Example Usage +```terraform +resource zitadel_action action { + depends_on = [zitadel_org.org] + provider = zitadel + org_id = zitadel_org.org.id + name = "actionname" + script = "testscript" + timeout = "10s" + allowed_to_fail = "true" +} +``` ## Schema @@ -26,6 +38,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `state` (Number) the state of the action - - +- `state` (Number) the state of the action \ No newline at end of file diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 1d5a1645..7421c39f 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_application_api Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing an API application belonging to a project, with all configuration possibilities. --- # zitadel_application_api (Resource) +Resource representing an API application belonging to a project, with all configuration possibilities. +## Example Usage +```terraform +resource zitadel_application_api application_api { + depends_on = [zitadel_org.org, zitadel_project.project] + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + name = "applicationapi" + auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" +} +``` ## Schema @@ -24,6 +34,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 111e981e..7b194926 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -1,16 +1,40 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_application_oidc Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing an OIDC application belonging to a project, with all configuration possibilities. --- # zitadel_application_oidc (Resource) +Resource representing an OIDC application belonging to a project, with all configuration possibilities. +## Example Usage +```terraform +resource zitadel_application_oidc application_oidc { + depends_on = [zitadel_org.org, zitadel_project.project] + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + + name = "applicationoidc" + redirect_uris = ["https://localhost.com"] + response_types = ["OIDC_RESPONSE_TYPE_CODE"] + grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] + post_logout_redirect_uris = ["https://localhost.com"] + app_type = "OIDC_APP_TYPE_WEB" + auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" + version = "OIDC_VERSION_1_0" + clock_skew = "0s" + dev_mode = "true" + access_token_type = "OIDC_TOKEN_TYPE_BEARER" + access_token_role_assertion = "false" + id_token_role_assertion = "false" + id_token_userinfo_assertion = "false" + additional_origins = [] +} +``` ## Schema @@ -40,6 +64,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 7e1a0d1e..30cb98b1 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -1,16 +1,24 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_domain Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing a domain of the organization. --- # zitadel_domain (Resource) +Resource representing a domain of the organization. +## Example Usage +```terraform +resource zitadel_domain domain { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + name = "localhost.com" +} +``` ## Schema @@ -25,6 +33,4 @@ description: |- - `id` (String) The ID of this resource. - `is_primary` (Boolean) Is domain primary - `is_verified` (Boolean) Is domain verified -- `validation_type` (Number) Validation type - - +- `validation_type` (Number) Validation type \ No newline at end of file diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 447846f7..824c40c1 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_domain_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom domain policy of an organization. --- # zitadel_domain_policy (Resource) +Resource representing the custom domain policy of an organization. +## Example Usage +```terraform +resource zitadel_domain_policy domain_policy { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + user_login_must_be_domain = "false" + validate_org_domains = "false" + smtp_sender_address_matches_instance_domain = "false" +} +``` ## Schema @@ -25,6 +35,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `is_default` (Boolean) Is this policy the default - - +- `is_default` (Boolean) Is this policy the default \ No newline at end of file diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 0c8b097e..e8518766 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -1,22 +1,42 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_human_user Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources. --- # zitadel_human_user (Resource) - - - +Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources. + +## Example Usage + +```terraform +resource zitadel_human_user human_user { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_name = "human" + first_name = "firstname" + last_name = "lastname" + nick_name = "nickname" + display_name = "displayname" + preferred_language = "de" + gender = "GENDER_MALE" + phone = "+41799999999" + is_phone_verified = "true" + email = "test@zitadel.com" + is_email_verified = "false" +} +``` ## Schema ### Required +- `first_name` (String) First name of the user +- `last_name` (String) Last name of the user - `org_id` (String) ID of the organization - `user_name` (String) Username @@ -24,12 +44,10 @@ description: |- - `display_name` (String) DIsplay name of the user - `email` (String) Email of the user -- `first_name` (String) First name of the user - `gender` (String) Gender of the user - `initial_password` (String) Initially set password for the user - `is_email_verified` (Boolean) Is the email verified of the user - `is_phone_verified` (Boolean) Is the phone verified of the user -- `last_name` (String) Last name of the user - `nick_name` (String) Nick name of the user - `phone` (String) Phone of the user - `preferred_language` (String) Preferred language of the user @@ -39,6 +57,4 @@ description: |- - `id` (String) The ID of this resource. - `login_names` (List of String) Loginnames - `preferred_login_name` (String) Preferred login name -- `state` (String) State of the user - - +- `state` (String) State of the user \ No newline at end of file diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index 4598533d..26d2b1bf 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -1,16 +1,33 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_label_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom label policy of an organization. --- # zitadel_label_policy (Resource) +Resource representing the custom label policy of an organization. +## Example Usage +```terraform +resource zitadel_label_policy label_policy { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + primary_color = "#5469d4" + hide_login_name_suffix = "true" + warn_color = "#cd3d56" + background_color = "#fafafa" + font_color = "#000000" + primary_color_dark = "#a5b4fc" + background_color_dark = "#111827" + warn_color_dark = "#ff3b5b" + font_color_dark = "#ffffff" + disable_watermark = "false" +} +``` ## Schema @@ -37,6 +54,4 @@ description: |- - `id` (String) The ID of this resource. - `is_default` (Boolean) defines if the organisation's admin changed the policy - `logo_url` (String) -- `logo_url_dark` (String) - - +- `logo_url_dark` (String) \ No newline at end of file diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index 9cb1304f..e61e9c03 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -1,16 +1,24 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_lockout_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom lockout policy of an organization. --- # zitadel_lockout_policy (Resource) +Resource representing the custom lockout policy of an organization. +## Example Usage +```terraform +resource zitadel_lockout_policy lockout_policy { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + max_password_attempts = "5" +} +``` ## Schema @@ -26,6 +34,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy - - +- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 8347e613..9caf3afd 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -1,16 +1,36 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_login_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom login policy of an organization. --- # zitadel_login_policy (Resource) - - - +Resource representing the custom login policy of an organization. + +## Example Usage + +```terraform +resource zitadel_login_policy login_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_login = "true" + allow_register = "true" + allow_external_idp = "true" + force_mfa = "false" + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h" + external_login_check_lifetime = "240h" + multi_factor_check_lifetime = "720h" + mfa_init_skip_lifetime = "24h" + second_factor_check_lifetime = "24h" + ignore_unknown_usernames = "true" + default_redirect_uri = "localhost:8080" +} +``` ## Schema @@ -35,6 +55,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy - - +- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index acd2c884..3f0a8286 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_machine_user Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources. --- # zitadel_machine_user (Resource) +Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources. +## Example Usage +```terraform +resource zitadel_machine_user machine_user { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + user_name = "machine" + name = "name" + description = "description" +} +``` ## Schema @@ -30,6 +40,4 @@ description: |- - `id` (String) The ID of this resource. - `login_names` (List of String) Loginnames - `preferred_login_name` (String) Preferred login name -- `state` (String) State of the user - - +- `state` (String) State of the user \ No newline at end of file diff --git a/docs/resources/org.md b/docs/resources/org.md index 2dc8b962..5da6722c 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -2,12 +2,12 @@ page_title: "zitadel_org Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance. --- # zitadel_org (Resource) - +Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance. ## Example Usage diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 740da9c2..5ca877e9 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -1,16 +1,25 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_org_member Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the membership of a user on an organization, defined with the given role. --- # zitadel_org_member (Resource) +Resource representing the membership of a user on an organization, defined with the given role. +## Example Usage +```terraform +resource zitadel_org_member org_member { + depends_on = [zitadel_org.org, zitadel_human_user.human_user] + org_id = zitadel_org.org.id + user_id = zitadel_human_user.human_user.id + roles = ["ORG_OWNER"] +} +``` ## Schema @@ -23,6 +32,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index 81d10ced..8c5f0e46 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -1,16 +1,28 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_password_complexity_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom password complexity policy of an organization. --- # zitadel_password_complexity_policy (Resource) +Resource representing the custom password complexity policy of an organization. +## Example Usage +```terraform +resource zitadel_password_complexity_policy password_complexity_policy { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + min_length = "8" + has_uppercase = "true" + has_lowercase = "true" + has_number = "true" + has_symbol = "true" +} +``` ## Schema @@ -27,6 +39,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy - - +- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 6c05c85f..52b5179f 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_privacy_policy Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the custom privacy policy of an organization. --- # zitadel_privacy_policy (Resource) +Resource representing the custom privacy policy of an organization. +## Example Usage +```terraform +resource zitadel_privacy_policy privacy_policy { + depends_on = [zitadel_org.org] + org_id = zitadel_org.org.id + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" +} +``` ## Schema @@ -25,6 +35,4 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. -- `is_default` (Boolean) - - +- `is_default` (Boolean) \ No newline at end of file diff --git a/docs/resources/project.md b/docs/resources/project.md index bb628ff3..afca8daf 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -1,16 +1,28 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_project Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the project, which can then be granted to different organizations or users directly, containing different applications. --- # zitadel_project (Resource) +Resource representing the project, which can then be granted to different organizations or users directly, containing different applications. +## Example Usage +```terraform +resource zitadel_project project { + depends_on = [zitadel_org.org] + name = "projectname" + org_id = zitadel_org.org.id + project_role_assertion = "true" + project_role_check = "true" + has_project_check = "true" + private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" +} +``` ## Schema @@ -30,6 +42,4 @@ description: |- ### Read-Only - `id` (String) ID of the project -- `state` (String) State of the project - - +- `state` (String) State of the project \ No newline at end of file diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 4d5ee736..31181952 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -1,16 +1,25 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_project_grant Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant. --- # zitadel_project_grant (Resource) +Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant. +## Example Usage +```terraform +resource zitadel_project_grant project_grant { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + granted_org_id = zitadel_org.grantedorg.id +} +``` ## Schema @@ -27,6 +36,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 945a72cb..698dc6ee 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -1,16 +1,27 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_project_grant_member Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the membership of a user on an granted project, defined with the given role. --- # zitadel_project_grant_member (Resource) +Resource representing the membership of a user on an granted project, defined with the given role. +## Example Usage +```terraform +resource zitadel_project_grant_member project_grant_member { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_project_grant.project_grant, zitadel_human_user.granted_human_user] + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + grant_id = zitadel_project_grant.project_grant.id + user_id = zitadel_human_user.granted_human_user.id + roles = ["PROJECT_GRANT_OWNER"] +} +``` ## Schema @@ -25,6 +36,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index e548023f..fef6e934 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_project_member Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the membership of a user on an project, defined with the given role. --- # zitadel_project_member (Resource) +Resource representing the membership of a user on an project, defined with the given role. +## Example Usage +```terraform +resource zitadel_project_member project_member { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_human_user.human_user] + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + user_id = zitadel_human_user.human_user.id + roles = ["PROJECT_OWNER"] +} +``` ## Schema @@ -24,6 +34,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index dc088a5c..ecf7e291 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -1,16 +1,27 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_project_role Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the project roles, which can be given as authorizations to users. --- # zitadel_project_role (Resource) +Resource representing the project roles, which can be given as authorizations to users. +## Example Usage +```terraform +resource zitadel_project_role project_role { + depends_on = [zitadel_org.org, zitadel_project.project] + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + role_key = "key" + display_name = "display_name2" + group = "role_group" +} +``` ## Schema @@ -28,6 +39,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index f9e207c0..4a0407cc 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -1,16 +1,26 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_user_grant Resource - terraform-provider-zitadel" subcategory: "" description: |- - + Resource representing the authorization given to a user directly, including the given roles. --- # zitadel_user_grant (Resource) +Resource representing the authorization given to a user directly, including the given roles. +## Example Usage +```terraform +resource zitadel_user_grant user_grant{ + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.human_user] + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + role_keys = [""] + user_id = zitadel_human_user.granted_human_user.id +} +``` ## Schema @@ -28,6 +38,4 @@ description: |- ### Read-Only -- `id` (String) The ID of this resource. - - +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 5a401824..b1f07936 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.3" + version = "1.0.0-alpha.4" } } } diff --git a/templates/resources/action.md.tmpl b/templates/resources/action.md.tmpl new file mode 100644 index 00000000..dba55919 --- /dev/null +++ b/templates/resources/action.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/action.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/application_api.md.tmpl b/templates/resources/application_api.md.tmpl new file mode 100644 index 00000000..ff120262 --- /dev/null +++ b/templates/resources/application_api.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/application_api.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/application_oidc.md.tmpl b/templates/resources/application_oidc.md.tmpl new file mode 100644 index 00000000..81d4c763 --- /dev/null +++ b/templates/resources/application_oidc.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/application_oidc.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/domain.md.tmpl b/templates/resources/domain.md.tmpl new file mode 100644 index 00000000..6e7a2280 --- /dev/null +++ b/templates/resources/domain.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/domain.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/domain_policy.md.tmpl b/templates/resources/domain_policy.md.tmpl new file mode 100644 index 00000000..ddcdab44 --- /dev/null +++ b/templates/resources/domain_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/domain_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/human_user.md.tmpl b/templates/resources/human_user.md.tmpl new file mode 100644 index 00000000..36c2cfc1 --- /dev/null +++ b/templates/resources/human_user.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/human_user.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/label_policy.md.tmpl b/templates/resources/label_policy.md.tmpl new file mode 100644 index 00000000..d3bb74dd --- /dev/null +++ b/templates/resources/label_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/label_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/lockout_policy.md.tmpl b/templates/resources/lockout_policy.md.tmpl new file mode 100644 index 00000000..0c6ee571 --- /dev/null +++ b/templates/resources/lockout_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/lockout_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/login_policy.md.tmpl b/templates/resources/login_policy.md.tmpl new file mode 100644 index 00000000..798ebf7e --- /dev/null +++ b/templates/resources/login_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/login_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/machine_user.md.tmpl b/templates/resources/machine_user.md.tmpl new file mode 100644 index 00000000..2947a2df --- /dev/null +++ b/templates/resources/machine_user.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/machine_user.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_member.md.tmpl b/templates/resources/org_member.md.tmpl new file mode 100644 index 00000000..239ae240 --- /dev/null +++ b/templates/resources/org_member.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/org_member.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/password_complexity_policy.md.tmpl b/templates/resources/password_complexity_policy.md.tmpl new file mode 100644 index 00000000..d68917e8 --- /dev/null +++ b/templates/resources/password_complexity_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/password_complexity_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/privacy_policy.md.tmpl b/templates/resources/privacy_policy.md.tmpl new file mode 100644 index 00000000..8f8669c0 --- /dev/null +++ b/templates/resources/privacy_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/privacy_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project.md.tmpl b/templates/resources/project.md.tmpl new file mode 100644 index 00000000..61d79abf --- /dev/null +++ b/templates/resources/project.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/project.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_grant.md.tmpl b/templates/resources/project_grant.md.tmpl new file mode 100644 index 00000000..0a99f11b --- /dev/null +++ b/templates/resources/project_grant.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/project_grant.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_grant_member.md.tmpl b/templates/resources/project_grant_member.md.tmpl new file mode 100644 index 00000000..27b68166 --- /dev/null +++ b/templates/resources/project_grant_member.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/project_grant_member.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_member.md.tmpl b/templates/resources/project_member.md.tmpl new file mode 100644 index 00000000..fecd8e25 --- /dev/null +++ b/templates/resources/project_member.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/project_member.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_role.md.tmpl b/templates/resources/project_role.md.tmpl new file mode 100644 index 00000000..3b880229 --- /dev/null +++ b/templates/resources/project_role.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/project_role.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/user_grant.md.tmpl b/templates/resources/user_grant.md.tmpl new file mode 100644 index 00000000..a47b3868 --- /dev/null +++ b/templates/resources/user_grant.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/user_grant.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/v2/action.go b/zitadel/v2/action.go index fb0e1553..2588b954 100644 --- a/zitadel/v2/action.go +++ b/zitadel/v2/action.go @@ -21,6 +21,7 @@ const ( func GetAction() *schema.Resource { return &schema.Resource{ + Description: "Resource representing an action belonging to an organization.", Schema: map[string]*schema.Schema{ actionOrgId: { Type: schema.TypeString, diff --git a/zitadel/v2/application_api.go b/zitadel/v2/application_api.go index b66e58d3..6bf51887 100644 --- a/zitadel/v2/application_api.go +++ b/zitadel/v2/application_api.go @@ -13,6 +13,7 @@ import ( func GetApplicationAPI() *schema.Resource { return &schema.Resource{ + Description: "Resource representing an API application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ applicationOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/application_oidc.go b/zitadel/v2/application_oidc.go index 688258b9..b0ddf4ca 100644 --- a/zitadel/v2/application_oidc.go +++ b/zitadel/v2/application_oidc.go @@ -34,6 +34,7 @@ const ( func GetApplicationOIDC() *schema.Resource { return &schema.Resource{ + Description: "Resource representing an OIDC application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ applicationOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/domain.go b/zitadel/v2/domain.go index a460a77c..4c120cd6 100644 --- a/zitadel/v2/domain.go +++ b/zitadel/v2/domain.go @@ -20,6 +20,7 @@ const ( func GetDomain() *schema.Resource { return &schema.Resource{ + Description: "Resource representing a domain of the organization.", Schema: map[string]*schema.Schema{ domainNameVar: { Type: schema.TypeString, diff --git a/zitadel/v2/domain_policy.go b/zitadel/v2/domain_policy.go index e81c97d0..b247403d 100644 --- a/zitadel/v2/domain_policy.go +++ b/zitadel/v2/domain_policy.go @@ -19,6 +19,7 @@ const ( func GetDomainPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom domain policy of an organization.", Schema: map[string]*schema.Schema{ domainPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/label_policy.go b/zitadel/v2/label_policy.go index d90f8b46..e5212627 100644 --- a/zitadel/v2/label_policy.go +++ b/zitadel/v2/label_policy.go @@ -30,6 +30,7 @@ const ( func GetLabelPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom label policy of an organization.", Schema: map[string]*schema.Schema{ labelPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/lockout_policy.go b/zitadel/v2/lockout_policy.go index 212605a7..b804292b 100644 --- a/zitadel/v2/lockout_policy.go +++ b/zitadel/v2/lockout_policy.go @@ -16,6 +16,7 @@ const ( func GetLockoutPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom lockout policy of an organization.", Schema: map[string]*schema.Schema{ lockoutPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go index 3c2e02d3..5ee252e8 100644 --- a/zitadel/v2/login_policy.go +++ b/zitadel/v2/login_policy.go @@ -31,6 +31,7 @@ const ( func GetLoginPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom login policy of an organization.", Schema: map[string]*schema.Schema{ loginPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org.go b/zitadel/v2/org.go index 109d4659..c65a3e8b 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org.go @@ -16,6 +16,7 @@ const ( func OrgResource() *schema.Resource { return &schema.Resource{ + Description: "Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", Schema: map[string]*schema.Schema{ nameVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_member.go b/zitadel/v2/org_member.go index 87d75e06..ba775104 100644 --- a/zitadel/v2/org_member.go +++ b/zitadel/v2/org_member.go @@ -17,6 +17,7 @@ const ( func GetOrgMember() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the membership of a user on an organization, defined with the given role.", Schema: map[string]*schema.Schema{ orgMemberOrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/password_complexity_policy.go b/zitadel/v2/password_complexity_policy.go index 68cf45eb..697e40b7 100644 --- a/zitadel/v2/password_complexity_policy.go +++ b/zitadel/v2/password_complexity_policy.go @@ -20,6 +20,7 @@ const ( func GetPasswordComplexityPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom password complexity policy of an organization.", Schema: map[string]*schema.Schema{ passwordCompPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/privacy_policy.go b/zitadel/v2/privacy_policy.go index 7e30d732..194bac93 100644 --- a/zitadel/v2/privacy_policy.go +++ b/zitadel/v2/privacy_policy.go @@ -18,6 +18,7 @@ const ( func GetPrivacyPolicy() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the custom privacy policy of an organization.", Schema: map[string]*schema.Schema{ privacyPolicyOrgIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/project.go b/zitadel/v2/project.go index f25a0434..87e72a74 100644 --- a/zitadel/v2/project.go +++ b/zitadel/v2/project.go @@ -22,6 +22,7 @@ const ( func GetProject() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the project, which can then be granted to different organizations or users directly, containing different applications.", Schema: map[string]*schema.Schema{ projectIdVar: { Type: schema.TypeString, diff --git a/zitadel/v2/project_grant.go b/zitadel/v2/project_grant.go index 77791796..a945fe19 100644 --- a/zitadel/v2/project_grant.go +++ b/zitadel/v2/project_grant.go @@ -17,6 +17,7 @@ const ( func GetProjectGrant() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant.", Schema: map[string]*schema.Schema{ projectGrantProjectIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/project_grant_member.go b/zitadel/v2/project_grant_member.go index eb77b06b..f5773762 100644 --- a/zitadel/v2/project_grant_member.go +++ b/zitadel/v2/project_grant_member.go @@ -18,6 +18,7 @@ const ( func GetProjectGrantMember() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the membership of a user on an granted project, defined with the given role.", Schema: map[string]*schema.Schema{ projectGrantMemberOrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/project_member.go b/zitadel/v2/project_member.go index 35af3167..5633cfa5 100644 --- a/zitadel/v2/project_member.go +++ b/zitadel/v2/project_member.go @@ -17,6 +17,7 @@ const ( func GetProjectMember() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the membership of a user on an project, defined with the given role.", Schema: map[string]*schema.Schema{ projectMemberOrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/project_role.go b/zitadel/v2/project_role.go index d7b1da9b..6ebd32ae 100644 --- a/zitadel/v2/project_role.go +++ b/zitadel/v2/project_role.go @@ -20,6 +20,7 @@ const ( func GetProjectRole() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the project roles, which can be given as authorizations to users.", Schema: map[string]*schema.Schema{ projectRoleProjectID: { Type: schema.TypeString, diff --git a/zitadel/v2/user.go b/zitadel/v2/user.go index b934d1dc..eee11e00 100644 --- a/zitadel/v2/user.go +++ b/zitadel/v2/user.go @@ -40,6 +40,7 @@ const ( func GetHumanUser() *schema.Resource { return &schema.Resource{ + Description: "Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, @@ -75,12 +76,12 @@ func GetHumanUser() *schema.Resource { firstNameVar: { Type: schema.TypeString, - Optional: true, + Required: true, Description: "First name of the user", }, lastNameVar: { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Last name of the user", }, nickNameVar: { @@ -138,6 +139,7 @@ func GetHumanUser() *schema.Resource { func GetMachineUser() *schema.Resource { return &schema.Resource{ + Description: "Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, @@ -222,26 +224,58 @@ func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } - gender := d.Get(genderVar).(string) - respUser, err := client.AddHumanUser(ctx, &management2.AddHumanUserRequest{ + addUser := &management2.AddHumanUserRequest{ UserName: d.Get(userNameVar).(string), Profile: &management2.AddHumanUserRequest_Profile{ - FirstName: d.Get(firstNameVar).(string), - LastName: d.Get(lastNameVar).(string), - NickName: d.Get(nickNameVar).(string), - DisplayName: d.Get(displayNameVar).(string), - PreferredLanguage: d.Get(preferredLanguageVar).(string), - Gender: user.Gender(user.Gender_value[gender]), - }, - Email: &management2.AddHumanUserRequest_Email{ - Email: d.Get(emailVar).(string), - IsEmailVerified: d.Get(isEmailVerifiedVar).(bool), - }, - Phone: &management2.AddHumanUserRequest_Phone{ - Phone: d.Get(phoneVar).(string), - IsPhoneVerified: d.Get(isPhoneVerifiedVar).(bool), + FirstName: d.Get(firstNameVar).(string), + LastName: d.Get(lastNameVar).(string), }, - }) + } + + nickname := d.Get(nickNameVar).(string) + if nickname != "" { + addUser.Profile.NickName = nickname + } + displayname := d.Get(displayNameVar).(string) + if displayname != "" { + addUser.Profile.DisplayName = displayname + } + + prefLang := d.Get(preferredLanguageVar).(string) + if prefLang != "" { + addUser.Profile.PreferredLanguage = prefLang + } + + gender := d.Get(genderVar).(string) + if gender != "" { + addUser.Profile.Gender = user.Gender(user.Gender_value[gender]) + } + + email := d.Get(emailVar).(string) + if email != "" { + isVerified := d.Get(isEmailVerifiedVar) + addUser.Email = &management2.AddHumanUserRequest_Email{ + Email: email, + IsEmailVerified: false, + } + if isVerified != nil { + addUser.Email.IsEmailVerified = isVerified.(bool) + } + } + + phone := d.Get(phoneVar).(string) + if phone != "" { + isVerified := d.Get(isPhoneVerifiedVar) + addUser.Phone = &management2.AddHumanUserRequest_Phone{ + Phone: phone, + IsPhoneVerified: false, + } + if isVerified != nil { + addUser.Email.IsEmailVerified = isVerified.(bool) + } + } + + respUser, err := client.AddHumanUser(ctx, addUser) if err != nil { return diag.Errorf("failed to create human user: %v", err) } @@ -304,13 +338,23 @@ func updateHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) } } + nickname := d.Get(nickNameVar) + displayname := d.Get(displayNameVar) + prefLang := d.Get(preferredLanguageVar) + gender := d.Get(genderVar) + email := d.Get(emailVar) + emailVerfied := d.Get(isEmailVerifiedVar) + phone := d.Get(phoneVar) + phoneVerified := d.Get(isPhoneVerifiedVar) + currentHuman := currentUser.GetUser().GetHuman() if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || - currentHuman.GetProfile().GetNickName() != d.Get(nickNameVar).(string) || - currentHuman.GetProfile().GetDisplayName() != d.Get(displayNameVar).(string) || - currentHuman.GetProfile().GetPreferredLanguage() != d.Get(preferredLanguageVar).(string) { - gender := d.Get(genderVar).(string) + (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || + (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || + (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || + (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { + _, err := client.UpdateHumanProfile(ctx, &management2.UpdateHumanProfileRequest{ UserId: d.Id(), FirstName: d.Get(firstNameVar).(string), @@ -318,34 +362,34 @@ func updateHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) NickName: d.Get(nickNameVar).(string), DisplayName: d.Get(displayNameVar).(string), PreferredLanguage: d.Get(preferredLanguageVar).(string), - Gender: user.Gender(user.Gender_value[gender]), + Gender: user.Gender(user.Gender_value[gender.(string)]), }) if err != nil { return diag.Errorf("failed to update human profile: %v", err) } } - if currentHuman.GetEmail().GetEmail() != d.Get(emailVar).(string) || currentHuman.GetEmail().GetIsEmailVerified() != d.Get(isEmailVerifiedVar).(bool) { + + if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { _, err = client.UpdateHumanEmail(ctx, &management2.UpdateHumanEmailRequest{ UserId: d.Id(), - Email: d.Get(emailVar).(string), - IsEmailVerified: d.Get(isEmailVerifiedVar).(bool), + Email: email.(string), + IsEmailVerified: emailVerfied.(bool), }) if err != nil { return diag.Errorf("failed to update human email: %v", err) } } - if currentHuman.GetPhone().GetPhone() != d.Get(phoneVar).(string) || currentHuman.GetPhone().GetIsPhoneVerified() != d.Get(isPhoneVerifiedVar).(bool) { + if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { _, err = client.UpdateHumanPhone(ctx, &management2.UpdateHumanPhoneRequest{ UserId: d.Id(), - Phone: d.Get(phoneVar).(string), - IsPhoneVerified: d.Get(isPhoneVerifiedVar).(bool), + Phone: phone.(string), + IsPhoneVerified: phoneVerified.(bool), }) if err != nil { return diag.Errorf("failed to update human phone: %v", err) } } - return nil } diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant.go index ee3a3b15..3c08d553 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant.go @@ -18,6 +18,7 @@ const ( func GetUserGrant() *schema.Resource { return &schema.Resource{ + Description: "Resource representing the authorization given to a user directly, including the given roles.", Schema: map[string]*schema.Schema{ userGrantProjectIDVar: { Type: schema.TypeString, From 22f85f38506ee42424e96587ccbd0883daa13246 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 29 Jul 2022 16:46:58 +0200 Subject: [PATCH 007/260] fix: add idps, machine keys, pats and trigger actions --- docs/resources/login_policy.md | 12 +- docs/resources/machine_key.md | 38 +++ docs/resources/org_jwt_idp.md | 45 +++ docs/resources/org_oidc_idp.md | 47 +++ docs/resources/personal_access_token.md | 36 +++ docs/resources/trigger_actions.md | 37 +++ examples/provider/login_policy.tf | 10 +- examples/provider/machine_key.tf | 8 + examples/provider/org_jwt_idp.tf | 12 + examples/provider/org_oidc_idp.tf | 14 + examples/provider/personal_access_token.tf | 7 + examples/provider/trigger_actions.tf | 8 + templates/resources/machine_key.md.tmpl | 16 + templates/resources/org_jwt_idp.md.tmpl | 16 + templates/resources/org_oidc_idp.md.tmpl | 16 + .../resources/personal_access_token.md.tmpl | 16 + templates/resources/trigger_actions.md.tmpl | 16 + zitadel/provider.go | 5 + zitadel/v1/project.go | 7 - zitadel/v2/helper.go | 54 ++++ zitadel/v2/idp_jwt.go | 202 +++++++++++++ zitadel/v2/idp_oidc.go | 273 ++++++++++++++++++ zitadel/v2/login_policy.go | 114 ++++++++ zitadel/v2/machine_key.go | 150 ++++++++++ zitadel/v2/org.go | 2 +- zitadel/v2/pat.go | 143 +++++++++ zitadel/v2/trigger_actions.go | 149 ++++++++++ 27 files changed, 1438 insertions(+), 15 deletions(-) create mode 100644 docs/resources/machine_key.md create mode 100644 docs/resources/org_jwt_idp.md create mode 100644 docs/resources/org_oidc_idp.md create mode 100644 docs/resources/personal_access_token.md create mode 100644 docs/resources/trigger_actions.md create mode 100644 examples/provider/machine_key.tf create mode 100644 examples/provider/org_jwt_idp.tf create mode 100644 examples/provider/org_oidc_idp.tf create mode 100644 examples/provider/personal_access_token.tf create mode 100644 examples/provider/trigger_actions.tf create mode 100644 templates/resources/machine_key.md.tmpl create mode 100644 templates/resources/org_jwt_idp.md.tmpl create mode 100644 templates/resources/org_oidc_idp.md.tmpl create mode 100644 templates/resources/personal_access_token.md.tmpl create mode 100644 templates/resources/trigger_actions.md.tmpl create mode 100644 zitadel/v2/helper.go create mode 100644 zitadel/v2/idp_jwt.go create mode 100644 zitadel/v2/idp_oidc.go create mode 100644 zitadel/v2/machine_key.go create mode 100644 zitadel/v2/pat.go create mode 100644 zitadel/v2/trigger_actions.go diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 9caf3afd..65cafe14 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -13,7 +13,7 @@ Resource representing the custom login policy of an organization. ```terraform resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org] + depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] org_id = zitadel_org.org.id user_login = "true" @@ -25,10 +25,13 @@ resource zitadel_login_policy login_policy { password_check_lifetime = "240h" external_login_check_lifetime = "240h" multi_factor_check_lifetime = "720h" - mfa_init_skip_lifetime = "24h" - second_factor_check_lifetime = "24h" + mfa_init_skip_lifetime = "24h" + second_factor_check_lifetime = "24h" ignore_unknown_usernames = "true" default_redirect_uri = "localhost:8080" + second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] + multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] + idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] } ``` @@ -43,13 +46,16 @@ resource zitadel_login_policy login_policy { - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen +- `idps` (Set of String) allowed idps to login or register - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) - `multi_factor_check_lifetime` (String) +- `multi_factors` (Set of String) allowed multi factors - `org_id` (String) Id for the organization - `password_check_lifetime` (String) - `passwordless_type` (String) defines if passwordless is allowed for users - `second_factor_check_lifetime` (String) +- `second_factors` (Set of String) allowed second factors - `user_login` (Boolean) defines if a user is allowed to login with his username and password ### Read-Only diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md new file mode 100644 index 00000000..c658ff2a --- /dev/null +++ b/docs/resources/machine_key.md @@ -0,0 +1,38 @@ +--- +page_title: "zitadel_machine_key Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a machine key +--- + +# zitadel_machine_key (Resource) + +Resource representing a machine key + +## Example Usage + +```terraform +resource zitadel_machine_key machine_key { + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_machine_user.machine_user.id + key_type = "KEY_TYPE_JSON" + expiration_date = "2519-04-01T08:45:00.000000Z" +} +``` + + +## Schema + +### Required + +- `expiration_date` (String) Expiration date of the machine key +- `key_type` (String) Type of the machine key +- `org_id` (String) ID of the organization +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. +- `key_details` (String, Sensitive) Value of the machine key \ No newline at end of file diff --git a/docs/resources/org_jwt_idp.md b/docs/resources/org_jwt_idp.md new file mode 100644 index 00000000..5b9e2fe6 --- /dev/null +++ b/docs/resources/org_jwt_idp.md @@ -0,0 +1,45 @@ +--- +page_title: "zitadel_org_jwt_idp Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a domain of the organization. +--- + +# zitadel_org_jwt_idp (Resource) + +Resource representing a domain of the organization. + +## Example Usage + +```terraform +resource zitadel_org_jwt_idp jwt_idp { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + name = "jwtidp" + styling_type = "STYLING_TYPE_UNSPECIFIED" + jwt_endpoint = "https://jwtendpoint.com" + issuer = "https://google.com" + keys_endpoint = "https://jwtendpoint.com/keys" + header_name = "x-auth-token" + auto_register = false +} +``` + + +## Schema + +### Required + +- `auto_register` (Boolean) auto register for users from this idp +- `header_name` (String) the name of the header where the JWT is sent in, default is authorization +- `issuer` (String) the issuer of the jwt (for validation) +- `jwt_endpoint` (String) the endpoint where the jwt can be extracted +- `keys_endpoint` (String) the endpoint to the key (JWK) which are used to sign the JWT with +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `styling_type` (String) Some identity providers specify the styling of the button to their login + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/org_oidc_idp.md b/docs/resources/org_oidc_idp.md new file mode 100644 index 00000000..7f58d6cb --- /dev/null +++ b/docs/resources/org_oidc_idp.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_org_oidc_idp Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a OIDC IDP of the organization. +--- + +# zitadel_org_oidc_idp (Resource) + +Resource representing a OIDC IDP of the organization. + +## Example Usage + +```terraform +resource zitadel_org_jwt_idp jwt_idp { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + name = "jwtidp" + styling_type = "STYLING_TYPE_UNSPECIFIED" + jwt_endpoint = "https://jwtendpoint.com" + issuer = "https://google.com" + keys_endpoint = "https://jwtendpoint.com/keys" + header_name = "x-auth-token" + auto_register = false +} +``` + + +## Schema + +### Required + +- `auto_register` (Boolean) auto register for users from this idp +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String) client secret generated by the identity provider +- `display_name_mapping` (String) definition which field is mapped to the display name of the user +- `issuer` (String) the oidc issuer of the identity provider +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `styling_type` (String) Some identity providers specify the styling of the button to their login +- `username_mapping` (String) definition which field is mapped to the email of the user + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md new file mode 100644 index 00000000..b8cb42f4 --- /dev/null +++ b/docs/resources/personal_access_token.md @@ -0,0 +1,36 @@ +--- +page_title: "zitadel_personal_access_token Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a personal access token of a user +--- + +# zitadel_personal_access_token (Resource) + +Resource representing a personal access token of a user + +## Example Usage + +```terraform +resource zitadel_personal_access_token pat { + depends_on = [zitadel_human_user.human_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_human_user.human_user.id + expiration_date = "2519-04-01T08:45:00.000000Z" +} +``` + + +## Schema + +### Required + +- `expiration_date` (String) Expiration date of the token +- `org_id` (String) ID of the organization +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. +- `token` (String, Sensitive) Value of the token \ No newline at end of file diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md new file mode 100644 index 00000000..ffed563f --- /dev/null +++ b/docs/resources/trigger_actions.md @@ -0,0 +1,37 @@ +--- +page_title: "zitadel_trigger_actions Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing triggers, when actions get started +--- + +# zitadel_trigger_actions (Resource) + +Resource representing triggers, when actions get started + +## Example Usage + +```terraform +resource zitadel_trigger_actions trigger_actions { + depends_on = [zitadel_action.action, zitadel_org.org] + + org_id = zitadel_org.org.id + flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" + trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" + action_ids = [zitadel_action.action.id] +} +``` + + +## Schema + +### Required + +- `action_ids` (Set of String) IDs of the triggered actions +- `flow_type` (String) Type of the flow to which the action triggers belong +- `org_id` (String) ID of the organization +- `trigger_type` (String) Trigger type on when the actions get triggered + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/login_policy.tf b/examples/provider/login_policy.tf index 98fbfb6b..bbc233bf 100644 --- a/examples/provider/login_policy.tf +++ b/examples/provider/login_policy.tf @@ -1,6 +1,5 @@ - resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org] + depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] org_id = zitadel_org.org.id user_login = "true" @@ -12,8 +11,11 @@ resource zitadel_login_policy login_policy { password_check_lifetime = "240h" external_login_check_lifetime = "240h" multi_factor_check_lifetime = "720h" - mfa_init_skip_lifetime = "24h" - second_factor_check_lifetime = "24h" + mfa_init_skip_lifetime = "24h" + second_factor_check_lifetime = "24h" ignore_unknown_usernames = "true" default_redirect_uri = "localhost:8080" + second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] + multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] + idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] } \ No newline at end of file diff --git a/examples/provider/machine_key.tf b/examples/provider/machine_key.tf new file mode 100644 index 00000000..c941777b --- /dev/null +++ b/examples/provider/machine_key.tf @@ -0,0 +1,8 @@ +resource zitadel_machine_key machine_key { + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_machine_user.machine_user.id + key_type = "KEY_TYPE_JSON" + expiration_date = "2519-04-01T08:45:00.000000Z" +} \ No newline at end of file diff --git a/examples/provider/org_jwt_idp.tf b/examples/provider/org_jwt_idp.tf new file mode 100644 index 00000000..52ee4edc --- /dev/null +++ b/examples/provider/org_jwt_idp.tf @@ -0,0 +1,12 @@ +resource zitadel_org_jwt_idp jwt_idp { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + name = "jwtidp" + styling_type = "STYLING_TYPE_UNSPECIFIED" + jwt_endpoint = "https://jwtendpoint.com" + issuer = "https://google.com" + keys_endpoint = "https://jwtendpoint.com/keys" + header_name = "x-auth-token" + auto_register = false +} \ No newline at end of file diff --git a/examples/provider/org_oidc_idp.tf b/examples/provider/org_oidc_idp.tf new file mode 100644 index 00000000..cd05c612 --- /dev/null +++ b/examples/provider/org_oidc_idp.tf @@ -0,0 +1,14 @@ +resource zitadel_org_oidc_idp oidc_idp { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + name = "oidcidp" + styling_type = "STYLING_TYPE_UNSPECIFIED" + client_id = "google" + client_secret = "google_secret" + issuer = "https://google.com" + scopes = ["openid", "profile", "email"] + display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + auto_register = false +} \ No newline at end of file diff --git a/examples/provider/personal_access_token.tf b/examples/provider/personal_access_token.tf new file mode 100644 index 00000000..0d14855e --- /dev/null +++ b/examples/provider/personal_access_token.tf @@ -0,0 +1,7 @@ +resource zitadel_personal_access_token pat { + depends_on = [zitadel_human_user.human_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_human_user.human_user.id + expiration_date = "2519-04-01T08:45:00.000000Z" +} \ No newline at end of file diff --git a/examples/provider/trigger_actions.tf b/examples/provider/trigger_actions.tf new file mode 100644 index 00000000..f910005d --- /dev/null +++ b/examples/provider/trigger_actions.tf @@ -0,0 +1,8 @@ +resource zitadel_trigger_actions trigger_actions { + depends_on = [zitadel_action.action, zitadel_org.org] + + org_id = zitadel_org.org.id + flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" + trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" + action_ids = [zitadel_action.action.id] +} \ No newline at end of file diff --git a/templates/resources/machine_key.md.tmpl b/templates/resources/machine_key.md.tmpl new file mode 100644 index 00000000..90174f04 --- /dev/null +++ b/templates/resources/machine_key.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/machine_key.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_jwt_idp.md.tmpl b/templates/resources/org_jwt_idp.md.tmpl new file mode 100644 index 00000000..6946a79f --- /dev/null +++ b/templates/resources/org_jwt_idp.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/org_jwt_idp.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_oidc_idp.md.tmpl b/templates/resources/org_oidc_idp.md.tmpl new file mode 100644 index 00000000..6946a79f --- /dev/null +++ b/templates/resources/org_oidc_idp.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/org_jwt_idp.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/personal_access_token.md.tmpl b/templates/resources/personal_access_token.md.tmpl new file mode 100644 index 00000000..b73bd3b0 --- /dev/null +++ b/templates/resources/personal_access_token.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/personal_access_token.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/trigger_actions.md.tmpl b/templates/resources/trigger_actions.md.tmpl new file mode 100644 index 00000000..61f6253f --- /dev/null +++ b/templates/resources/trigger_actions.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/trigger_actions.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index b0f08801..62b298b9 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -60,6 +60,11 @@ func Provider() *schema.Provider { "zitadel_login_policy": v2.GetLoginPolicy(), "zitadel_password_complexity_policy": v2.GetPasswordComplexityPolicy(), "zitadel_privacy_policy": v2.GetPrivacyPolicy(), + "zitadel_trigger_actions": v2.GetTriggerActions(), + "zitadel_personal_access_token": v2.GetPAT(), + "zitadel_machine_key": v2.GetMachineKey(), + "zitadel_org_jwt_idp": v2.GetOrgJWTIDP(), + "zitadel_org_oidc_idp": v2.GetOrgOIDCIDP(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v1/project.go b/zitadel/v1/project.go index 921a049f..90526287 100644 --- a/zitadel/v1/project.go +++ b/zitadel/v1/project.go @@ -10,7 +10,6 @@ import ( ) const ( - projectIdVar = "id" projectNameVar = "name" projectState = "state" projectResourceOwner = "resource_owner" @@ -23,11 +22,6 @@ const ( func GetProjectDatasource() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ - projectIdVar: { - Type: schema.TypeString, - Computed: true, - Description: "ID of the project", - }, projectNameVar: { Type: schema.TypeString, Computed: true, @@ -108,7 +102,6 @@ func readProject(ctx context.Context, d *schema.ResourceData, m interface{}, inf project := resp.GetProject() set := map[string]interface{}{ - projectIdVar: project.GetId(), projectResourceOwner: project.GetDetails().GetResourceOwner(), projectState: project.GetState().Number(), projectNameVar: project.GetName(), diff --git a/zitadel/v2/helper.go b/zitadel/v2/helper.go new file mode 100644 index 00000000..b8630336 --- /dev/null +++ b/zitadel/v2/helper.go @@ -0,0 +1,54 @@ +package v2 + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +type stringified struct { + str string +} + +func (s *stringified) String() string { + return s.str +} + +type stringify interface { + String() string +} + +func setToStringSlice(set *schema.Set) []string { + slice := make([]string, 0) + for _, secondFactor := range set.List() { + slice = append(slice, secondFactor.(string)) + } + return slice +} + +func getAddAndDelete(current []stringify, desired []string) ([]string, []string) { + addSlice := make([]string, 0) + deleteSlice := make([]string, 0) + + for _, desiredItem := range desired { + found := false + for _, currentItem := range current { + if desiredItem == currentItem.String() { + found = true + } + } + if !found { + addSlice = append(addSlice, desiredItem) + } + } + + for _, currentItem := range current { + found := false + for _, desiredItem := range desired { + if desiredItem == currentItem.String() { + found = true + } + } + if !found { + deleteSlice = append(deleteSlice, currentItem.String()) + } + } + + return addSlice, deleteSlice +} diff --git a/zitadel/v2/idp_jwt.go b/zitadel/v2/idp_jwt.go new file mode 100644 index 00000000..f62fcc7c --- /dev/null +++ b/zitadel/v2/idp_jwt.go @@ -0,0 +1,202 @@ +package v2 + +import ( + "context" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +const ( + idpJwtEndpoint = "jwt_endpoint" + idpKeysEndpoint = "keys_endpoint" + idpHeaderName = "header_name" +) + +func GetOrgJWTIDP() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a domain of the organization.", + Schema: map[string]*schema.Schema{ + idpOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idpNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idpStylingTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Some identity providers specify the styling of the button to their login", + }, + idpJwtEndpoint: { + Type: schema.TypeString, + Required: true, + Description: "the endpoint where the jwt can be extracted", + }, + idpKeysEndpoint: { + Type: schema.TypeString, + Required: true, + Description: "the endpoint to the key (JWK) which are used to sign the JWT with", + }, + idpIssuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the issuer of the jwt (for validation)", + }, + idpHeaderName: { + Type: schema.TypeString, + Required: true, + Description: "the name of the header where the JWT is sent in, default is authorization", + }, + idpAutoRegister: { + Type: schema.TypeBool, + Required: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: readOrgJWTIDP, + CreateContext: createOrgJWTIDP, + UpdateContext: updateOrgJWTIDP, + DeleteContext: deleteOrgIDP, + } +} +func createOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(domainOrgIdVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + stylingType := d.Get(idpStylingTypeVar) + resp, err := client.AddOrgJWTIDP(ctx, &management2.AddOrgJWTIDPRequest{ + Name: d.Get(idpNameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + JwtEndpoint: d.Get(idpJwtEndpoint).(string), + Issuer: d.Get(idpIssuerVar).(string), + KeysEndpoint: d.Get(idpKeysEndpoint).(string), + HeaderName: d.Get(idpHeaderName).(string), + AutoRegister: d.Get(idpAutoRegister).(bool), + }) + if err != nil { + return diag.Errorf("failed to create jwt idp: %v", err) + } + d.SetId(resp.IdpId) + return nil +} + +func updateOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Get("id").(string)}) + if err != nil { + return diag.Errorf("failed to read jwt idp: %v", err) + } + + idpID := d.Id() + name := d.Get(idpNameVar).(string) + stylingType := d.Get(idpStylingTypeVar).(string) + autoRegister := d.Get(idpAutoRegister).(bool) + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + _, err := client.UpdateOrgIDP(ctx, &management2.UpdateOrgIDPRequest{ + IdpId: idpID, + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp: %v", err) + } + } + + jwt := resp.GetIdp().GetJwtConfig() + jwtEndpoint := d.Get(idpJwtEndpoint).(string) + issuer := d.Get(idpIssuerVar).(string) + keysEndpoint := d.Get(idpKeysEndpoint).(string) + headerName := d.Get(idpHeaderName).(string) + + //either nothing changed on the IDP or something besides the secret changed + if jwt.GetJwtEndpoint() != jwtEndpoint || + jwt.GetIssuer() != issuer || + jwt.GetKeysEndpoint() != keysEndpoint || + jwt.GetHeaderName() != headerName { + + _, err = client.UpdateOrgIDPJWTConfig(ctx, &management2.UpdateOrgIDPJWTConfigRequest{ + IdpId: idpID, + JwtEndpoint: jwtEndpoint, + Issuer: issuer, + KeysEndpoint: keysEndpoint, + HeaderName: headerName, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp config: %v", err) + } + } + return nil +} + +func readOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read jwt idp: %v", err) + } + + idp := resp.GetIdp() + jwt := idp.GetJwtConfig() + set := map[string]interface{}{ + idpOrgIDVar: idp.GetDetails().ResourceOwner, + idpNameVar: idp.GetName(), + idpStylingTypeVar: idp.GetStylingType().String(), + idpJwtEndpoint: jwt.GetJwtEndpoint(), + idpIssuerVar: jwt.GetIssuer(), + idpKeysEndpoint: jwt.GetKeysEndpoint(), + idpHeaderName: jwt.GetHeaderName(), + idpAutoRegister: idp.GetAutoRegister(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of jwt idp: %v", k, err) + } + } + d.SetId(idp.Id) + + return nil +} diff --git a/zitadel/v2/idp_oidc.go b/zitadel/v2/idp_oidc.go new file mode 100644 index 00000000..9345ca79 --- /dev/null +++ b/zitadel/v2/idp_oidc.go @@ -0,0 +1,273 @@ +package v2 + +import ( + "context" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "reflect" +) + +const ( + idpOrgIDVar = "org_id" + idpNameVar = "name" + idpStylingTypeVar = "styling_type" + idpClientIDVar = "client_id" + idpClientSecretVar = "client_secret" + idpIssuerVar = "issuer" + idpScopesVar = "scopes" + idpDisplayNameMapping = "display_name_mapping" + idpUsernameMapping = "username_mapping" + idpAutoRegister = "auto_register" +) + +func GetOrgOIDCIDP() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP of the organization.", + Schema: map[string]*schema.Schema{ + idpOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idpNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idpStylingTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Some identity providers specify the styling of the button to their login", + }, + idpClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idpClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + }, + idpIssuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the oidc issuer of the identity provider", + }, + idpScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idpDisplayNameMapping: { + Type: schema.TypeString, + Required: true, + Description: "definition which field is mapped to the display name of the user", + }, + idpUsernameMapping: { + Type: schema.TypeString, + Required: true, + Description: "definition which field is mapped to the email of the user", + }, + idpAutoRegister: { + Type: schema.TypeBool, + Required: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: readOrgOIDCIDP, + UpdateContext: updateOrgOIDCIDP, + CreateContext: createOrgOIDCIDP, + DeleteContext: deleteOrgIDP, + } +} + +func deleteOrgIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrgIDP(ctx, &management2.RemoveOrgIDPRequest{ + IdpId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete oidc idp: %v", err) + } + return nil +} + +func createOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + scopes := make([]string, 0) + scopesSet := d.Get(idpScopesVar).(*schema.Set) + for _, scope := range scopesSet.List() { + scopes = append(scopes, scope.(string)) + } + + stylingType := d.Get(idpStylingTypeVar) + displayNameMapping := d.Get(idpDisplayNameMapping).(string) + usernameMapping := d.Get(idpUsernameMapping).(string) + resp, err := client.AddOrgOIDCIDP(ctx, &management2.AddOrgOIDCIDPRequest{ + Name: d.Get(idpNameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + ClientId: d.Get(idpClientIDVar).(string), + ClientSecret: d.Get(idpClientSecretVar).(string), + Issuer: d.Get(idpIssuerVar).(string), + Scopes: scopes, + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + AutoRegister: d.Get(idpAutoRegister).(bool), + }) + if err != nil { + return diag.Errorf("failed to create oidc idp: %v", err) + } + d.SetId(resp.GetIdpId()) + + return nil +} + +func updateOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) + if err != nil { + return diag.Errorf("failed to read oidc idp: %v", err) + } + + idpID := d.Id() + name := d.Get(idpNameVar).(string) + stylingType := d.Get(idpStylingTypeVar).(string) + autoRegister := d.Get(idpAutoRegister).(bool) + changed := false + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + changed = true + _, err := client.UpdateOrgIDP(ctx, &management2.UpdateOrgIDPRequest{ + IdpId: idpID, + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update oidc idp: %v", err) + } + } + + oidc := resp.GetIdp().GetOidcConfig() + clientID := d.Get(idpClientIDVar).(string) + clientSecret := d.Get(idpClientSecretVar).(string) + issuer := d.Get(idpIssuerVar).(string) + scopesSet := d.Get(idpScopesVar).(*schema.Set) + displayNameMapping := d.Get(idpDisplayNameMapping).(string) + usernameMapping := d.Get(idpUsernameMapping).(string) + + scopes := make([]string, 0) + for _, scope := range scopesSet.List() { + scopes = append(scopes, scope.(string)) + } + + //either nothing changed on the IDP or something besides the secret changed + if (oidc.GetClientId() != clientID || + oidc.GetIssuer() != issuer || + !reflect.DeepEqual(oidc.GetScopes(), scopes) || + oidc.GetDisplayNameMapping().String() != displayNameMapping || + oidc.GetUsernameMapping().String() != usernameMapping) || + !changed { + + _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management2.UpdateOrgIDPOIDCConfigRequest{ + IdpId: idpID, + ClientId: clientID, + ClientSecret: clientSecret, + Issuer: issuer, + Scopes: scopes, + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + }) + if err != nil { + return diag.Errorf("failed to update oidc idp config: %v", err) + } + } + d.SetId(idpID) + return nil +} + +func readOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read oidc idp: %v", err) + } + + idp := resp.GetIdp() + oidc := idp.GetOidcConfig() + set := map[string]interface{}{ + idpOrgIDVar: idp.GetDetails().GetResourceOwner(), + idpNameVar: idp.GetName(), + idpStylingTypeVar: idp.GetStylingType().String(), + idpClientIDVar: oidc.GetClientId(), + idpClientSecretVar: d.Get(idpClientSecretVar).(string), + idpIssuerVar: oidc.GetIssuer(), + idpScopesVar: oidc.GetScopes(), + idpDisplayNameMapping: oidc.GetDisplayNameMapping().String(), + idpUsernameMapping: oidc.GetUsernameMapping().String(), + idpAutoRegister: idp.GetAutoRegister(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + + return nil +} diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go index 5ee252e8..0c91e416 100644 --- a/zitadel/v2/login_policy.go +++ b/zitadel/v2/login_policy.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" "google.golang.org/protobuf/types/known/durationpb" @@ -27,6 +28,9 @@ const ( loginPolicyMultiFactorCheckLifetime = "multi_factor_check_lifetime" loginPolicyIgnoreUnknownUsernames = "ignore_unknown_usernames" loginPolicyDefaultRedirectURI = "default_redirect_uri" + loginPolicySecondFactorsVar = "second_factors" + loginPolicyMultiFactorsVar = "multi_factors" + loginPolicyIDPsVar = "idps" ) func GetLoginPolicy() *schema.Resource { @@ -109,6 +113,30 @@ func GetLoginPolicy() *schema.Resource { Required: true, Description: "", }, + loginPolicySecondFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed second factors", + }, + loginPolicyMultiFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed multi factors", + }, + loginPolicyIDPsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed idps to login or register", + }, }, CreateContext: createLoginPolicy, UpdateContext: updateLoginPolicy, @@ -153,6 +181,11 @@ func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ return diag.FromErr(err) } + current, err := client.GetLoginPolicy(ctx, &management2.GetLoginPolicyRequest{}) + if err != nil { + return diag.FromErr(err) + } + passwordCheckLT, err := time.ParseDuration(d.Get(loginPolicyPasswordCheckLifetime).(string)) if err != nil { return diag.FromErr(err) @@ -169,6 +202,7 @@ func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ if err != nil { return diag.FromErr(err) } + multiFactorCheckLT, err := time.ParseDuration(d.Get(loginPolicyMultiFactorCheckLifetime).(string)) if err != nil { return diag.FromErr(err) @@ -193,6 +227,74 @@ func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ return diag.Errorf("failed to update login policy: %v", err) } d.SetId(org) + + secondFactors := setToStringSlice(d.Get(loginPolicySecondFactorsVar).(*schema.Set)) + currentSecondFactors := make([]stringify, 0) + for _, secondFactor := range current.GetPolicy().GetSecondFactors() { + currentSecondFactors = append(currentSecondFactors, secondFactor) + } + addSecondFactor, deleteSecondFactors := getAddAndDelete(currentSecondFactors, secondFactors) + + for _, factor := range addSecondFactor { + if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management2.AddSecondFactorToLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteSecondFactors { + if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &management2.RemoveSecondFactorFromLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + multiFactors := setToStringSlice(d.Get(loginPolicyMultiFactorsVar).(*schema.Set)) + currentMultiFactors := make([]stringify, 0) + for _, multiFactor := range current.GetPolicy().GetMultiFactors() { + currentMultiFactors = append(currentMultiFactors, multiFactor) + } + addMultiFactor, deleteMultiFactors := getAddAndDelete(currentMultiFactors, multiFactors) + for _, factor := range addMultiFactor { + if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management2.AddMultiFactorToLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteMultiFactors { + if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &management2.RemoveMultiFactorFromLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + idps := setToStringSlice(d.Get(loginPolicyIDPsVar).(*schema.Set)) + currentIdps := make([]stringify, 0) + for _, currentIdp := range current.GetPolicy().GetIdps() { + currentIdps = append(currentIdps, &stringified{currentIdp.IdpId}) + } + addIdps, deleteIdps := getAddAndDelete(currentIdps, idps) + for _, addIdp := range addIdps { + var ownertype idp.IDPOwnerType + _, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: addIdp}) + if err != nil { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM + } else { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + } + if _, err := client.AddIDPToLoginPolicy(ctx, &management2.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + return diag.FromErr(err) + } + } + for _, deleteIdp := range deleteIdps { + if _, err := client.RemoveIDPFromLoginPolicy(ctx, &management2.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { + return diag.FromErr(err) + } + } + return nil } @@ -230,6 +332,16 @@ func createLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ if err != nil { return diag.FromErr(err) } + secondFactors := make([]policy.SecondFactorType, 0) + secondFactorsSet := d.Get(loginPolicySecondFactorsVar).(*schema.Set) + for _, factor := range secondFactorsSet.List() { + secondFactors = append(secondFactors, policy.SecondFactorType(policy.SecondFactorType_value[factor.(string)])) + } + multiFactors := make([]policy.MultiFactorType, 0) + multiFactorsSet := d.Get(loginPolicyMultiFactorsVar).(*schema.Set) + for _, factor := range multiFactorsSet.List() { + multiFactors = append(multiFactors, policy.MultiFactorType(policy.MultiFactorType_value[factor.(string)])) + } _, err = client.AddCustomLoginPolicy(ctx, &management2.AddCustomLoginPolicyRequest{ AllowUsernamePassword: d.Get(loginPolicyAllowUsernamePassword).(bool), @@ -245,6 +357,8 @@ func createLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + SecondFactors: secondFactors, + MultiFactors: multiFactors, }) if err != nil { return diag.Errorf("failed to create login policy: %v", err) diff --git a/zitadel/v2/machine_key.go b/zitadel/v2/machine_key.go new file mode 100644 index 00000000..cf31523f --- /dev/null +++ b/zitadel/v2/machine_key.go @@ -0,0 +1,150 @@ +package v2 + +import ( + "context" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" + "time" +) + +const ( + machineKeyOrgIDVar = "org_id" + machineKeyUserIDVar = "user_id" + machineKeyKeyTypeVar = "key_type" + machineKeyKeyDetailsVar = "key_details" + machineKeyExpirationDateVar = "expiration_date" +) + +func GetMachineKey() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a machine key", + Schema: map[string]*schema.Schema{ + machineKeyOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + machineKeyUserIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + machineKeyKeyTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the machine key", + ForceNew: true, + }, + machineKeyExpirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the machine key", + ForceNew: true, + }, + machineKeyKeyDetailsVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the machine key", + Sensitive: true, + }, + }, + DeleteContext: deleteMachineKey, + CreateContext: createMachineKey, + ReadContext: readMachineKey, + } +} + +func deleteMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(machineKeyOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveMachineKey(ctx, &management2.RemoveMachineKeyRequest{ + UserId: d.Get(machineKeyUserIDVar).(string), + KeyId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete machine key: %v", err) + } + return nil +} + +func createMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(machineKeyOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(timeFormat, d.Get(machineKeyExpirationDateVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + keyType := d.Get(machineKeyKeyTypeVar).(string) + resp, err := client.AddMachineKey(ctx, &management2.AddMachineKeyRequest{ + UserId: d.Get(machineKeyUserIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), + ExpirationDate: timestamppb.New(t), + }) + d.SetId(resp.GetKeyId()) + + if err := d.Set(machineKeyKeyDetailsVar, string(resp.GetKeyDetails())); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func readMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(machineKeyOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(machineKeyUserIDVar).(string) + resp, err := client.GetMachineKeyByIDs(ctx, &management2.GetMachineKeyByIDsRequest{ + UserId: userID, + KeyId: d.Id(), + }) + d.SetId(resp.GetKey().GetId()) + set := map[string]interface{}{ + machineKeyExpirationDateVar: resp.GetKey().GetExpirationDate().String(), + machineKeyUserIDVar: userID, + machineKeyOrgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of machine key: %v", k, err) + } + } + return nil +} diff --git a/zitadel/v2/org.go b/zitadel/v2/org.go index c65a3e8b..e3fbb1db 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org.go @@ -105,7 +105,7 @@ func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di d.SetId(org.GetId()) tflog.Debug(ctx, "found org", map[string]interface{}{ - "id": d.Get("id"), + "id": d.Id(), "org": name, }) return nil diff --git a/zitadel/v2/pat.go b/zitadel/v2/pat.go new file mode 100644 index 00000000..53c51186 --- /dev/null +++ b/zitadel/v2/pat.go @@ -0,0 +1,143 @@ +package v2 + +import ( + "context" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" + "time" +) + +const ( + patOrgIDVar = "org_id" + patUserIDVar = "user_id" + patTokenVar = "token" + patExpirationDateVar = "expiration_date" + timeFormat = "2519-04-01T08:45:00.000000Z" +) + +func GetPAT() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a personal access token of a user", + Schema: map[string]*schema.Schema{ + patOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + patUserIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + patTokenVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the token", + Sensitive: true, + }, + patExpirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the token", + ForceNew: true, + }, + }, + DeleteContext: deletePAT, + CreateContext: createPAT, + ReadContext: readPAT, + } +} + +func deletePAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(patOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemovePersonalAccessToken(ctx, &management2.RemovePersonalAccessTokenRequest{ + UserId: d.Get(patUserIDVar).(string), + TokenId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete PAT: %v", err) + } + return nil +} + +func createPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(patOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(timeFormat, d.Get(patExpirationDateVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.AddPersonalAccessToken(ctx, &management2.AddPersonalAccessTokenRequest{ + UserId: d.Get(patUserIDVar).(string), + ExpirationDate: timestamppb.New(t), + }) + d.SetId(resp.GetTokenId()) + if err := d.Set(patTokenVar, resp.GetToken()); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func readPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(patOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(patUserIDVar).(string) + resp, err := client.GetPersonalAccessTokenByIDs(ctx, &management2.GetPersonalAccessTokenByIDsRequest{ + UserId: userID, + TokenId: d.Id(), + }) + d.SetId(resp.GetToken().GetId()) + set := map[string]interface{}{ + patExpirationDateVar: resp.GetToken().GetExpirationDate().String(), + patUserIDVar: userID, + patOrgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of project: %v", k, err) + } + } + if err := d.Set(patTokenVar, resp.GetToken()); err != nil { + return diag.FromErr(err) + } + return nil +} diff --git a/zitadel/v2/trigger_actions.go b/zitadel/v2/trigger_actions.go new file mode 100644 index 00000000..17e16cdb --- /dev/null +++ b/zitadel/v2/trigger_actions.go @@ -0,0 +1,149 @@ +package v2 + +import ( + "context" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +const ( + triggerActionsOrgIDVar = "org_id" + triggerActionsFlowTypeVar = "flow_type" + triggerActionsTriggerTypeVar = "trigger_type" + triggerActionsActionsVar = "action_ids" +) + +func GetTriggerActions() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing triggers, when actions get started", + Schema: map[string]*schema.Schema{ + triggerActionsOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + triggerActionsFlowTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the flow to which the action triggers belong", + ForceNew: true, + }, + triggerActionsTriggerTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Trigger type on when the actions get triggered", + ForceNew: true, + }, + triggerActionsActionsVar: { + Type: schema.TypeSet, + Elem: schema.TypeString, + Required: true, + Description: "IDs of the triggered actions", + }, + }, + DeleteContext: deleteTriggerActions, + CreateContext: createTriggerActions, + UpdateContext: updateTriggerActions, + ReadContext: readTriggerActions, + } +} + +func deleteTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(triggerActionsOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[d.Get(triggerActionsFlowTypeVar).(string)]), + TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerActionsTriggerTypeVar).(string)]), + ActionIds: []string{}, + }) + if err != nil { + return diag.Errorf("failed to delete trigger actions: %v", err) + } + return nil +} + +func updateTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(triggerActionsOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + actionsSet := d.Get(triggerActionsActionsVar).(*schema.Set) + actions := make([]string, 0) + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[d.Get(triggerActionsFlowTypeVar).(string)]), + TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerActionsTriggerTypeVar).(string)]), + ActionIds: actions, + }) + if err != nil { + return diag.Errorf("failed to update trigger actions: %v", err) + } + + return nil +} + +func createTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(triggerActionsOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + actionsSet := d.Get(triggerActionsActionsVar).(*schema.Set) + actions := make([]string, 0) + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + flowType := d.Get(triggerActionsFlowTypeVar).(string) + triggerType := d.Get(triggerActionsTriggerTypeVar).(string) + _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[flowType]), + TriggerType: action.TriggerType(action.TriggerType_value[triggerType]), + ActionIds: actions, + }) + d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) + + return nil +} + +func readTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + d.SetId("") + return nil +} + +func getTriggerActionsID(orgID, flowType string, triggerType string) string { + return orgID + "_" + flowType + "_" + triggerType +} From 75f7f05d25af91eaa45e3ef1cfb2bdd610153867 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 8 Aug 2022 17:19:53 +0200 Subject: [PATCH 008/260] fix: add clientID and client secret to the applications as sensitive, read-only --- docs/resources/application_api.md | 2 ++ docs/resources/application_oidc.md | 2 ++ zitadel/v2/application_api.go | 21 +++++++++++++++++++++ zitadel/v2/application_oidc.go | 24 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 7421c39f..25bf5c78 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -34,4 +34,6 @@ resource zitadel_application_api application_api { ### Read-Only +- `client_id` (String, Sensitive) generated ID for this config +- `client_secret` (String, Sensitive) generated secret for this config - `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 7b194926..b94ec968 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -64,4 +64,6 @@ resource zitadel_application_oidc application_oidc { ### Read-Only +- `client_id` (String, Sensitive) generated ID for this config +- `client_secret` (String, Sensitive) generated secret for this config - `id` (String) The ID of this resource. \ No newline at end of file diff --git a/zitadel/v2/application_api.go b/zitadel/v2/application_api.go index 6bf51887..2e1cf0d8 100644 --- a/zitadel/v2/application_api.go +++ b/zitadel/v2/application_api.go @@ -37,6 +37,18 @@ func GetApplicationAPI() *schema.Resource { Required: true, Description: "Auth method type", }, + applicationClientID: { + Type: schema.TypeString, + Computed: true, + Description: "generated ID for this config", + Sensitive: true, + }, + applicationClientSecret: { + Type: schema.TypeString, + Computed: true, + Description: "generated secret for this config", + Sensitive: true, + }, }, DeleteContext: deleteApplicationAPI, CreateContext: createApplicationAPI, @@ -131,6 +143,15 @@ func createApplicationAPI(ctx context.Context, d *schema.ResourceData, m interfa AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[(d.Get(applicationAuthMethodTypeVar).(string))]), }) + set := map[string]interface{}{ + applicationClientID: resp.GetClientId(), + applicationClientSecret: resp.GetClientSecret(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationAPI: %v", k, err) + } + } if err != nil { return diag.Errorf("failed to create applicationAPI: %v", err) } diff --git a/zitadel/v2/application_oidc.go b/zitadel/v2/application_oidc.go index b0ddf4ca..6eebdae9 100644 --- a/zitadel/v2/application_oidc.go +++ b/zitadel/v2/application_oidc.go @@ -30,6 +30,8 @@ const ( applicationIdTokenUserinfoAssertionVar = "id_token_userinfo_assertion" applicationClockSkewVar = "clock_skew" applicationAdditionalOriginsVar = "additional_origins" + applicationClientID = "client_id" + applicationClientSecret = "client_secret" ) func GetApplicationOIDC() *schema.Resource { @@ -138,6 +140,18 @@ func GetApplicationOIDC() *schema.Resource { Optional: true, Description: "Additional origins", }, + applicationClientID: { + Type: schema.TypeString, + Computed: true, + Description: "generated ID for this config", + Sensitive: true, + }, + applicationClientSecret: { + Type: schema.TypeString, + Computed: true, + Description: "generated secret for this config", + Sensitive: true, + }, }, DeleteContext: deleteApplicationOIDC, CreateContext: createApplicationOIDC, @@ -304,6 +318,16 @@ func createApplicationOIDC(ctx context.Context, d *schema.ResourceData, m interf AdditionalOrigins: interfaceToStringSlice(d.Get(applicationAdditionalOriginsVar)), }) + set := map[string]interface{}{ + applicationClientID: resp.GetClientId(), + applicationClientSecret: resp.GetClientSecret(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationOIDC: %v", k, err) + } + } + if err != nil { return diag.Errorf("failed to create applicationOIDC: %v", err) } From af2e97be1970bf9c05c0dd2e0414ceee00498668 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 10 Aug 2022 19:14:49 +0200 Subject: [PATCH 009/260] fix: several corrections for policies, formatting and handling of new resources --- docs/index.md | 16 +- docs/resources/domain_policy.md | 3 +- docs/resources/label_policy.md | 6 +- docs/resources/lockout_policy.md | 3 +- docs/resources/login_policy.md | 13 +- docs/resources/machine_key.md | 2 +- docs/resources/password_complexity_policy.md | 3 +- docs/resources/personal_access_token.md | 6 +- docs/resources/privacy_policy.md | 3 +- docs/resources/user_grant.md | 4 +- examples/migration/main.tf | 98 +++++++ examples/provider/human_user.tf | 1 - examples/provider/label_policy.tf | 2 +- examples/provider/login_policy.tf | 10 +- examples/provider/machine_key.tf | 2 +- examples/provider/personal_access_token.tf | 6 +- examples/provider/user_grant.tf | 4 +- go.mod | 22 +- go.sum | 248 +++++++++++++++- templates/index.md.tmpl | 13 + zitadel/provider.go | 11 +- zitadel/v1/action.go | 82 ------ zitadel/v1/client.go | 56 ---- zitadel/v1/domain.go | 79 ----- zitadel/v1/iam_policy.go | 58 ---- zitadel/v1/label_policy.go | 156 ---------- zitadel/v1/lockout_policy.go | 58 ---- zitadel/v1/login_policy.go | 107 ------- zitadel/v1/member.go | 58 ---- zitadel/v1/org.go | 294 ------------------- zitadel/v1/password_complexity_policy.go | 86 ------ zitadel/v1/privacy_policy.go | 72 ----- zitadel/v1/project.go | 129 -------- zitadel/v1/user.go | 236 --------------- zitadel/v2/action.go | 38 +-- zitadel/v2/application_api.go | 1 + zitadel/v2/application_oidc.go | 5 +- zitadel/v2/client.go | 9 +- zitadel/v2/domain.go | 1 + zitadel/v2/domain_policy.go | 13 +- zitadel/v2/idp_jwt.go | 4 +- zitadel/v2/idp_oidc.go | 3 +- zitadel/v2/label_policy.go | 42 ++- zitadel/v2/lockout_policy.go | 13 +- zitadel/v2/login_policy.go | 68 +++-- zitadel/v2/machine_key.go | 14 +- zitadel/v2/org.go | 3 +- zitadel/v2/org_member.go | 8 +- zitadel/v2/password_complexity_policy.go | 13 +- zitadel/v2/pat.go | 24 +- zitadel/v2/privacy_policy.go | 13 +- zitadel/v2/project.go | 1 + zitadel/v2/project_grant.go | 1 + zitadel/v2/project_grant_member.go | 6 +- zitadel/v2/project_member.go | 6 +- zitadel/v2/project_role.go | 1 + zitadel/v2/trigger_actions.go | 12 +- zitadel/v2/user.go | 16 +- zitadel/v2/user_grant.go | 73 ++++- 59 files changed, 652 insertions(+), 1683 deletions(-) create mode 100644 examples/migration/main.tf delete mode 100644 zitadel/v1/action.go delete mode 100644 zitadel/v1/client.go delete mode 100644 zitadel/v1/domain.go delete mode 100644 zitadel/v1/iam_policy.go delete mode 100644 zitadel/v1/label_policy.go delete mode 100644 zitadel/v1/lockout_policy.go delete mode 100644 zitadel/v1/login_policy.go delete mode 100644 zitadel/v1/member.go delete mode 100644 zitadel/v1/org.go delete mode 100644 zitadel/v1/password_complexity_policy.go delete mode 100644 zitadel/v1/privacy_policy.go delete mode 100644 zitadel/v1/project.go delete mode 100644 zitadel/v1/user.go diff --git a/docs/index.md b/docs/index.md index 69ba6bbd..88bc1599 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,6 +11,19 @@ This provider allows the management of different resources on a ZITADEL instance Through this provider it is possible to interact with the [ZITADEL API](https://docs.zitadel.com/docs/apis/introduction) to configure different aspects of the instance. +Currently does not contain, but could be included in the future if demand exists: + +- instance as resource +- policies and settings on instance level as resource +- custom text resources + +Not planned to include as resources, as more administration task as a resource: + +- Import and export of organizations +- (re-)setting of password for human user +- initializing of OTP setup for human user +- initializing of passwordless setup for human user + ## Configuring the provider ```terraform @@ -18,7 +31,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.4" + version = "1.0.0-alpha.5" } } } @@ -38,7 +51,6 @@ provider zitadel { ### Required - `domain` (String) Domain used to connect to the ZITADEL instance -- `project` (String) ID of the ZITADEL project on your ZITADEL instance, for the audience-scope - `token` (String) Path to the file containing credentials to connect to ZITADEL ### Optional diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 824c40c1..c2cc389e 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -34,5 +34,4 @@ resource zitadel_domain_policy domain_policy { ### Read-Only -- `id` (String) The ID of this resource. -- `is_default` (Boolean) Is this policy the default \ No newline at end of file +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index 26d2b1bf..a389b65c 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -26,6 +26,7 @@ resource zitadel_label_policy label_policy { warn_color_dark = "#ff3b5b" font_color_dark = "#ffffff" disable_watermark = "false" + set_active = "true" } ``` @@ -46,12 +47,15 @@ resource zitadel_label_policy label_policy { - `warn_color` (String) hex value for warn color - `warn_color_dark` (String) hex value for warn color dark theme +### Optional + +- `set_active` (Boolean) set the label policy active after creating/updating + ### Read-Only - `font_url` (String) - `icon_url` (String) - `icon_url_dark` (String) - `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy - `logo_url` (String) - `logo_url_dark` (String) \ No newline at end of file diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index e61e9c03..19f6a199 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -33,5 +33,4 @@ resource zitadel_lockout_policy lockout_policy { ### Read-Only -- `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 65cafe14..be271979 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -22,11 +22,11 @@ resource zitadel_login_policy login_policy { force_mfa = "false" passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" - password_check_lifetime = "240h" - external_login_check_lifetime = "240h" - multi_factor_check_lifetime = "720h" - mfa_init_skip_lifetime = "24h" - second_factor_check_lifetime = "24h" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = "true" default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] @@ -60,5 +60,4 @@ resource zitadel_login_policy login_policy { ### Read-Only -- `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index c658ff2a..16251de4 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -18,7 +18,7 @@ resource zitadel_machine_key machine_key { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" - expiration_date = "2519-04-01T08:45:00.000000Z" + expiration_date = "2519-04-01T08:45:00Z" } ``` diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index 8c5f0e46..0afb943d 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -38,5 +38,4 @@ resource zitadel_password_complexity_policy password_complexity_policy { ### Read-Only -- `id` (String) The ID of this resource. -- `is_default` (Boolean) defines if the organisation's admin changed the policy \ No newline at end of file +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index b8cb42f4..941f98d1 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -13,11 +13,11 @@ Resource representing a personal access token of a user ```terraform resource zitadel_personal_access_token pat { - depends_on = [zitadel_human_user.human_user, zitadel_org.org] + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id - user_id = zitadel_human_user.human_user.id - expiration_date = "2519-04-01T08:45:00.000000Z" + user_id = zitadel_machine_user.machine_user.id + expiration_date = "2519-04-01T08:45:00Z" } ``` diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 52b5179f..d85cadc4 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -34,5 +34,4 @@ resource zitadel_privacy_policy privacy_policy { ### Read-Only -- `id` (String) The ID of this resource. -- `is_default` (Boolean) \ No newline at end of file +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 4a0407cc..5cab8d44 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -13,11 +13,11 @@ Resource representing the authorization given to a user directly, including the ```terraform resource zitadel_user_grant user_grant{ - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.human_user] + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - role_keys = [""] + role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id } ``` diff --git a/examples/migration/main.tf b/examples/migration/main.tf new file mode 100644 index 00000000..8a0f963c --- /dev/null +++ b/examples/migration/main.tf @@ -0,0 +1,98 @@ +terraform { + required_providers { + zitadel = { + source = "zitadel/zitadel" + version = "0.0.0" + } + } +} + +provider zitadel { + issuer = "http://localhost:8080/oauth/v2" + address = "localhost:8080" + project = "160549024225689888" + token = "/Users/benz/go/src/github.com/zitadel/terraform-provider-zitadel/local-token" +} + + +data zitadelV1Org zitadelV1Org { + provider = zitadel + issuer = "https://issuer.zitadel.dev" + address = "api.zitadel.dev:443" + project = "70669147545070419" + token = "/Users/benz/go/src/github.com/zitadel/terraform-provider-zitadel/zitadel-dev-token" +} + +output fetched_org_id { + value = data.zitadelV1Org.zitadelV1Org.org +} + +output fetched_org_name { + value = data.zitadelV1Org.zitadelV1Org.name +} + +resource org org { + provider = zitadel + old_id = data.zitadelV1Org.zitadelV1Org.org + name = data.zitadelV1Org.zitadelV1Org.name +} + +resource user userTest { + depends_on = [data.zitadelV1Org.zitadelV1Org, org.org] + provider = zitadel + + for_each = { + for idx, user in data.zitadelV1Org.zitadelV1Org.users : user.user_name => user + } + old_id = each.value.id + resource_owner = org.org.id + state = each.value.state + user_name = each.value.user_name + login_names = each.value.login_names + preferred_login_name = each.value.preferred_login_name + type = each.value.type + first_name = each.value.first_name + last_name = each.value.last_name + nick_name = each.value.nick_name + display_name = each.value.display_name + preferred_language = each.value.preferred_language + gender = each.value.gender + phone = each.value.phone + is_phone_verified = each.value.is_phone_verified + email = each.value.email + is_email_verified = each.value.is_email_verified + name = each.value.name + description = each.value.description +} + + +resource project projectTest { + depends_on = [data.zitadelV1Org.zitadelV1Org, org.org] + provider = zitadel + + for_each = { + for idx, project in data.zitadelV1Org.zitadelV1Org.projects : project.name => project + } + old_id = each.value.id + name = each.value.name + state = each.value.state + resource_owner = org.org.id + project_role_assertion = each.value.project_role_assertion + project_role_check = each.value.project_role_check + has_project_check = each.value.has_project_check + private_labeling_setting = each.value.private_labeling_setting +} + + +resource domain domainTest { + depends_on = [data.zitadelV1Org.zitadelV1Org, org.org] + provider = zitadel + + for_each = { + for idx, domain in data.zitadelV1Org.zitadelV1Org.domains : domain.name => domain + } + + name = each.value.name + org_id = org.org.id +} + diff --git a/examples/provider/human_user.tf b/examples/provider/human_user.tf index 78028fec..616946c1 100644 --- a/examples/provider/human_user.tf +++ b/examples/provider/human_user.tf @@ -1,4 +1,3 @@ - resource zitadel_human_user human_user { depends_on = [zitadel_org.org] diff --git a/examples/provider/label_policy.tf b/examples/provider/label_policy.tf index 30370689..93d7c598 100644 --- a/examples/provider/label_policy.tf +++ b/examples/provider/label_policy.tf @@ -1,4 +1,3 @@ - resource zitadel_label_policy label_policy { depends_on = [zitadel_org.org] @@ -13,4 +12,5 @@ resource zitadel_label_policy label_policy { warn_color_dark = "#ff3b5b" font_color_dark = "#ffffff" disable_watermark = "false" + set_active = "true" } \ No newline at end of file diff --git a/examples/provider/login_policy.tf b/examples/provider/login_policy.tf index bbc233bf..5e30cfff 100644 --- a/examples/provider/login_policy.tf +++ b/examples/provider/login_policy.tf @@ -8,11 +8,11 @@ resource zitadel_login_policy login_policy { force_mfa = "false" passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" - password_check_lifetime = "240h" - external_login_check_lifetime = "240h" - multi_factor_check_lifetime = "720h" - mfa_init_skip_lifetime = "24h" - second_factor_check_lifetime = "24h" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = "true" default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] diff --git a/examples/provider/machine_key.tf b/examples/provider/machine_key.tf index c941777b..94212129 100644 --- a/examples/provider/machine_key.tf +++ b/examples/provider/machine_key.tf @@ -4,5 +4,5 @@ resource zitadel_machine_key machine_key { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" - expiration_date = "2519-04-01T08:45:00.000000Z" + expiration_date = "2519-04-01T08:45:00Z" } \ No newline at end of file diff --git a/examples/provider/personal_access_token.tf b/examples/provider/personal_access_token.tf index 0d14855e..0b063787 100644 --- a/examples/provider/personal_access_token.tf +++ b/examples/provider/personal_access_token.tf @@ -1,7 +1,7 @@ resource zitadel_personal_access_token pat { - depends_on = [zitadel_human_user.human_user, zitadel_org.org] + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id - user_id = zitadel_human_user.human_user.id - expiration_date = "2519-04-01T08:45:00.000000Z" + user_id = zitadel_machine_user.machine_user.id + expiration_date = "2519-04-01T08:45:00Z" } \ No newline at end of file diff --git a/examples/provider/user_grant.tf b/examples/provider/user_grant.tf index c2c8f4da..7479cf5f 100644 --- a/examples/provider/user_grant.tf +++ b/examples/provider/user_grant.tf @@ -1,9 +1,9 @@ resource zitadel_user_grant user_grant{ - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.human_user] + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - role_keys = [""] + role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id } \ No newline at end of file diff --git a/go.mod b/go.mod index e62db688..80020353 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.17 require ( github.com/hashicorp/terraform-plugin-log v0.4.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 - github.com/zitadel/oidc v1.5.1 + github.com/zitadel/oidc v1.7.0 github.com/zitadel/zitadel-go v0.3.5 - github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.2 - google.golang.org/protobuf v1.28.0 + github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 + google.golang.org/protobuf v1.28.1 ) require ( @@ -20,7 +20,7 @@ require ( github.com/google/go-cmp v0.5.8 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-hclog v1.2.0 // indirect @@ -48,14 +48,14 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.0.0-20220207234003-57398862261d // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect + golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect + golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/appengine v1.6.6 // indirect - google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect - google.golang.org/grpc v1.47.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 // indirect + google.golang.org/grpc v1.48.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index 04d70ccf..d71d23d0 100644 --- a/go.sum +++ b/go.sum @@ -13,14 +13,36 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= +cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= +cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= +cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -30,11 +52,13 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -53,14 +77,17 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6 github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -73,7 +100,10 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= @@ -111,6 +141,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -128,8 +159,10 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -140,6 +173,8 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +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.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= @@ -149,6 +184,8 @@ github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gA github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -156,11 +193,25 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 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/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= +github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= @@ -171,8 +222,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2 github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1/go.mod h1:chrfS3YoLAlKTRE5cFWvCbt8uGAjshktT4PveTUpsFQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 h1:BGNSrTRW4rwfhJiFwvwF4XQ0Y72Jj9YEgxVrtovbD5o= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3/go.mod h1:VHn7KgNsRriXa4mcgtkpR00OXyQY6g67JWMvn+R27A4= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 h1:BqHID5W5qnMkug0Z8UmL8tN0gAy4jQ+B4WFt8cCgluU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2/go.mod h1:ZbS3MZTZq/apAfAEHGoB5HbsQQstoqP92SjAqtQ9zeg= 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/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= @@ -221,6 +272,7 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1 github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -285,6 +337,8 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -298,8 +352,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM= github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -321,17 +376,23 @@ github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0 github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zitadel/logging v0.3.3/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.5.1 h1:e7VqNgrwE9I8FqDvxnd4YqCS0BAeKbgQSOVJ727ShxU= +github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.5.1/go.mod h1:s/hyqXVzchd3Y3XA2STBv2g4UKc5HeFf4Og/Mu98AYs= +github.com/zitadel/oidc v1.7.0 h1:Hy24siGCg2ciQmicF6zkGpCFOQir0zOBK63CZPS3ZKM= +github.com/zitadel/oidc v1.7.0/go.mod h1:lbT3Wd/8MujrbLWdVm6Ll6VJjmAUfzW9SscvB4GwLTQ= github.com/zitadel/zitadel-go v0.3.5 h1:j0rWIs/jC39BkKUSIYzKbFhr1NQ/0KBAvC0LfsiNX4o= github.com/zitadel/zitadel-go v0.3.5/go.mod h1:EFtsbJQRt7cjIK6zV+wwo7OWVjtxD5HaBfJ+9VxBwtI= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.2 h1:ABaR8jMayo3KlXSYVwZ4ukwE9RJroklz8ztgYbnV2ik= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.2/go.mod h1:ZZcNXlWlE1DIB8BBDMq+J0m0hTTq/C46w2NjAkoRzpg= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.4 h1:TbRSz8Sl3ZL+g3evMCeKo5CPtdHSZlaEQcmc4yghElI= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.4/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 h1:EeRJNEAlBeP0nUJ5H2SMfk+wngbowwtSMRub+/7cGxI= +github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= @@ -346,8 +407,9 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -370,6 +432,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -379,6 +442,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -411,21 +476,47 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY= +golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -435,7 +526,9 @@ 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-20201207232520-09787c993a3a/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/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= @@ -468,20 +561,45 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/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-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -489,6 +607,7 @@ 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= @@ -538,13 +657,25 @@ golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/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.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -561,13 +692,37 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= +google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= +google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= +google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= +google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +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-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -601,8 +756,57 @@ google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 h1:sRT5xdTkj1Kbk30qbYC7VyMj73N5pZYsw6v+Nrzdhno= +google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -616,13 +820,28 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -637,8 +856,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 60e16150..38435cd7 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -11,6 +11,19 @@ This provider allows the management of different resources on a ZITADEL instance Through this provider it is possible to interact with the [ZITADEL API](https://docs.zitadel.com/docs/apis/introduction) to configure different aspects of the instance. +Currently does not contain, but could be included in the future if demand exists: + +- instance as resource +- policies and settings on instance level as resource +- custom text resources + +Not planned to include as resources, as more administration task as a resource: + +- Import and export of organizations +- (re-)setting of password for human user +- initializing of OTP setup for human user +- initializing of passwordless setup for human user + ## Configuring the provider {{ tffile "examples/provider/provider.tf" }} diff --git a/zitadel/provider.go b/zitadel/provider.go index 62b298b9..a229ae13 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -2,16 +2,16 @@ package zitadel import ( "context" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + v2 "github.com/zitadel/terraform-provider-zitadel/zitadel/v2" ) func Provider() *schema.Provider { return &schema.Provider{ - DataSourcesMap: map[string]*schema.Resource{ - // "zitadelV1Org": v1.GetOrgDatasource(), - }, + DataSourcesMap: map[string]*schema.Resource{}, Schema: map[string]*schema.Schema{ v2.DomainVar: { Type: schema.TypeString, @@ -23,11 +23,6 @@ func Provider() *schema.Provider { Optional: true, Description: "Use insecure connection", }, - v2.ProjectVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the ZITADEL project on your ZITADEL instance, for the audience-scope", - }, v2.TokenVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v1/action.go b/zitadel/v1/action.go deleted file mode 100644 index b7edc7ef..00000000 --- a/zitadel/v1/action.go +++ /dev/null @@ -1,82 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - actionOrgId = "org_id" - actionState = "state" - actionName = "name" - actionScript = "script" - actionTimeout = "timeout" - actionAllowedToFail = "allowed_to_fail" -) - -func GetActionDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - actionOrgId: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the organization", - }, - actionState: { - Type: schema.TypeInt, - Computed: true, - Description: "the state of the action", - }, - actionName: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - actionScript: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - actionTimeout: { - Type: schema.TypeString, - Computed: true, - Description: "after which time the action will be terminated if not finished", - }, - actionAllowedToFail: { - Type: schema.TypeBool, - Computed: true, - Description: "when true, the next action will be called even if this action fails", - }, - }, - } -} - -func readActionsOfOrg(ctx context.Context, actions *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListActions(ctx, &management2.ListActionsRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - for i := range resp.Result { - action := resp.Result[i] - - values := map[string]interface{}{ - actionOrgId: action.GetDetails().GetResourceOwner(), - actionState: action.GetState(), - actionName: action.GetName(), - actionScript: action.GetScript(), - actionTimeout: action.GetTimeout().String(), - actionAllowedToFail: action.GetAllowedToFail(), - } - actions.Add(values) - } - - return nil -} diff --git a/zitadel/v1/client.go b/zitadel/v1/client.go deleted file mode 100644 index cd3343de..00000000 --- a/zitadel/v1/client.go +++ /dev/null @@ -1,56 +0,0 @@ -package v1 - -import ( - "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/oidc/pkg/oidc" - "github.com/zitadel/zitadel-go/pkg/client/management" - "github.com/zitadel/zitadel-go/pkg/client/middleware" - "github.com/zitadel/zitadel-go/pkg/client/zitadel" -) - -type ClientInfo struct { - Issuer string - Address string - Project string - Token string -} - -func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { - issuer := d.Get(issuerVar).(string) - address := d.Get(addressVar).(string) - projectID := d.Get(projectVar).(string) - token := d.Get(tokenVar).(string) - - return &ClientInfo{ - issuer, - address, - projectID, - token, - }, nil -} - -func getManagementClient(clientinfo *ClientInfo, orgID string) (*management.Client, error) { - opts := []zitadel.Option{ - zitadel.WithCustomURL(clientinfo.Issuer, clientinfo.Address), - zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(clientinfo.Token)), - } - if orgID != "" { - opts = append(opts, zitadel.WithOrgID(orgID)) - } - - client, err := management.NewClient( - []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(clientinfo.Project)}, - opts..., - ) - if err != nil { - return nil, fmt.Errorf("failed to start zitadel client: %v", err) - } - /*defer func() { - err := client.Connection.Close() - if err != nil { - log.Println("could not close grpc connection", err) - } - }()*/ - return client, nil -} diff --git a/zitadel/v1/domain.go b/zitadel/v1/domain.go deleted file mode 100644 index 51e25fed..00000000 --- a/zitadel/v1/domain.go +++ /dev/null @@ -1,79 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - domainOrgIdVar = "org_id" - domainNameVar = "name" - domainIsVerified = "is_verified" - domainIsPrimary = "is_primary" - domainValidationType = "validation_type" -) - -func GetDomainDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - domainNameVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Name of the domain", - }, - domainOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - domainIsVerified: { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Is domain verified", - }, - domainIsPrimary: { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Is domain primary", - }, - domainValidationType: { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Validation type", - }, - }, - } -} - -func readDomainsOfOrg(ctx context.Context, domains *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListOrgDomains(ctx, &management2.ListOrgDomainsRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - for i := range resp.Result { - domain := resp.Result[i] - - values := map[string]interface{}{ - domainOrgIdVar: domain.GetOrgId(), - domainNameVar: domain.GetDomainName(), - domainIsVerified: domain.GetIsVerified(), - domainIsPrimary: domain.GetIsPrimary(), - domainValidationType: int(domain.GetValidationType().Number()), - } - domains.Add(values) - } - - return nil -} diff --git a/zitadel/v1/iam_policy.go b/zitadel/v1/iam_policy.go deleted file mode 100644 index 647d0536..00000000 --- a/zitadel/v1/iam_policy.go +++ /dev/null @@ -1,58 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - iamPolicyOrgIdVar = "org_id" - iamPolicyUserLogin = "user_login" - iamPolicyIsDefault = "is_default" -) - -func GetIAMPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - iamPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - iamPolicyUserLogin: { - Type: schema.TypeBool, - Computed: true, - Description: "User login must be domain", - }, - iamPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "Is this policy the default", - }, - }, - } -} - -func readIAMPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetOrgIAMPolicy(ctx, &management2.GetOrgIAMPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get iam policy: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - iamPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - iamPolicyUserLogin: policy.GetUserLoginMustBeDomain(), - iamPolicyIsDefault: policy.GetIsDefault(), - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/label_policy.go b/zitadel/v1/label_policy.go deleted file mode 100644 index 4e835a64..00000000 --- a/zitadel/v1/label_policy.go +++ /dev/null @@ -1,156 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - labelPolicyOrgIdVar = "org_id" - labelPolicyPrimaryColor = "primary_color" - labelPolicyIsDefault = "is_default" - labelPolicyHideLoginNameSuffix = "hide_login_name_suffix" - labelPolicyWarnColor = "warn_color" - labelPolicyBackgroundColor = "background_color" - labelPolicyFontColor = "font_color" - labelPolicyPrimaryColorDark = "primary_color_dark" - labelPolicyBackgroundColorDark = "background_color_dark" - labelPolicyWarnColorDark = "warn_color_dark" - labelPolicyFontColorDark = "font_color_dark" - labelPolicyDisableWatermark = "disable_watermark" - labelPolicyLogoURL = "logo_url" - labelPolicyIconURL = "icon_url" - labelPolicyLogoURLDark = "logo_url_dark" - labelPolicyIconURLDark = "icon_url_dark" - labelPolicyFontURL = "font_url" -) - -func GetLabelPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - labelPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - labelPolicyPrimaryColor: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for primary color", - }, - labelPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, - labelPolicyHideLoginNameSuffix: { - Type: schema.TypeBool, - Computed: true, - Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes", - }, - labelPolicyWarnColor: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for warn color", - }, - labelPolicyBackgroundColor: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for background color", - }, - labelPolicyFontColor: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for font color", - }, - labelPolicyPrimaryColorDark: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for primary color dark theme", - }, - labelPolicyBackgroundColorDark: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for background color dark theme", - }, - labelPolicyWarnColorDark: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for warn color dark theme", - }, - labelPolicyFontColorDark: { - Type: schema.TypeString, - Computed: true, - Description: "hex value for font color dark theme", - }, - labelPolicyDisableWatermark: { - Type: schema.TypeBool, - Computed: true, - Description: "", - }, - labelPolicyLogoURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyIconURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyLogoURLDark: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyIconURLDark: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyFontURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - }, - } -} - -func readLabelPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetLabelPolicy(ctx, &management2.GetLabelPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - labelPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - labelPolicyPrimaryColor: policy.GetPrimaryColor(), - labelPolicyIsDefault: policy.GetIsDefault(), - labelPolicyHideLoginNameSuffix: policy.GetHideLoginNameSuffix(), - labelPolicyWarnColor: policy.GetWarnColor(), - labelPolicyBackgroundColor: policy.GetBackgroundColor(), - labelPolicyFontColor: policy.GetFontColor(), - labelPolicyPrimaryColorDark: policy.GetPrimaryColorDark(), - labelPolicyBackgroundColorDark: policy.GetBackgroundColorDark(), - labelPolicyWarnColorDark: policy.GetWarnColorDark(), - labelPolicyFontColorDark: policy.GetFontColorDark(), - labelPolicyDisableWatermark: policy.GetDisableWatermark(), - labelPolicyLogoURL: policy.GetLogoUrl(), - labelPolicyIconURL: policy.GetIconUrl(), - labelPolicyLogoURLDark: policy.GetLogoUrlDark(), - labelPolicyIconURLDark: policy.GetIconUrlDark(), - labelPolicyFontURL: policy.GetFontUrl(), - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/lockout_policy.go b/zitadel/v1/lockout_policy.go deleted file mode 100644 index e1a325a4..00000000 --- a/zitadel/v1/lockout_policy.go +++ /dev/null @@ -1,58 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - lockoutPolicyOrgIdVar = "org_id" - lockoutPolicyMaxPasswordAttempts = "max_password_attempts" - lockoutPolicyIsDefault = "is_default" -) - -func GetLockoutPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - lockoutPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - lockoutPolicyMaxPasswordAttempts: { - Type: schema.TypeInt, - Computed: true, - Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", - }, - lockoutPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, - }, - } -} - -func readLockoutPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetLockoutPolicy(ctx, &management2.GetLockoutPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - lockoutPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - lockoutPolicyIsDefault: policy.GetIsDefault(), - lockoutPolicyMaxPasswordAttempts: policy.GetMaxPasswordAttempts(), - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/login_policy.go b/zitadel/v1/login_policy.go deleted file mode 100644 index 0992ed28..00000000 --- a/zitadel/v1/login_policy.go +++ /dev/null @@ -1,107 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - loginPolicyOrgIdVar = "org_id" - loginPolicyAllowUsernamePassword = "allow_username_password" - loginPolicyAllowRegister = "allow_register" - loginPolicyAllowExternalIDP = "allow_external_idp" - loginPolicyForceMFA = "force_mfa" - loginPolicyPasswordlessType = "passwordless_type" - loginPolicyIsDefault = "is_default" - loginPolicyHidePasswordReset = "hide_password_reset" - loginPolicyIgnoreUnknownUsernames = "ignore_unknown_usernames" - loginPolicyDefaultRedirectURI = "default_redirect_uri" -) - -func GetLoginPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - loginPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - loginPolicyAllowUsernamePassword: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if a user is allowed to login with his username and password", - }, - loginPolicyAllowRegister: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if a person is allowed to register a user on this organisation", - }, - loginPolicyAllowExternalIDP: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if a user is allowed to add a defined identity provider. E.g. Google auth", - }, - loginPolicyForceMFA: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if a user MUST use a multi factor to log in", - }, - loginPolicyPasswordlessType: { - Type: schema.TypeInt, - Computed: true, - Description: "defines if passwordless is allowed for users", - }, - loginPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, - loginPolicyHidePasswordReset: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if password reset link should be shown in the login screen", - }, - loginPolicyIgnoreUnknownUsernames: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if unknown username on login screen directly return an error or always display the password screen", - }, - loginPolicyDefaultRedirectURI: { - Type: schema.TypeString, - Computed: true, - Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", - }, - }, - } -} - -func readLoginPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetLoginPolicy(ctx, &management2.GetLoginPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - loginPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - loginPolicyAllowUsernamePassword: policy.GetAllowUsernamePassword(), - loginPolicyAllowRegister: policy.GetAllowRegister(), - loginPolicyAllowExternalIDP: policy.GetAllowExternalIdp(), - loginPolicyForceMFA: policy.GetForceMfa(), - loginPolicyPasswordlessType: policy.GetPasswordlessType(), - loginPolicyIsDefault: policy.GetIsDefault(), - loginPolicyHidePasswordReset: policy.GetHidePasswordReset(), - loginPolicyIgnoreUnknownUsernames: policy.GetIgnoreUnknownUsernames(), - //loginPolicyDefaultRedirectURI: policy - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/member.go b/zitadel/v1/member.go deleted file mode 100644 index 0a3f550a..00000000 --- a/zitadel/v1/member.go +++ /dev/null @@ -1,58 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - memberOrgID = "org_id" - memberUserID = "user_id" -) - -func GetMemberDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - memberOrgID: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "ID of the organization", - }, - memberUserID: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - }, - }, - } -} - -func readMembersOfOrg(ctx context.Context, domains *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListOrgDomains(ctx, &management2.ListOrgDomainsRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - for i := range resp.Result { - domain := resp.Result[i] - - values := map[string]interface{}{ - domainOrgIdVar: domain.GetOrgId(), - domainNameVar: domain.GetDomainName(), - domainIsVerified: domain.GetIsVerified(), - domainIsPrimary: domain.GetIsPrimary(), - domainValidationType: int(domain.GetValidationType().Number()), - } - domains.Add(values) - } - - return nil -} diff --git a/zitadel/v1/org.go b/zitadel/v1/org.go deleted file mode 100644 index f79e4679..00000000 --- a/zitadel/v1/org.go +++ /dev/null @@ -1,294 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - orgVar = "org" - nameVar = "name" - issuerVar = "issuer" - addressVar = "address" - projectVar = "project" - tokenVar = "token" - - passwordComplexityPolicyVar = "password_complexity_policy" - lockoutPolicyVar = "lockout_policy" - loginPolicyVar = "login_policy" - iamPolicyVar = "iam_policy" - labelPolicyVar = "label_policy" - privacyPolicyVar = "privacy_policy" - - usersVar = "users" - projectsVar = "projects" - domainsVar = "domains" - actionsVar = "actions" -) - -func GetOrgDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - orgVar: { - Type: schema.TypeString, - Optional: true, - Description: "ID of the organization", - }, - nameVar: { - Type: schema.TypeString, - Optional: true, - Description: "Name of the organization", - }, - issuerVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("ISSUER", ""), - }, - addressVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("ADDRESS", ""), - }, - projectVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("PROJECT", ""), - }, - tokenVar: { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("SERVICE_TOKEN", ""), - }, - - passwordComplexityPolicyVar: { - Type: schema.TypeSet, - Elem: GetPasswordComplexityPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of password complexity policies in organization", - }, - lockoutPolicyVar: { - Type: schema.TypeSet, - Elem: GetLockoutPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of lockout policies in organization", - }, - loginPolicyVar: { - Type: schema.TypeSet, - Elem: GetLoginPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of login policies in organization", - }, - labelPolicyVar: { - Type: schema.TypeSet, - Elem: GetLabelPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of label policies in organization", - }, - iamPolicyVar: { - Type: schema.TypeSet, - Elem: GetIAMPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of domain policies in organization", - }, - privacyPolicyVar: { - Type: schema.TypeSet, - Elem: GetPrivacyPolicyDatasource(), - Optional: true, - Computed: true, - Description: "List of privacy policies in organization", - }, - - usersVar: { - Type: schema.TypeSet, - Elem: GetUserDatasource(), - Optional: true, - Computed: true, - Description: "List of users in organization", - }, - projectsVar: { - Type: schema.TypeSet, - Elem: GetProjectDatasource(), - Optional: true, - Computed: true, - Description: "List of projects in organization", - }, - domainsVar: { - Type: schema.TypeSet, - Elem: GetDomainDatasource(), - Optional: true, - Computed: true, - Description: "List of domains in organization", - }, - actionsVar: { - Type: schema.TypeSet, - Elem: GetActionDatasource(), - Optional: true, - Computed: true, - Description: "List of actions in organization", - }, - }, - ReadContext: readOrg, - } -} - -func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, err := GetClientInfo(d) - if err != nil { - return diag.FromErr(err) - } - - client, err := getManagementClient(clientinfo, "") - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetMyOrg(ctx, &management2.GetMyOrgRequest{}) - if err != nil { - return diag.Errorf("failed to get org: %v", err) - } - id := resp.GetOrg().GetId() - d.SetId(id) - name := resp.GetOrg().GetName() - - tflog.Debug(ctx, "found org", map[string]interface{}{ - "id": id, - "name": name, - }) - - if err := d.Set(nameVar, name); err != nil { - return diag.Errorf("failed to set org name: %v", err) - } - if err := d.Set(orgVar, id); err != nil { - return diag.Errorf("failed to set org: %v", err) - } - d.SetId(id) - - /**************************************************************************************** - Users - */ - users := d.Get(usersVar).(*schema.Set) - if err := readUsersOfOrg(ctx, users, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(usersVar, users); err != nil { - return diag.Errorf("failed to set list of users: %v", err) - } - - /**************************************************************************************** - Projects - */ - projects := d.Get(projectsVar).(*schema.Set) - if err := readProjectsOfOrg(ctx, projects, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(projectsVar, projects); err != nil { - return diag.Errorf("failed to set list of projects: %v", err) - } - /**************************************************************************************** - Domains - */ - domains := d.Get(domainsVar).(*schema.Set) - if err := readDomainsOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(domainsVar, domains); err != nil { - return diag.Errorf("failed to set list of domains: %v", err) - } - - /**************************************************************************************** - iam policy - */ - iamPolicy := d.Get(iamPolicyVar).(*schema.Set) - if err := readIAMPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(iamPolicyVar, iamPolicy); err != nil { - return diag.Errorf("failed to set list of iam policies: %v", err) - } - - /**************************************************************************************** - label policy - */ - labelPolicy := d.Get(labelPolicyVar).(*schema.Set) - if err := readLabelPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(labelPolicyVar, labelPolicy); err != nil { - return diag.Errorf("failed to set list of label policies: %v", err) - } - - /**************************************************************************************** - lockout policy - */ - lockoutPolicy := d.Get(lockoutPolicyVar).(*schema.Set) - if err := readLockoutPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(lockoutPolicyVar, lockoutPolicy); err != nil { - return diag.Errorf("failed to set list of lockout policies: %v", err) - } - - /**************************************************************************************** - login policy - */ - loginPolicy := d.Get(loginPolicyVar).(*schema.Set) - if err := readLoginPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(loginPolicyVar, loginPolicy); err != nil { - return diag.Errorf("failed to set list of login policies: %v", err) - } - - /**************************************************************************************** - password complexity policy - */ - passwordComplexityPolicy := d.Get(passwordComplexityPolicyVar).(*schema.Set) - if err := readPasswordComplexityPolicyPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(passwordComplexityPolicyVar, passwordComplexityPolicy); err != nil { - return diag.Errorf("failed to set list of password complexity policies: %v", err) - } - - /**************************************************************************************** - privacy policy - */ - privacyPolicy := d.Get(privacyPolicyVar).(*schema.Set) - if err := readPrivacyPolicyOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(privacyPolicyVar, privacyPolicy); err != nil { - return diag.Errorf("failed to set list of privacy policies: %v", err) - } - - /**************************************************************************************** - actions - */ - actions := d.Get(actionsVar).(*schema.Set) - if err := readActionsOfOrg(ctx, domains, m, clientinfo, resp.GetOrg().GetId()); err != nil { - return err - } - if err := d.Set(actionsVar, actions); err != nil { - return diag.Errorf("failed to set list of actions: %v", err) - } - - return nil -} - -func resourceToValueMap(r *schema.Resource, d *schema.ResourceData) map[string]interface{} { - values := make(map[string]interface{}, 0) - for key := range r.Schema { - values[key] = d.Get(key) - } - return values -} diff --git a/zitadel/v1/password_complexity_policy.go b/zitadel/v1/password_complexity_policy.go deleted file mode 100644 index 90ebaa5a..00000000 --- a/zitadel/v1/password_complexity_policy.go +++ /dev/null @@ -1,86 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - passwordCompPolicyOrgIdVar = "org_id" - passwordCompPolicyMinLength = "min_length" - passwordCompPolicyHasUppercase = "has_uppercase" - passwordCompPolicyHasLowercase = "has_lowercase" - passwordCompPolicyHasNumber = "has_number" - passwordCompPolicyHasSymbol = "has_symbol" - passwordCompPolicyIsDefault = "is_default" -) - -func GetPasswordComplexityPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - passwordCompPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - passwordCompPolicyMinLength: { - Type: schema.TypeInt, - Computed: true, - Description: "Minimal length for the password", - }, - passwordCompPolicyHasUppercase: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the password MUST contain an upper case letter", - }, - passwordCompPolicyHasLowercase: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the password MUST contain a lower case letter", - }, - passwordCompPolicyHasNumber: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the password MUST contain a number", - }, - passwordCompPolicyHasSymbol: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the password MUST contain a symbol. E.g. \"$\"", - }, - passwordCompPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, - }, - } -} - -func readPasswordComplexityPolicyPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetPasswordComplexityPolicy(ctx, &management2.GetPasswordComplexityPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - passwordCompPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - passwordCompPolicyMinLength: policy.GetMinLength(), - passwordCompPolicyHasUppercase: policy.GetHasUppercase(), - passwordCompPolicyHasLowercase: policy.GetHasLowercase(), - passwordCompPolicyHasNumber: policy.GetHasNumber(), - passwordCompPolicyHasSymbol: policy.GetHasSymbol(), - passwordCompPolicyIsDefault: policy.GetIsDefault(), - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/privacy_policy.go b/zitadel/v1/privacy_policy.go deleted file mode 100644 index 25233bb1..00000000 --- a/zitadel/v1/privacy_policy.go +++ /dev/null @@ -1,72 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - privacyPolicyOrgIdVar = "org_id" - privacyPolicyTOSLink = "tos_link" - privacyPolicyPrivacyLink = "privacy_link" - privacyPolicyIsDefault = "is_default" - privacyPolicyHelpLink = "help_link" -) - -func GetPrivacyPolicyDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - privacyPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - }, - privacyPolicyTOSLink: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - privacyPolicyPrivacyLink: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - privacyPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "", - }, - privacyPolicyHelpLink: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - }, - } -} - -func readPrivacyPolicyOfOrg(ctx context.Context, policies *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetPrivacyPolicy(ctx, &management2.GetPrivacyPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to get list of domains: %v", err) - } - - policy := resp.Policy - values := map[string]interface{}{ - privacyPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - privacyPolicyTOSLink: policy.GetTosLink(), - privacyPolicyPrivacyLink: policy.GetPrivacyLink(), - privacyPolicyIsDefault: policy.GetIsDefault(), - privacyPolicyHelpLink: policy.GetHelpLink(), - } - policies.Add(values) - return nil -} diff --git a/zitadel/v1/project.go b/zitadel/v1/project.go deleted file mode 100644 index 90526287..00000000 --- a/zitadel/v1/project.go +++ /dev/null @@ -1,129 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - projectNameVar = "name" - projectState = "state" - projectResourceOwner = "resource_owner" - projectRoleAssertionVar = "project_role_assertion" - projectRoleCheckVar = "project_role_check" - hasProjectCheckVar = "has_project_check" - privateLabelingSettingVar = "private_labeling_setting" -) - -func GetProjectDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - projectNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the project", - }, - projectResourceOwner: { - Type: schema.TypeString, - Computed: true, - Description: "Organization in which the project is located", - }, - projectState: { - Type: schema.TypeInt, - Computed: true, - Description: "State of the project", - }, - projectRoleAssertionVar: { - Type: schema.TypeBool, - Computed: true, - Description: "describes if roles of user should be added in token", - }, - projectRoleCheckVar: { - Type: schema.TypeBool, - Computed: true, - Description: "ZITADEL checks if the user has at least one on this project", - }, - hasProjectCheckVar: { - Type: schema.TypeBool, - Computed: true, - Description: "ZITADEL checks if the org of the user has permission to this project", - }, - privateLabelingSettingVar: { - Type: schema.TypeInt, - Computed: true, - Description: "Defines from where the private labeling should be triggered", - }, - }, - } -} - -func readProjectsOfOrg(ctx context.Context, projects *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListProjects(ctx, &management2.ListProjectsRequest{}) - if err != nil { - return diag.Errorf("failed to get list of projects: %v", err) - } - - projectResource := GetProjectDatasource() - for i := range resp.Result { - project := resp.Result[i] - projectdata := projectResource.Data(&terraform.InstanceState{}) - projectdata.SetId(project.Id) - if errDiag := readProject(ctx, projectdata, m, clientinfo, org); errDiag != nil { - return errDiag - } - - data := resourceToValueMap(projectResource, projectdata) - projects.Add(data) - } - return nil -} - -func readProject(ctx context.Context, d *schema.ResourceData, m interface{}, info *ClientInfo, org string) diag.Diagnostics { - tflog.Info(ctx, "started read") - - client, err := getManagementClient(info, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetProjectByID(ctx, &management2.GetProjectByIDRequest{Id: d.Id()}) - if err != nil { - return diag.Errorf("failed to get list of users: %v", err) - } - - project := resp.GetProject() - set := map[string]interface{}{ - projectResourceOwner: project.GetDetails().GetResourceOwner(), - projectState: project.GetState().Number(), - projectNameVar: project.GetName(), - projectRoleAssertionVar: project.GetProjectRoleAssertion(), - projectRoleCheckVar: project.GetProjectRoleCheck(), - hasProjectCheckVar: project.GetHasProjectCheck(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of project: %v", k, err) - } - } - d.SetId(project.GetId()) - return nil -} - -func getProjectValueMap(d *schema.ResourceData) map[string]interface{} { - res := GetProjectDatasource() - - values := make(map[string]interface{}, 0) - for key := range res.Schema { - values[key] = d.Get(key) - } - return values -} diff --git a/zitadel/v1/user.go b/zitadel/v1/user.go deleted file mode 100644 index bf51e54e..00000000 --- a/zitadel/v1/user.go +++ /dev/null @@ -1,236 +0,0 @@ -package v1 - -import ( - "context" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - v2 "github.com/zitadel/terraform-provider-zitadel/zitadel/v2" - management2 "github.com/zitadel/zitadel-go/pkg/client/zitadel/management" -) - -const ( - idVar = "id" - resourceOwnerVar = "resource_owner" - userStateVar = "state" - userNameVar = "user_name" - loginNamesVar = "login_names" - preferredLoginNameVar = "preferred_login_name" - typeVar = "type" - - firstNameVar = "first_name" - lastNameVar = "last_name" - nickNameVar = "nick_name" - displayNameVar = "display_name" - preferredLanguageVar = "preferred_language" - genderVar = "gender" - - isEmailVerifiedVar = "is_email_verified" - emailVar = "email" - - isPhoneVerifiedVar = "is_phone_verified" - phoneVar = "phone" - - machineNameVar = "name" - descriptionVar = "description" -) - -func GetUserDatasource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - idVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "ID of the user", - }, - resourceOwnerVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - userStateVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "State of the user", - }, - userNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Username", - }, - loginNamesVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "Loginnames", - }, - preferredLoginNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Preferred login name", - }, - typeVar: { - Type: schema.TypeString, - Computed: true, - Description: "Type of the user", - }, - - firstNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "First name of the user", - }, - lastNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Last name of the user", - }, - nickNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Nick name of the user", - }, - displayNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "DIsplay name of the user", - }, - preferredLanguageVar: { - Type: schema.TypeString, - Computed: true, - Description: "Preferred language of the user", - }, - genderVar: { - Type: schema.TypeInt, - Computed: true, - Description: "Gender of the user", - }, - - emailVar: { - Type: schema.TypeString, - Computed: true, - Description: "Email of the user", - }, - isEmailVerifiedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "Is the email verified of the user", - }, - - phoneVar: { - Type: schema.TypeString, - Computed: true, - Description: "Phone of the user", - }, - isPhoneVerifiedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "Is the phone verified of the user", - }, - - machineNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the machine user", - }, - descriptionVar: { - Type: schema.TypeString, - Computed: true, - Description: "Description of the user", - }, - }, - } -} - -func readUsersOfOrg(ctx context.Context, users *schema.Set, m interface{}, clientinfo *ClientInfo, org string) diag.Diagnostics { - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListUsers(ctx, &management2.ListUsersRequest{}) - if err != nil { - return diag.Errorf("failed to get list of users: %v", err) - } - - userResource := GetUserDatasource() - for i := range resp.Result { - user := resp.Result[i] - - userdata := userResource.Data(&terraform.InstanceState{}) - userdata.SetId(user.GetId()) - if errDiag := readUser(ctx, userdata, m, clientinfo, org); errDiag != nil { - return errDiag - } - data := resourceToValueMap(userResource, userdata) - users.Add(data) - } - return nil -} - -func readUser(ctx context.Context, d *schema.ResourceData, m interface{}, info *ClientInfo, org string) diag.Diagnostics { - tflog.Info(ctx, "started read") - - client, err := getManagementClient(info, org) - if err != nil { - return diag.FromErr(err) - } - - respUser, err := client.GetUserByID(ctx, &management2.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - return diag.Errorf("failed to get list of users: %v", err) - } - - user := respUser.GetUser() - userType := "" - loginNames := []string{} - for _, v := range user.GetLoginNames() { - loginNames = append(loginNames, v) - } - set := map[string]interface{}{ - idVar: user.GetId(), - resourceOwnerVar: user.GetDetails().GetResourceOwner(), - userStateVar: user.GetState().String(), - userNameVar: user.GetUserName(), - loginNamesVar: loginNames, - preferredLoginNameVar: user.GetPreferredLoginName(), - typeVar: userType, - } - if human := user.GetHuman(); human != nil { - set[typeVar] = v2.HumanUser - if profile := human.GetProfile(); profile != nil { - set[firstNameVar] = profile.GetFirstName() - set[lastNameVar] = profile.GetLastName() - set[displayNameVar] = profile.GetDisplayName() - set[nickNameVar] = profile.GetNickName() - set[preferredLanguageVar] = profile.GetPreferredLanguage() - if gender := profile.GetGender().Number(); gender != 0 { - set[genderVar] = gender - } - } - if email := human.GetEmail(); email != nil { - set[emailVar] = email.GetEmail() - set[isEmailVerifiedVar] = email.GetIsEmailVerified() - } - if phone := human.GetPhone(); phone != nil { - set[phoneVar] = phone.GetPhone() - set[isPhoneVerifiedVar] = phone.GetIsPhoneVerified() - } - } else if machine := user.GetMachine(); machine != nil { - set[typeVar] = v2.MachineUser - set[machineNameVar] = machine.GetName() - set[descriptionVar] = machine.GetDescription() - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of user: %v", k, err) - } - } - d.SetId(user.GetId()) - return nil -} diff --git a/zitadel/v2/action.go b/zitadel/v2/action.go index 2588b954..31203f0d 100644 --- a/zitadel/v2/action.go +++ b/zitadel/v2/action.go @@ -2,12 +2,13 @@ package v2 import ( "context" + "time" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "time" ) const ( @@ -161,29 +162,32 @@ func readAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag resp, err := client.ListActions(ctx, &management2.ListActionsRequest{}) if err != nil { - return diag.Errorf("failed to read action: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to read action: %v", err) } - set := map[string]interface{}{} - actionIDStr := "" for i := range resp.Result { action := resp.Result[i] if action.GetId() == d.Id() { - actionIDStr = d.Id() - set[actionOrgId] = action.GetDetails().GetResourceOwner() - set[actionName] = action.GetName() - set[actionState] = action.GetState() - set[actionScript] = action.GetScript() - set[actionTimeout] = action.GetTimeout().AsDuration().String() - set[actionAllowedToFail] = action.GetAllowedToFail() + set := map[string]interface{}{ + actionOrgId: action.GetDetails().GetResourceOwner(), + actionName: action.GetName(), + actionState: action.GetState(), + actionScript: action.GetScript(), + actionTimeout: action.GetTimeout().AsDuration().String(), + actionAllowedToFail: action.GetAllowedToFail(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of action: %v", k, err) + } + } + d.SetId(action.GetId()) + return nil } } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of action: %v", k, err) - } - } - d.SetId(actionIDStr) + d.SetId("") return nil } diff --git a/zitadel/v2/application_api.go b/zitadel/v2/application_api.go index 2e1cf0d8..9d373343 100644 --- a/zitadel/v2/application_api.go +++ b/zitadel/v2/application_api.go @@ -3,6 +3,7 @@ package v2 import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/application_oidc.go b/zitadel/v2/application_oidc.go index 6eebdae9..b94a358c 100644 --- a/zitadel/v2/application_oidc.go +++ b/zitadel/v2/application_oidc.go @@ -2,14 +2,15 @@ package v2 import ( "context" + "reflect" + "time" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "reflect" - "time" ) const ( diff --git a/zitadel/v2/client.go b/zitadel/v2/client.go index c2ffe6f3..183a482d 100644 --- a/zitadel/v2/client.go +++ b/zitadel/v2/client.go @@ -2,6 +2,7 @@ package v2 import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/oidc/pkg/oidc" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" @@ -13,7 +14,6 @@ import ( const ( DomainVar = "domain" InsecureVar = "insecure" - ProjectVar = "project" TokenVar = "token" PortVar = "port" ) @@ -22,7 +22,6 @@ type ClientInfo struct { Domain string Issuer string Options []zitadel.Option - Project string } func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { @@ -60,19 +59,19 @@ func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { domain, issuer, options, - d.Get(ProjectVar).(string), }, nil } func getAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( info.Issuer, info.Domain, - []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, + []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}, info.Options..., ) if err != nil { return nil, fmt.Errorf("failed to start zitadel client: %v", err) } + return client, nil } @@ -84,7 +83,7 @@ func getManagementClient(info *ClientInfo, orgID string) (*management.Client, er client, err := management.NewClient( info.Issuer, info.Domain, - []string{oidc.ScopeOpenID, zitadel.ScopeProjectID(info.Project)}, + []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}, options..., ) if err != nil { diff --git a/zitadel/v2/domain.go b/zitadel/v2/domain.go index 4c120cd6..9c9be240 100644 --- a/zitadel/v2/domain.go +++ b/zitadel/v2/domain.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/domain_policy.go b/zitadel/v2/domain_policy.go index b247403d..0cd14f3c 100644 --- a/zitadel/v2/domain_policy.go +++ b/zitadel/v2/domain_policy.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -12,7 +13,6 @@ import ( const ( domainPolicyOrgIdVar = "org_id" domainPolicyUserLoginMustBeDomain = "user_login_must_be_domain" - domainPolicyIsDefault = "is_default" domainPolicyValidateOrgDomain = "validate_org_domains" domainPolicySmtpSender = "smtp_sender_address_matches_instance_domain" ) @@ -32,11 +32,6 @@ func GetDomainPolicy() *schema.Resource { Required: true, Description: "User login must be domain", }, - domainPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "Is this policy the default", - }, domainPolicyValidateOrgDomain: { Type: schema.TypeBool, Required: true, @@ -75,7 +70,6 @@ func deleteDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.Errorf("failed to reset domain policy: %v", err) } - d.SetId(org) return nil } @@ -155,9 +149,12 @@ func readDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{} } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ domainPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - domainPolicyIsDefault: policy.GetIsDefault(), domainPolicyUserLoginMustBeDomain: policy.GetUserLoginMustBeDomain(), domainPolicyValidateOrgDomain: policy.GetValidateOrgDomains(), } diff --git a/zitadel/v2/idp_jwt.go b/zitadel/v2/idp_jwt.go index f62fcc7c..bc6e3958 100644 --- a/zitadel/v2/idp_jwt.go +++ b/zitadel/v2/idp_jwt.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -75,7 +76,7 @@ func createOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(domainOrgIdVar).(string)) + client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -197,6 +198,5 @@ func readOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) d } } d.SetId(idp.Id) - return nil } diff --git a/zitadel/v2/idp_oidc.go b/zitadel/v2/idp_oidc.go index 9345ca79..9fe8773e 100644 --- a/zitadel/v2/idp_oidc.go +++ b/zitadel/v2/idp_oidc.go @@ -2,12 +2,13 @@ package v2 import ( "context" + "reflect" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "reflect" ) const ( diff --git a/zitadel/v2/label_policy.go b/zitadel/v2/label_policy.go index e5212627..8ac61acc 100644 --- a/zitadel/v2/label_policy.go +++ b/zitadel/v2/label_policy.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,7 +12,6 @@ import ( const ( labelPolicyOrgIdVar = "org_id" labelPolicyPrimaryColor = "primary_color" - labelPolicyIsDefault = "is_default" labelPolicyHideLoginNameSuffix = "hide_login_name_suffix" labelPolicyWarnColor = "warn_color" labelPolicyBackgroundColor = "background_color" @@ -26,6 +26,7 @@ const ( labelPolicyLogoURLDark = "logo_url_dark" labelPolicyIconURLDark = "icon_url_dark" labelPolicyFontURL = "font_url" + labelPolicySetActive = "set_active" ) func GetLabelPolicy() *schema.Resource { @@ -43,11 +44,6 @@ func GetLabelPolicy() *schema.Resource { Required: true, Description: "hex value for primary color", }, - labelPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, labelPolicyHideLoginNameSuffix: { Type: schema.TypeBool, Required: true, @@ -118,6 +114,11 @@ func GetLabelPolicy() *schema.Resource { Computed: true, Description: "", }, + labelPolicySetActive: { + Type: schema.TypeBool, + Optional: true, + Description: "set the label policy active after creating/updating", + }, }, ReadContext: readLabelPolicy, CreateContext: createLabelPolicy, @@ -144,7 +145,6 @@ func deleteLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{ if err != nil { return diag.Errorf("failed to reset label policy: %v", err) } - d.SetId(org) return nil } @@ -178,6 +178,16 @@ func updateLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{ return diag.Errorf("failed to update label policy: %v", err) } d.SetId(org) + + active := d.Get(labelPolicySetActive) + if active != nil { + activeBool := active.(bool) + if activeBool { + if _, err := client.ActivateCustomLabelPolicy(ctx, &management2.ActivateCustomLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate label policy: %v", err) + } + } + } return nil } @@ -211,6 +221,16 @@ func createLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{ return diag.Errorf("failed to create label policy: %v", err) } d.SetId(org) + + active := d.Get(labelPolicySetActive) + if active != nil { + activeBool := active.(bool) + if activeBool { + if _, err := client.ActivateCustomLabelPolicy(ctx, &management2.ActivateCustomLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate label policy: %v", err) + } + } + } return nil } @@ -228,7 +248,7 @@ func readLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } - resp, err := client.GetLabelPolicy(ctx, &management2.GetLabelPolicyRequest{}) + resp, err := client.GetPreviewLabelPolicy(ctx, &management2.GetPreviewLabelPolicyRequest{}) if err != nil { d.SetId("") return nil @@ -236,9 +256,11 @@ func readLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ - labelPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - labelPolicyIsDefault: policy.GetIsDefault(), labelPolicyPrimaryColor: policy.GetPrimaryColor(), labelPolicyHideLoginNameSuffix: policy.GetHideLoginNameSuffix(), labelPolicyWarnColor: policy.GetWarnColor(), diff --git a/zitadel/v2/lockout_policy.go b/zitadel/v2/lockout_policy.go index b804292b..7643ce8e 100644 --- a/zitadel/v2/lockout_policy.go +++ b/zitadel/v2/lockout_policy.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,7 +12,6 @@ import ( const ( lockoutPolicyOrgIdVar = "org_id" lockoutPolicyMaxPasswordAttempts = "max_password_attempts" - lockoutPolicyIsDefault = "is_default" ) func GetLockoutPolicy() *schema.Resource { @@ -30,11 +30,6 @@ func GetLockoutPolicy() *schema.Resource { Required: true, Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", }, - lockoutPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, }, DeleteContext: deleteLockoutPolicy, CreateContext: createLockoutPolicy, @@ -61,7 +56,6 @@ func deleteLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interfac if err != nil { return diag.Errorf("failed to reset lockout policy: %v", err) } - d.SetId(org) return nil } @@ -135,9 +129,12 @@ func readLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{ } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ lockoutPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - lockoutPolicyIsDefault: policy.GetIsDefault(), lockoutPolicyMaxPasswordAttempts: policy.GetMaxPasswordAttempts(), } diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go index 0c91e416..6a6c331d 100644 --- a/zitadel/v2/login_policy.go +++ b/zitadel/v2/login_policy.go @@ -2,6 +2,8 @@ package v2 import ( "context" + "time" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -9,7 +11,6 @@ import ( management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" "google.golang.org/protobuf/types/known/durationpb" - "time" ) const ( @@ -19,7 +20,6 @@ const ( loginPolicyAllowExternalIDP = "allow_external_idp" loginPolicyForceMFA = "force_mfa" loginPolicyPasswordlessType = "passwordless_type" - loginPolicyIsDefault = "is_default" loginPolicyHidePasswordReset = "hide_password_reset" loginPolicyPasswordCheckLifetime = "password_check_lifetime" loginPolicyExternalLoginCheckLifetime = "external_login_check_lifetime" @@ -68,11 +68,6 @@ func GetLoginPolicy() *schema.Resource { Required: true, Description: "defines if passwordless is allowed for users", }, - loginPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, loginPolicyHidePasswordReset: { Type: schema.TypeBool, Required: true, @@ -163,7 +158,6 @@ func deleteLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ if err != nil { return diag.Errorf("failed to reset login policy: %v", err) } - d.SetId(org) return nil } @@ -208,23 +202,42 @@ func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{ return diag.FromErr(err) } - _, err = client.UpdateCustomLoginPolicy(ctx, &management2.UpdateCustomLoginPolicyRequest{ - AllowUsernamePassword: d.Get(loginPolicyAllowUsernamePassword).(bool), - AllowRegister: d.Get(loginPolicyAllowRegister).(bool), - AllowExternalIdp: d.Get(loginPolicyAllowExternalIDP).(bool), - ForceMfa: d.Get(loginPolicyForceMFA).(bool), - PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]), - HidePasswordReset: d.Get(loginPolicyHidePasswordReset).(bool), - IgnoreUnknownUsernames: d.Get(loginPolicyIgnoreUnknownUsernames).(bool), - DefaultRedirectUri: d.Get(loginPolicyDefaultRedirectURI).(string), - PasswordCheckLifetime: durationpb.New(passwordCheckLT), - ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), - MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), - SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), - MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), - }) - if err != nil { - return diag.Errorf("failed to update login policy: %v", err) + allowUsernamePassword := d.Get(loginPolicyAllowUsernamePassword).(bool) + allowRegister := d.Get(loginPolicyAllowRegister).(bool) + allowExternalIdp := d.Get(loginPolicyAllowExternalIDP).(bool) + forceMfa := d.Get(loginPolicyForceMFA).(bool) + passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]) + hidePasswordReset := d.Get(loginPolicyHidePasswordReset).(bool) + ignoreUnkownUsernames := d.Get(loginPolicyIgnoreUnknownUsernames).(bool) + defaultRedirectUri := d.Get(loginPolicyDefaultRedirectURI).(string) + currentPolicy := current.GetPolicy() + if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || + currentPolicy.GetAllowRegister() != allowRegister || + currentPolicy.GetAllowExternalIdp() != allowExternalIdp || + currentPolicy.GetForceMfa() != forceMfa || + currentPolicy.GetPasswordlessType() != passwordlessType || + currentPolicy.GetHidePasswordReset() != hidePasswordReset || + currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || + currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { + + _, err = client.UpdateCustomLoginPolicy(ctx, &management2.UpdateCustomLoginPolicyRequest{ + AllowUsernamePassword: allowUsernamePassword, + AllowRegister: allowRegister, + AllowExternalIdp: allowExternalIdp, + ForceMfa: forceMfa, + PasswordlessType: passwordlessType, + HidePasswordReset: hidePasswordReset, + IgnoreUnknownUsernames: ignoreUnkownUsernames, + DefaultRedirectUri: defaultRedirectUri, + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + }) + if err != nil { + return diag.Errorf("failed to update login policy: %v", err) + } } d.SetId(org) @@ -389,9 +402,12 @@ func readLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ loginPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - loginPolicyIsDefault: policy.GetIsDefault(), loginPolicyAllowUsernamePassword: policy.GetAllowUsernamePassword(), loginPolicyAllowRegister: policy.GetAllowRegister(), loginPolicyAllowExternalIDP: policy.GetAllowExternalIdp(), diff --git a/zitadel/v2/machine_key.go b/zitadel/v2/machine_key.go index cf31523f..4353e610 100644 --- a/zitadel/v2/machine_key.go +++ b/zitadel/v2/machine_key.go @@ -2,13 +2,14 @@ package v2 import ( "context" + "time" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/timestamppb" - "time" ) const ( @@ -97,9 +98,9 @@ func createMachineKey(ctx context.Context, d *schema.ResourceData, m interface{} return diag.FromErr(err) } - t, err := time.Parse(timeFormat, d.Get(machineKeyExpirationDateVar).(string)) + t, err := time.Parse(time.RFC3339, d.Get(machineKeyExpirationDateVar).(string)) if err != nil { - return diag.FromErr(err) + return diag.Errorf("failed to parse time: %v", err) } keyType := d.Get(machineKeyKeyTypeVar).(string) @@ -135,9 +136,14 @@ func readMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) UserId: userID, KeyId: d.Id(), }) + if err != nil { + d.SetId("") + return nil + } d.SetId(resp.GetKey().GetId()) + set := map[string]interface{}{ - machineKeyExpirationDateVar: resp.GetKey().GetExpirationDate().String(), + machineKeyExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), machineKeyUserIDVar: userID, machineKeyOrgIDVar: orgID, } diff --git a/zitadel/v2/org.go b/zitadel/v2/org.go index e3fbb1db..fe34b707 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org.go @@ -2,12 +2,13 @@ package v2 import ( "context" + "strings" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" admin2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "strings" ) const ( diff --git a/zitadel/v2/org_member.go b/zitadel/v2/org_member.go index ba775104..d9edd72c 100644 --- a/zitadel/v2/org_member.go +++ b/zitadel/v2/org_member.go @@ -2,11 +2,12 @@ package v2 import ( "context" + "strings" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "strings" ) const ( @@ -138,7 +139,9 @@ func readOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) d resp, err := client.ListOrgMembers(ctx, &management2.ListOrgMembersRequest{}) if err != nil { - return diag.Errorf("failed to read orgmember: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to read orgmember: %v", err) } userID := d.Get(orgMemberUserIDVar).(string) @@ -158,6 +161,7 @@ func readOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) d return nil } } + d.SetId("") return nil } diff --git a/zitadel/v2/password_complexity_policy.go b/zitadel/v2/password_complexity_policy.go index 697e40b7..9da5a66a 100644 --- a/zitadel/v2/password_complexity_policy.go +++ b/zitadel/v2/password_complexity_policy.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -15,7 +16,6 @@ const ( passwordCompPolicyHasLowercase = "has_lowercase" passwordCompPolicyHasNumber = "has_number" passwordCompPolicyHasSymbol = "has_symbol" - passwordCompPolicyIsDefault = "is_default" ) func GetPasswordComplexityPolicy() *schema.Resource { @@ -53,11 +53,6 @@ func GetPasswordComplexityPolicy() *schema.Resource { Required: true, Description: "defines if the password MUST contain a symbol. E.g. \"$\"", }, - passwordCompPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "defines if the organisation's admin changed the policy", - }, }, DeleteContext: deletePasswordComplexityPolicy, ReadContext: readPasswordComplexityPolicy, @@ -84,7 +79,6 @@ func deletePasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, if err != nil { return diag.Errorf("failed to reset password complexity policy: %v", err) } - d.SetId(org) return nil } @@ -166,9 +160,12 @@ func readPasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ passwordCompPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - passwordCompPolicyIsDefault: policy.GetIsDefault(), passwordCompPolicyMinLength: policy.GetMinLength(), passwordCompPolicyHasUppercase: policy.GetHasUppercase(), passwordCompPolicyHasLowercase: policy.GetHasLowercase(), diff --git a/zitadel/v2/pat.go b/zitadel/v2/pat.go index 53c51186..ead39087 100644 --- a/zitadel/v2/pat.go +++ b/zitadel/v2/pat.go @@ -2,12 +2,13 @@ package v2 import ( "context" + "time" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/timestamppb" - "time" ) const ( @@ -15,7 +16,6 @@ const ( patUserIDVar = "user_id" patTokenVar = "token" patExpirationDateVar = "expiration_date" - timeFormat = "2519-04-01T08:45:00.000000Z" ) func GetPAT() *schema.Resource { @@ -90,20 +90,20 @@ func createPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag. return diag.FromErr(err) } - t, err := time.Parse(timeFormat, d.Get(patExpirationDateVar).(string)) + t, err := time.Parse(time.RFC3339, d.Get(patExpirationDateVar).(string)) if err != nil { - return diag.FromErr(err) + return diag.Errorf("failed to parse time: %v", err) } resp, err := client.AddPersonalAccessToken(ctx, &management2.AddPersonalAccessTokenRequest{ UserId: d.Get(patUserIDVar).(string), ExpirationDate: timestamppb.New(t), }) - d.SetId(resp.GetTokenId()) + if err := d.Set(patTokenVar, resp.GetToken()); err != nil { return diag.FromErr(err) } - + d.SetId(resp.GetTokenId()) return nil } @@ -125,9 +125,13 @@ func readPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di UserId: userID, TokenId: d.Id(), }) - d.SetId(resp.GetToken().GetId()) + if err != nil { + d.SetId("") + return nil + } + set := map[string]interface{}{ - patExpirationDateVar: resp.GetToken().GetExpirationDate().String(), + patExpirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), patUserIDVar: userID, patOrgIDVar: orgID, } @@ -136,8 +140,6 @@ func readPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di return diag.Errorf("failed to set %s of project: %v", k, err) } } - if err := d.Set(patTokenVar, resp.GetToken()); err != nil { - return diag.FromErr(err) - } + d.SetId(resp.GetToken().GetId()) return nil } diff --git a/zitadel/v2/privacy_policy.go b/zitadel/v2/privacy_policy.go index 194bac93..8d7dec45 100644 --- a/zitadel/v2/privacy_policy.go +++ b/zitadel/v2/privacy_policy.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -12,7 +13,6 @@ const ( privacyPolicyOrgIdVar = "org_id" privacyPolicyTOSLink = "tos_link" privacyPolicyPrivacyLink = "privacy_link" - privacyPolicyIsDefault = "is_default" privacyPolicyHelpLink = "help_link" ) @@ -36,11 +36,6 @@ func GetPrivacyPolicy() *schema.Resource { Required: true, Description: "", }, - privacyPolicyIsDefault: { - Type: schema.TypeBool, - Computed: true, - Description: "", - }, privacyPolicyHelpLink: { Type: schema.TypeString, Required: true, @@ -72,7 +67,6 @@ func deletePrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interfac if err != nil { return diag.Errorf("failed to reset privacy policy: %v", err) } - d.SetId(org) return nil } @@ -150,9 +144,12 @@ func readPrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{ } policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } set := map[string]interface{}{ privacyPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - privacyPolicyIsDefault: policy.GetIsDefault(), privacyPolicyTOSLink: policy.GetTosLink(), privacyPolicyPrivacyLink: policy.GetPrivacyLink(), privacyPolicyHelpLink: policy.GetHelpLink(), diff --git a/zitadel/v2/project.go b/zitadel/v2/project.go index 87e72a74..d7cb9cf5 100644 --- a/zitadel/v2/project.go +++ b/zitadel/v2/project.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/project_grant.go b/zitadel/v2/project_grant.go index a945fe19..c328dd5f 100644 --- a/zitadel/v2/project_grant.go +++ b/zitadel/v2/project_grant.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/project_grant_member.go b/zitadel/v2/project_grant_member.go index f5773762..100230ee 100644 --- a/zitadel/v2/project_grant_member.go +++ b/zitadel/v2/project_grant_member.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -160,7 +161,9 @@ func readProjectGrantMember(ctx context.Context, d *schema.ResourceData, m inter grantID := d.Get(projectGrantMemberGrantIDVar).(string) resp, err := client.ListProjectGrantMembers(ctx, &management2.ListProjectGrantMembersRequest{ProjectId: projectID, GrantId: grantID}) if err != nil { - return diag.Errorf("failed to read projectgrantmember: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to read projectgrantmember: %v", err) } userID := d.Get(projectGrantMemberUserIDVar).(string) @@ -182,6 +185,7 @@ func readProjectGrantMember(ctx context.Context, d *schema.ResourceData, m inter return nil } } + d.SetId("") return nil } diff --git a/zitadel/v2/project_member.go b/zitadel/v2/project_member.go index 5633cfa5..e05eab74 100644 --- a/zitadel/v2/project_member.go +++ b/zitadel/v2/project_member.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -149,7 +150,9 @@ func readProjectMember(ctx context.Context, d *schema.ResourceData, m interface{ projectID := d.Get(projectMemberProjectIDVar).(string) resp, err := client.ListProjectMembers(ctx, &management2.ListProjectMembersRequest{ProjectId: projectID}) if err != nil { - return diag.Errorf("failed to read projectmember: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to read projectmember: %v", err) } userID := d.Get(projectMemberUserIDVar).(string) @@ -170,6 +173,7 @@ func readProjectMember(ctx context.Context, d *schema.ResourceData, m interface{ return nil } } + d.SetId("") return nil } diff --git a/zitadel/v2/project_role.go b/zitadel/v2/project_role.go index 6ebd32ae..9ee219b3 100644 --- a/zitadel/v2/project_role.go +++ b/zitadel/v2/project_role.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/trigger_actions.go b/zitadel/v2/trigger_actions.go index 17e16cdb..f543b0c5 100644 --- a/zitadel/v2/trigger_actions.go +++ b/zitadel/v2/trigger_actions.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -39,8 +40,10 @@ func GetTriggerActions() *schema.Resource { ForceNew: true, }, triggerActionsActionsVar: { - Type: schema.TypeSet, - Elem: schema.TypeString, + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, Required: true, Description: "IDs of the triggered actions", }, @@ -140,7 +143,10 @@ func createTriggerActions(ctx context.Context, d *schema.ResourceData, m interfa func readTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - d.SetId("") + orgID := d.Get(triggerActionsOrgIDVar).(string) + flowType := d.Get(triggerActionsFlowTypeVar).(string) + triggerType := d.Get(triggerActionsTriggerTypeVar).(string) + d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) return nil } diff --git a/zitadel/v2/user.go b/zitadel/v2/user.go index eee11e00..17b04520 100644 --- a/zitadel/v2/user.go +++ b/zitadel/v2/user.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -23,19 +24,16 @@ const ( preferredLanguageVar = "preferred_language" genderVar = "gender" - isPhoneVerifiedVar = "is_phone_verified" + isEmailVerifiedVar = "is_email_verified" emailVar = "email" - isEmailVerifiedVar = "is_email_verified" + isPhoneVerifiedVar = "is_phone_verified" phoneVar = "phone" machineNameVar = "name" descriptionVar = "description" initialPasswordVar = "initial_password" - - HumanUser = "human" - MachineUser = "machine" ) func GetHumanUser() *schema.Resource { @@ -271,7 +269,7 @@ func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) IsPhoneVerified: false, } if isVerified != nil { - addUser.Email.IsEmailVerified = isVerified.(bool) + addUser.Phone.IsPhoneVerified = isVerified.(bool) } } @@ -285,7 +283,7 @@ func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) } func createMachineUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") + tflog.Info(ctx, "started create") clientinfo, ok := m.(*ClientInfo) if !ok { @@ -310,7 +308,7 @@ func createMachineUser(ctx context.Context, d *schema.ResourceData, m interface{ } func updateHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") + tflog.Info(ctx, "started update") clientinfo, ok := m.(*ClientInfo) if !ok { @@ -394,7 +392,7 @@ func updateHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) } func updateMachineUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") + tflog.Info(ctx, "started update") clientinfo, ok := m.(*ClientInfo) if !ok { diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant.go index 3c08d553..6f856e3c 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant.go @@ -2,10 +2,12 @@ package v2 import ( "context" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" ) const ( @@ -50,6 +52,7 @@ func GetUserGrant() *schema.Resource { Type: schema.TypeString, Required: true, Description: "ID of the organization which owns the resource", + ForceNew: true, }, }, DeleteContext: deleteUserGrant, @@ -95,10 +98,14 @@ func updateUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } + roles := make([]string, 0) + for _, role := range d.Get(userGrantRoleKeysVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } _, err = client.UpdateUserGrant(ctx, &management2.UpdateUserGrantRequest{ GrantId: d.Id(), UserId: d.Get(userGrantUserIDVar).(string), - RoleKeys: d.Get(userGrantRoleKeysVar).([]string), + RoleKeys: roles, }) if err != nil { return diag.Errorf("failed to update usergrant: %v", err) @@ -119,11 +126,16 @@ func createUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } + roles := make([]string, 0) + for _, role := range d.Get(userGrantRoleKeysVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + resp, err := client.AddUserGrant(ctx, &management2.AddUserGrantRequest{ UserId: d.Get(userGrantUserIDVar).(string), ProjectGrantId: d.Get(userGrantProjectGrantIDVar).(string), ProjectId: d.Get(userGrantProjectIDVar).(string), - RoleKeys: d.Get(userGrantRoleKeysVar).([]string), + RoleKeys: roles, }) if err != nil { return diag.Errorf("failed to create usergrant: %v", err) @@ -144,27 +156,58 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d if err != nil { return diag.FromErr(err) } + projectID := d.Get(userGrantProjectIDVar) + projectGrantID := d.Get(userGrantProjectGrantIDVar) - resp, err := client.GetUserGrantByID(ctx, &management2.GetUserGrantByIDRequest{UserId: d.Get(userGrantUserIDVar).(string), GrantId: d.Id()}) + queries := []*user.UserGrantQuery{ + {Query: &user.UserGrantQuery_UserIdQuery{ + UserIdQuery: &user.UserGrantUserIDQuery{ + UserId: d.Get(userGrantUserIDVar).(string), + }, + }}, + } + if projectID != nil { + queries = append(queries, &user.UserGrantQuery{Query: &user.UserGrantQuery_ProjectIdQuery{ + ProjectIdQuery: &user.UserGrantProjectIDQuery{ + ProjectId: projectID.(string), + }, + }}, + ) + } + if projectGrantID != nil { + queries = append(queries, &user.UserGrantQuery{Query: &user.UserGrantQuery_ProjectGrantIdQuery{ + ProjectGrantIdQuery: &user.UserGrantProjectGrantIDQuery{ + ProjectGrantId: projectGrantID.(string), + }, + }}, + ) + } + grants, err := client.ListUserGrants(ctx, &management2.ListUserGrantRequest{ + Queries: queries, + }) if err != nil { d.SetId("") return nil //return diag.Errorf("failed to read usergrant: %v", err) } - grant := resp.GetUserGrant() - set := map[string]interface{}{ - userGrantUserIDVar: grant.GetProjectId(), - userGrantProjectIDVar: grant.GetProjectId(), - userGrantProjectGrantIDVar: grant.GetProjectGrantId(), - userGrantRoleKeysVar: grant.GetRoleKeys(), - userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectgrant: %v", k, err) + if len(grants.GetResult()) == 1 { + grant := grants.GetResult()[0] + set := map[string]interface{}{ + userGrantUserIDVar: grant.GetUserId(), + userGrantProjectIDVar: grant.GetProjectId(), + userGrantProjectGrantIDVar: grant.GetProjectGrantId(), + userGrantRoleKeysVar: grant.GetRoleKeys(), + userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of usergrant: %v", k, err) + } } + d.SetId(grant.GetId()) } - d.SetId(grant.GetId()) + + d.SetId("") return nil } From 97b2d6c6cf46906ae4a15542bdf1b77bfba129f7 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 11 Aug 2022 09:01:56 +0200 Subject: [PATCH 010/260] fix: handling of usergrant as it has optional attributes --- docs/index.md | 2 +- docs/resources/user_grant.md | 4 ++-- examples/provider/provider.tf | 2 +- zitadel/v2/user_grant.go | 19 ++++++++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/index.md b/docs/index.md index 88bc1599..81858b02 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,7 +31,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.5" + version = "1.0.0-alpha.6" } } } diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 5cab8d44..00019b89 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -28,13 +28,13 @@ resource zitadel_user_grant user_grant{ ### Required - `org_id` (String) ID of the organization which owns the resource -- `project_id` (String) ID of the project -- `role_keys` (Set of String) List of roles granted - `user_id` (String) ID of the user ### Optional - `project_grant_id` (String) ID of the granted project +- `project_id` (String) ID of the project +- `role_keys` (Set of String) List of roles granted ### Read-Only diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index b1f07936..c1bd881f 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.4" + version = "1.0.0-alpha.6" } } } diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant.go index 6f856e3c..7e7449a5 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant.go @@ -24,7 +24,7 @@ func GetUserGrant() *schema.Resource { Schema: map[string]*schema.Schema{ userGrantProjectIDVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "ID of the project", ForceNew: true, }, @@ -45,7 +45,7 @@ func GetUserGrant() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "List of roles granted", }, userGrantOrgIDVar: { @@ -194,11 +194,15 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d if len(grants.GetResult()) == 1 { grant := grants.GetResult()[0] set := map[string]interface{}{ - userGrantUserIDVar: grant.GetUserId(), - userGrantProjectIDVar: grant.GetProjectId(), - userGrantProjectGrantIDVar: grant.GetProjectGrantId(), - userGrantRoleKeysVar: grant.GetRoleKeys(), - userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), + userGrantUserIDVar: grant.GetUserId(), + userGrantRoleKeysVar: grant.GetRoleKeys(), + userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), + } + if grant.GetProjectId() != "" { + set[userGrantProjectIDVar] = grant.GetProjectId() + } + if grant.GetProjectGrantId() != "" { + set[userGrantProjectGrantIDVar] = grant.GetProjectGrantId() } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -206,6 +210,7 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d } } d.SetId(grant.GetId()) + return nil } d.SetId("") From c38f89dce97a97a0368379aa511cda6c5c09e513 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 31 Aug 2022 15:51:23 +0200 Subject: [PATCH 011/260] fix: added app keys, import possibility and fixed human user creation with initial password --- docs/resources/application_api.md | 2 +- docs/resources/application_key.md | 40 +++++ docs/resources/human_user.md | 13 +- docs/resources/machine_user.md | 2 +- examples/provider/app_key.tf | 9 ++ examples/provider/application_api.tf | 2 +- examples/provider/granted_human_user.tf | 2 +- examples/provider/human_user.tf | 5 +- examples/provider/machine_user.tf | 2 +- go.mod | 2 +- templates/resources/application_key.md.tmpl | 16 ++ templates/resources/human_user.md.tmpl | 2 + zitadel/provider.go | 1 + zitadel/v2/action.go | 52 +++--- zitadel/v2/app_key.go | 169 ++++++++++++++++++++ zitadel/v2/application_api.go | 1 + zitadel/v2/application_oidc.go | 1 + zitadel/v2/domain.go | 5 +- zitadel/v2/domain_policy.go | 1 + zitadel/v2/idp_jwt.go | 1 + zitadel/v2/idp_oidc.go | 1 + zitadel/v2/label_policy.go | 1 + zitadel/v2/lockout_policy.go | 1 + zitadel/v2/login_policy.go | 1 + zitadel/v2/machine_key.go | 1 + zitadel/v2/org.go | 71 ++++---- zitadel/v2/org_member.go | 40 +++-- zitadel/v2/password_complexity_policy.go | 1 + zitadel/v2/pat.go | 1 + zitadel/v2/privacy_policy.go | 1 + zitadel/v2/project.go | 1 + zitadel/v2/project_grant.go | 1 + zitadel/v2/project_grant_member.go | 46 ++++-- zitadel/v2/project_member.go | 43 +++-- zitadel/v2/project_role.go | 9 +- zitadel/v2/trigger_actions.go | 1 + zitadel/v2/user.go | 70 +++++++- zitadel/v2/user_grant.go | 1 + 38 files changed, 499 insertions(+), 120 deletions(-) create mode 100644 docs/resources/application_key.md create mode 100644 examples/provider/app_key.tf create mode 100644 templates/resources/application_key.md.tmpl create mode 100644 zitadel/v2/app_key.go diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 25bf5c78..f80889d7 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -18,7 +18,7 @@ resource zitadel_application_api application_api { org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" - auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" + auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } ``` diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md new file mode 100644 index 00000000..6618a6c6 --- /dev/null +++ b/docs/resources/application_key.md @@ -0,0 +1,40 @@ +--- +page_title: "zitadel_application_key Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a app key +--- + +# zitadel_application_key (Resource) + +Resource representing a app key + +## Example Usage + +```terraform +resource zitadel_application_key app_key { + depends_on = [zitadel_application_api.application_api, zitadel_project.project, zitadel_org.org] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + app_id = zitadel_application_api.application_api.id + key_type = "KEY_TYPE_JSON" + expiration_date = "2519-04-01T08:45:00Z" +} +``` + + +## Schema + +### Required + +- `app_id` (String) ID of the application +- `expiration_date` (String) Expiration date of the app key +- `key_type` (String) Type of the app key +- `org_id` (String) ID of the organization +- `project_id` (String) ID of the project + +### Read-Only + +- `id` (String) The ID of this resource. +- `key_details` (String, Sensitive) Value of the app key \ No newline at end of file diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index e8518766..5dd790cb 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -7,6 +7,8 @@ description: |- # zitadel_human_user (Resource) +**Caution: Email can only be set verified if a password is set for the user, either with initial_password or during runtime** + Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources. ## Example Usage @@ -16,7 +18,7 @@ resource zitadel_human_user human_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "human" + user_name = "human@localhost.com" first_name = "firstname" last_name = "lastname" nick_name = "nickname" @@ -26,7 +28,8 @@ resource zitadel_human_user human_user { phone = "+41799999999" is_phone_verified = "true" email = "test@zitadel.com" - is_email_verified = "false" + is_email_verified = "true" + initial_password = "Password1!" } ``` @@ -42,11 +45,11 @@ resource zitadel_human_user human_user { ### Optional -- `display_name` (String) DIsplay name of the user +- `display_name` (String) Display name of the user - `email` (String) Email of the user - `gender` (String) Gender of the user -- `initial_password` (String) Initially set password for the user -- `is_email_verified` (Boolean) Is the email verified of the user +- `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation +- `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user - `nick_name` (String) Nick name of the user - `phone` (String) Phone of the user diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index 3f0a8286..3cd40d57 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -16,7 +16,7 @@ resource zitadel_machine_user machine_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "machine" + user_name = "machine@localhost.com" name = "name" description = "description" } diff --git a/examples/provider/app_key.tf b/examples/provider/app_key.tf new file mode 100644 index 00000000..343b92e9 --- /dev/null +++ b/examples/provider/app_key.tf @@ -0,0 +1,9 @@ +resource zitadel_application_key app_key { + depends_on = [zitadel_application_api.application_api, zitadel_project.project, zitadel_org.org] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + app_id = zitadel_application_api.application_api.id + key_type = "KEY_TYPE_JSON" + expiration_date = "2519-04-01T08:45:00Z" +} \ No newline at end of file diff --git a/examples/provider/application_api.tf b/examples/provider/application_api.tf index 8c893bcd..b58c2229 100644 --- a/examples/provider/application_api.tf +++ b/examples/provider/application_api.tf @@ -5,5 +5,5 @@ resource zitadel_application_api application_api { org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" - auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" + auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } \ No newline at end of file diff --git a/examples/provider/granted_human_user.tf b/examples/provider/granted_human_user.tf index 80e29a17..1496bd6a 100644 --- a/examples/provider/granted_human_user.tf +++ b/examples/provider/granted_human_user.tf @@ -3,7 +3,7 @@ resource zitadel_human_user granted_human_user { depends_on = [zitadel_org.grantedorg] org_id = zitadel_org.grantedorg.id - user_name = "human" + user_name = "human@localhost" first_name = "firstname" last_name = "lastname" nick_name = "nickname" diff --git a/examples/provider/human_user.tf b/examples/provider/human_user.tf index 616946c1..048d5864 100644 --- a/examples/provider/human_user.tf +++ b/examples/provider/human_user.tf @@ -2,7 +2,7 @@ resource zitadel_human_user human_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "human" + user_name = "human@localhost.com" first_name = "firstname" last_name = "lastname" nick_name = "nickname" @@ -12,5 +12,6 @@ resource zitadel_human_user human_user { phone = "+41799999999" is_phone_verified = "true" email = "test@zitadel.com" - is_email_verified = "false" + is_email_verified = "true" + initial_password = "Password1!" } diff --git a/examples/provider/machine_user.tf b/examples/provider/machine_user.tf index 31687733..a61f64af 100644 --- a/examples/provider/machine_user.tf +++ b/examples/provider/machine_user.tf @@ -3,7 +3,7 @@ resource zitadel_machine_user machine_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "machine" + user_name = "machine@localhost.com" name = "name" description = "description" } \ No newline at end of file diff --git a/go.mod b/go.mod index 80020353..da021f94 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zitadel/terraform-provider-zitadel -go 1.17 +go 1.19 require ( github.com/hashicorp/terraform-plugin-log v0.4.0 diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl new file mode 100644 index 00000000..f3395ea5 --- /dev/null +++ b/templates/resources/application_key.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/app_key.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/human_user.md.tmpl b/templates/resources/human_user.md.tmpl index 36c2cfc1..139dcd38 100644 --- a/templates/resources/human_user.md.tmpl +++ b/templates/resources/human_user.md.tmpl @@ -7,6 +7,8 @@ description: |- # {{.Name}} ({{.Type}}) +**Caution: Email can only be set verified if a password is set for the user, either with initial_password or during runtime** + {{ .Description | trimspace }} ## Example Usage diff --git a/zitadel/provider.go b/zitadel/provider.go index a229ae13..e23d8ccd 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -44,6 +44,7 @@ func Provider() *schema.Provider { "zitadel_action": v2.GetAction(), "zitadel_application_oidc": v2.GetApplicationOIDC(), "zitadel_application_api": v2.GetApplicationAPI(), + "zitadel_application_key": v2.GetAppKey(), "zitadel_project_grant": v2.GetProjectGrant(), "zitadel_user_grant": v2.GetUserGrant(), "zitadel_org_member": v2.GetOrgMember(), diff --git a/zitadel/v2/action.go b/zitadel/v2/action.go index 31203f0d..2279b2ed 100644 --- a/zitadel/v2/action.go +++ b/zitadel/v2/action.go @@ -7,7 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" ) @@ -60,6 +61,7 @@ func GetAction() *schema.Resource { DeleteContext: deleteAction, ReadContext: readAction, UpdateContext: updateAction, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -81,7 +83,7 @@ func updateAction(ctx context.Context, d *schema.ResourceData, m interface{}) di return diag.FromErr(err) } - _, err = client.UpdateAction(ctx, &management2.UpdateActionRequest{ + _, err = client.UpdateAction(ctx, &management.UpdateActionRequest{ Id: d.Id(), Name: d.Get(actionName).(string), Script: d.Get(actionScript).(string), @@ -107,7 +109,7 @@ func deleteAction(ctx context.Context, d *schema.ResourceData, m interface{}) di return diag.FromErr(err) } - _, err = client.DeleteAction(ctx, &management2.DeleteActionRequest{ + _, err = client.DeleteAction(ctx, &management.DeleteActionRequest{ Id: d.Id(), }) if err != nil { @@ -134,7 +136,7 @@ func createAction(ctx context.Context, d *schema.ResourceData, m interface{}) di return diag.FromErr(err) } - resp, err := client.CreateAction(ctx, &management2.CreateActionRequest{ + resp, err := client.CreateAction(ctx, &management.CreateActionRequest{ Name: d.Get(actionName).(string), Script: d.Get(actionScript).(string), Timeout: durationpb.New(timeout), @@ -160,32 +162,38 @@ func readAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag return diag.FromErr(err) } - resp, err := client.ListActions(ctx, &management2.ListActionsRequest{}) + resp, err := client.ListActions(ctx, &management.ListActionsRequest{ + Queries: []*management.ActionQuery{ + {Query: &management.ActionQuery_ActionIdQuery{ + ActionIdQuery: &action.ActionIDQuery{ + Id: d.Id(), + }, + }}, + }, + }) if err != nil { d.SetId("") return nil //return diag.Errorf("failed to read action: %v", err) } - for i := range resp.Result { - action := resp.Result[i] - if action.GetId() == d.Id() { - set := map[string]interface{}{ - actionOrgId: action.GetDetails().GetResourceOwner(), - actionName: action.GetName(), - actionState: action.GetState(), - actionScript: action.GetScript(), - actionTimeout: action.GetTimeout().AsDuration().String(), - actionAllowedToFail: action.GetAllowedToFail(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of action: %v", k, err) - } + if len(resp.Result) == 1 { + action := resp.Result[0] + set := map[string]interface{}{ + actionOrgId: action.GetDetails().GetResourceOwner(), + actionName: action.GetName(), + actionState: action.GetState(), + actionScript: action.GetScript(), + actionTimeout: action.GetTimeout().AsDuration().String(), + actionAllowedToFail: action.GetAllowedToFail(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of action: %v", k, err) } - d.SetId(action.GetId()) - return nil } + d.SetId(action.GetId()) + return nil } d.SetId("") diff --git a/zitadel/v2/app_key.go b/zitadel/v2/app_key.go new file mode 100644 index 00000000..9215f4b1 --- /dev/null +++ b/zitadel/v2/app_key.go @@ -0,0 +1,169 @@ +package v2 + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" +) + +const ( + appKeyOrgIDVar = "org_id" + appKeyProjectIDVar = "project_id" + appKeyAppIDVar = "app_id" + appKeyKeyTypeVar = "key_type" + appKeyKeyDetailsVar = "key_details" + appKeyExpirationDateVar = "expiration_date" +) + +func GetAppKey() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a app key", + Schema: map[string]*schema.Schema{ + appKeyOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + appKeyProjectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + appKeyAppIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the application", + ForceNew: true, + }, + appKeyKeyTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the app key", + ForceNew: true, + }, + appKeyExpirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the app key", + ForceNew: true, + }, + appKeyKeyDetailsVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the app key", + Sensitive: true, + }, + }, + DeleteContext: deleteAppKey, + CreateContext: createAppKey, + ReadContext: readAppKey, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} + +func deleteAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := getManagementClient(clientinfo, d.Get(appKeyOrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveAppKey(ctx, &management2.RemoveAppKeyRequest{ + ProjectId: d.Get(appKeyProjectIDVar).(string), + AppId: d.Get(appKeyAppIDVar).(string), + KeyId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete app key: %v", err) + } + return nil +} + +func createAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(appKeyOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(time.RFC3339, d.Get(appKeyExpirationDateVar).(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + + keyType := d.Get(appKeyKeyTypeVar).(string) + resp, err := client.AddAppKey(ctx, &management2.AddAppKeyRequest{ + ProjectId: d.Get(appKeyProjectIDVar).(string), + AppId: d.Get(appKeyAppIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), + ExpirationDate: timestamppb.New(t), + }) + + d.SetId(resp.GetId()) + if err := d.Set(appKeyKeyDetailsVar, string(resp.GetKeyDetails())); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func readAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(appKeyOrgIDVar).(string) + client, err := getManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(appKeyProjectIDVar).(string) + appID := d.Get(appKeyAppIDVar).(string) + resp, err := client.GetAppKey(ctx, &management2.GetAppKeyRequest{ + ProjectId: projectID, + AppId: appID, + KeyId: d.Id(), + }) + if err != nil { + d.SetId("") + return nil + } + d.SetId(resp.GetKey().GetId()) + + set := map[string]interface{}{ + appKeyExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), + appKeyProjectIDVar: projectID, + appKeyAppIDVar: appID, + appKeyOrgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of app key: %v", k, err) + } + } + return nil +} diff --git a/zitadel/v2/application_api.go b/zitadel/v2/application_api.go index 9d373343..e26f4455 100644 --- a/zitadel/v2/application_api.go +++ b/zitadel/v2/application_api.go @@ -55,6 +55,7 @@ func GetApplicationAPI() *schema.Resource { CreateContext: createApplicationAPI, UpdateContext: updateApplicationAPI, ReadContext: readApplicationAPI, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/application_oidc.go b/zitadel/v2/application_oidc.go index b94a358c..7a2bfa28 100644 --- a/zitadel/v2/application_oidc.go +++ b/zitadel/v2/application_oidc.go @@ -158,6 +158,7 @@ func GetApplicationOIDC() *schema.Resource { CreateContext: createApplicationOIDC, UpdateContext: updateApplicationOIDC, ReadContext: readApplicationOIDC, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/domain.go b/zitadel/v2/domain.go index 9c9be240..05049d5c 100644 --- a/zitadel/v2/domain.go +++ b/zitadel/v2/domain.go @@ -54,6 +54,7 @@ func GetDomain() *schema.Resource { ReadContext: readDomain, CreateContext: createDomain, DeleteContext: deleteDomain, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -128,7 +129,9 @@ func readDomain(ctx context.Context, d *schema.ResourceData, m interface{}) diag }, }) if err != nil { - return diag.Errorf("failed to read domain: %v", err) + d.SetId("") + return nil + //return diag.Errorf("failed to read domain: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/domain_policy.go b/zitadel/v2/domain_policy.go index 0cd14f3c..72a8a8c5 100644 --- a/zitadel/v2/domain_policy.go +++ b/zitadel/v2/domain_policy.go @@ -47,6 +47,7 @@ func GetDomainPolicy() *schema.Resource { CreateContext: createDomainPolicy, DeleteContext: deleteDomainPolicy, UpdateContext: updateDomainPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/idp_jwt.go b/zitadel/v2/idp_jwt.go index bc6e3958..5568c7d7 100644 --- a/zitadel/v2/idp_jwt.go +++ b/zitadel/v2/idp_jwt.go @@ -66,6 +66,7 @@ func GetOrgJWTIDP() *schema.Resource { CreateContext: createOrgJWTIDP, UpdateContext: updateOrgJWTIDP, DeleteContext: deleteOrgIDP, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } func createOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_oidc.go b/zitadel/v2/idp_oidc.go index 9fe8773e..1b1235df 100644 --- a/zitadel/v2/idp_oidc.go +++ b/zitadel/v2/idp_oidc.go @@ -87,6 +87,7 @@ func GetOrgOIDCIDP() *schema.Resource { UpdateContext: updateOrgOIDCIDP, CreateContext: createOrgOIDCIDP, DeleteContext: deleteOrgIDP, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/label_policy.go b/zitadel/v2/label_policy.go index 8ac61acc..099aae72 100644 --- a/zitadel/v2/label_policy.go +++ b/zitadel/v2/label_policy.go @@ -124,6 +124,7 @@ func GetLabelPolicy() *schema.Resource { CreateContext: createLabelPolicy, DeleteContext: deleteLabelPolicy, UpdateContext: updateLabelPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/lockout_policy.go b/zitadel/v2/lockout_policy.go index 7643ce8e..2711635a 100644 --- a/zitadel/v2/lockout_policy.go +++ b/zitadel/v2/lockout_policy.go @@ -35,6 +35,7 @@ func GetLockoutPolicy() *schema.Resource { CreateContext: createLockoutPolicy, UpdateContext: updateLockoutPolicy, ReadContext: readLockoutPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go index 6a6c331d..0548bdbf 100644 --- a/zitadel/v2/login_policy.go +++ b/zitadel/v2/login_policy.go @@ -137,6 +137,7 @@ func GetLoginPolicy() *schema.Resource { UpdateContext: updateLoginPolicy, DeleteContext: deleteLoginPolicy, ReadContext: readLoginPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/machine_key.go b/zitadel/v2/machine_key.go index 4353e610..e3105fd1 100644 --- a/zitadel/v2/machine_key.go +++ b/zitadel/v2/machine_key.go @@ -58,6 +58,7 @@ func GetMachineKey() *schema.Resource { DeleteContext: deleteMachineKey, CreateContext: createMachineKey, ReadContext: readMachineKey, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/org.go b/zitadel/v2/org.go index fe34b707..e5e2590d 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - admin2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" ) const ( @@ -23,12 +23,13 @@ func OrgResource() *schema.Resource { Type: schema.TypeString, Required: true, Description: "Name of the org", - ForceNew: true, }, }, CreateContext: createOrg, DeleteContext: deleteOrg, ReadContext: readOrg, + UpdateContext: updateOrg, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -47,44 +48,64 @@ func deleteOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag. func createOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") + clientinfo, ok := m.(*ClientInfo) if !ok { return diag.Errorf("failed to get client") } + client, err := getManagementClient(clientinfo, "") if err != nil { return diag.FromErr(err) } - if errDiag := readOrg(ctx, d, m); errDiag != nil { - return errDiag + resp, err := client.AddOrg(ctx, &management.AddOrgRequest{ + Name: d.Get(nameVar).(string), + }) + if err != nil { + return diag.FromErr(err) } + d.SetId(resp.GetId()) - if d.Id() == "" { - resp, err := client.AddOrg(ctx, &management2.AddOrgRequest{ - Name: d.Get(nameVar).(string), - }) - if err != nil { - return diag.FromErr(err) - } - d.SetId(resp.GetId()) + return nil +} + +func updateOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*ClientInfo) + if !ok { + return diag.Errorf("failed to get client") } + client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateOrg(ctx, &management.UpdateOrgRequest{ + Name: d.Get(nameVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update org: %v", err) + } return nil } func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") + clientinfo, ok := m.(*ClientInfo) if !ok { return diag.Errorf("failed to get client") } + client, err := getAdminClient(clientinfo) if err != nil { return diag.FromErr(err) } - resp, err := client.ListOrgs(ctx, &admin2.ListOrgsRequest{}) + resp, err := client.ListOrgs(ctx, &admin.ListOrgsRequest{}) if err != nil { return diag.Errorf("error while listing orgs: %v", err) } @@ -92,30 +113,26 @@ func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di "orglist": resp.Result, }) - //id := d.Get("id").(string) - name := d.Get(nameVar).(string) + orgID := d.Id() tflog.Debug(ctx, "check if org is existing", map[string]interface{}{ - // "id": id, - "org": name, + "id": orgID, }) for i := range resp.Result { org := resp.Result[i] - - if strings.Compare(org.GetName(), name) == 0 { - d.SetId(org.GetId()) - + if strings.Compare(org.GetId(), orgID) == 0 { + d.SetId(orgID) tflog.Debug(ctx, "found org", map[string]interface{}{ - "id": d.Id(), - "org": name, + "id": orgID, }) + if err := d.Set(nameVar, org.GetName()); err != nil { + return diag.Errorf("failed to set %s of org: %v", nameVar, err) + } return nil } } d.SetId("") - tflog.Debug(ctx, "org not found", map[string]interface{}{ - "org": name, - }) + tflog.Debug(ctx, "org not found", map[string]interface{}{}) return nil } diff --git a/zitadel/v2/org_member.go b/zitadel/v2/org_member.go index d9edd72c..e77997d3 100644 --- a/zitadel/v2/org_member.go +++ b/zitadel/v2/org_member.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" ) const ( @@ -45,6 +46,7 @@ func GetOrgMember() *schema.Resource { CreateContext: createOrgMember, UpdateContext: updateOrgMember, ReadContext: readOrgMember, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -137,30 +139,38 @@ func readOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) d return diag.FromErr(err) } - resp, err := client.ListOrgMembers(ctx, &management2.ListOrgMembersRequest{}) + userID := d.Get(orgMemberUserIDVar).(string) + resp, err := client.ListOrgMembers(ctx, &management2.ListOrgMembersRequest{ + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) if err != nil { d.SetId("") return nil //return diag.Errorf("failed to read orgmember: %v", err) } - userID := d.Get(orgMemberUserIDVar).(string) - for _, orgMember := range resp.Result { - if orgMember.UserId == userID { - set := map[string]interface{}{ - orgMemberUserIDVar: orgMember.GetUserId(), - orgMemberOrgIDVar: orgMember.GetDetails().GetResourceOwner(), - orgMemberRolesVar: orgMember.GetRoles(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of orgmember: %v", k, err) - } + if len(resp.Result) == 1 { + orgMember := resp.Result[0] + set := map[string]interface{}{ + orgMemberUserIDVar: orgMember.GetUserId(), + orgMemberOrgIDVar: orgMember.GetDetails().GetResourceOwner(), + orgMemberRolesVar: orgMember.GetRoles(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of orgmember: %v", k, err) } - d.SetId(getOrgMemberID(org, userID)) - return nil } + d.SetId(getOrgMemberID(org, userID)) + return nil } + d.SetId("") return nil } diff --git a/zitadel/v2/password_complexity_policy.go b/zitadel/v2/password_complexity_policy.go index 9da5a66a..942fdbbc 100644 --- a/zitadel/v2/password_complexity_policy.go +++ b/zitadel/v2/password_complexity_policy.go @@ -58,6 +58,7 @@ func GetPasswordComplexityPolicy() *schema.Resource { ReadContext: readPasswordComplexityPolicy, CreateContext: createPasswordComplexityPolicy, UpdateContext: updatePasswordComplexityPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/pat.go b/zitadel/v2/pat.go index ead39087..568d5f6d 100644 --- a/zitadel/v2/pat.go +++ b/zitadel/v2/pat.go @@ -50,6 +50,7 @@ func GetPAT() *schema.Resource { DeleteContext: deletePAT, CreateContext: createPAT, ReadContext: readPAT, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/privacy_policy.go b/zitadel/v2/privacy_policy.go index 8d7dec45..edbe6107 100644 --- a/zitadel/v2/privacy_policy.go +++ b/zitadel/v2/privacy_policy.go @@ -46,6 +46,7 @@ func GetPrivacyPolicy() *schema.Resource { DeleteContext: deletePrivacyPolicy, ReadContext: readPrivacyPolicy, UpdateContext: updatePrivacyPolicy, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/project.go b/zitadel/v2/project.go index d7cb9cf5..c9d291c5 100644 --- a/zitadel/v2/project.go +++ b/zitadel/v2/project.go @@ -71,6 +71,7 @@ func GetProject() *schema.Resource { CreateContext: createProject, UpdateContext: updateProject, ReadContext: readProject, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/project_grant.go b/zitadel/v2/project_grant.go index c328dd5f..b20b3331 100644 --- a/zitadel/v2/project_grant.go +++ b/zitadel/v2/project_grant.go @@ -50,6 +50,7 @@ func GetProjectGrant() *schema.Resource { CreateContext: createProjectGrant, UpdateContext: updateProjectGrant, ReadContext: readProjectGrant, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/project_grant_member.go b/zitadel/v2/project_grant_member.go index 100230ee..68130516 100644 --- a/zitadel/v2/project_grant_member.go +++ b/zitadel/v2/project_grant_member.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" ) const ( @@ -58,6 +59,7 @@ func GetProjectGrantMember() *schema.Resource { CreateContext: createProjectGrantMember, UpdateContext: updateProjectGrantMember, ReadContext: readProjectGrantMember, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -159,32 +161,42 @@ func readProjectGrantMember(ctx context.Context, d *schema.ResourceData, m inter projectID := d.Get(projectGrantMemberProjectIDVar).(string) grantID := d.Get(projectGrantMemberGrantIDVar).(string) - resp, err := client.ListProjectGrantMembers(ctx, &management2.ListProjectGrantMembersRequest{ProjectId: projectID, GrantId: grantID}) + userID := d.Get(projectGrantMemberUserIDVar).(string) + resp, err := client.ListProjectGrantMembers(ctx, &management2.ListProjectGrantMembersRequest{ + ProjectId: projectID, + GrantId: grantID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) if err != nil { d.SetId("") return nil //return diag.Errorf("failed to read projectgrantmember: %v", err) } - userID := d.Get(projectGrantMemberUserIDVar).(string) - for _, member := range resp.Result { - if member.UserId == userID { - set := map[string]interface{}{ - projectGrantMemberUserIDVar: member.GetUserId(), - projectGrantMemberOrgIDVar: member.GetDetails().GetResourceOwner(), - projectGrantMemberProjectIDVar: projectID, - projectGrantMemberRolesVar: member.GetRoles(), - projectGrantMemberGrantIDVar: grantID, - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectgrantmember: %v", k, err) - } + if len(resp.Result) == 1 { + memberRes := resp.Result[0] + set := map[string]interface{}{ + projectGrantMemberUserIDVar: userID, + projectGrantMemberOrgIDVar: memberRes.GetDetails().GetResourceOwner(), + projectGrantMemberProjectIDVar: projectID, + projectGrantMemberRolesVar: memberRes.GetRoles(), + projectGrantMemberGrantIDVar: grantID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of projectgrantmember: %v", k, err) } - d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) - return nil } + d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) + return nil } + d.SetId("") return nil } diff --git a/zitadel/v2/project_member.go b/zitadel/v2/project_member.go index e05eab74..6b471782 100644 --- a/zitadel/v2/project_member.go +++ b/zitadel/v2/project_member.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" ) const ( @@ -51,6 +52,7 @@ func GetProjectMember() *schema.Resource { CreateContext: createProjectMember, UpdateContext: updateProjectMember, ReadContext: readProjectMember, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -148,31 +150,40 @@ func readProjectMember(ctx context.Context, d *schema.ResourceData, m interface{ } projectID := d.Get(projectMemberProjectIDVar).(string) - resp, err := client.ListProjectMembers(ctx, &management2.ListProjectMembersRequest{ProjectId: projectID}) + userID := d.Get(projectMemberUserIDVar).(string) + resp, err := client.ListProjectMembers(ctx, &management2.ListProjectMembersRequest{ + ProjectId: projectID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) if err != nil { d.SetId("") return nil //return diag.Errorf("failed to read projectmember: %v", err) } - userID := d.Get(projectMemberUserIDVar).(string) - for _, member := range resp.Result { - if member.UserId == userID { - set := map[string]interface{}{ - projectMemberUserIDVar: member.GetUserId(), - projectMemberOrgIDVar: member.GetDetails().GetResourceOwner(), - projectMemberProjectIDVar: projectID, - projectMemberRolesVar: member.GetRoles(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectmember: %v", k, err) - } + if len(resp.Result) == 1 { + memberRes := resp.Result[0] + set := map[string]interface{}{ + projectMemberUserIDVar: memberRes.GetUserId(), + projectMemberOrgIDVar: memberRes.GetDetails().GetResourceOwner(), + projectMemberProjectIDVar: projectID, + projectMemberRolesVar: memberRes.GetRoles(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of projectmember: %v", k, err) } - d.SetId(getProjectMemberID(org, projectID, userID)) - return nil } + d.SetId(getProjectMemberID(org, projectID, userID)) + return nil } + d.SetId("") return nil } diff --git a/zitadel/v2/project_role.go b/zitadel/v2/project_role.go index 9ee219b3..a70feb6a 100644 --- a/zitadel/v2/project_role.go +++ b/zitadel/v2/project_role.go @@ -55,6 +55,7 @@ func GetProjectRole() *schema.Resource { CreateContext: createProjectRole, UpdateContext: updateProjectRole, ReadContext: readProjectRole, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -145,13 +146,15 @@ func readProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(projectRoleOrgID).(string)) + orgID := d.Get(projectRoleOrgID).(string) + client, err := getManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) } + projectID := d.Get(projectRoleProjectID).(string) resp, err := client.ListProjectRoles(ctx, &management2.ListProjectRolesRequest{ - ProjectId: d.Get(projectRoleProjectID).(string), + ProjectId: projectID, Queries: []*project2.RoleQuery{ {Query: &project2.RoleQuery_KeyQuery{ KeyQuery: &project2.RoleKeyQuery{ @@ -168,8 +171,6 @@ func readProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) } if len(resp.Result) == 1 { - projectID := d.Get(projectRoleProjectID).(string) - orgID := d.Get(projectRoleOrgID).(string) projectRole := resp.GetResult()[0] roleKey := projectRole.GetKey() set := map[string]interface{}{ diff --git a/zitadel/v2/trigger_actions.go b/zitadel/v2/trigger_actions.go index f543b0c5..de71c6d1 100644 --- a/zitadel/v2/trigger_actions.go +++ b/zitadel/v2/trigger_actions.go @@ -52,6 +52,7 @@ func GetTriggerActions() *schema.Resource { CreateContext: createTriggerActions, UpdateContext: updateTriggerActions, ReadContext: readTriggerActions, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/user.go b/zitadel/v2/user.go index 17b04520..57c9aa7a 100644 --- a/zitadel/v2/user.go +++ b/zitadel/v2/user.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" @@ -34,8 +35,15 @@ const ( descriptionVar = "description" initialPasswordVar = "initial_password" + + defaultGenderString = "GENDER_UNSPECIFIED" + defaultPreferredLanguage = "und" ) +func defaultDisplayName(firstName, lastName string) string { + return firstName + " " + lastName +} + func GetHumanUser() *schema.Resource { return &schema.Resource{ Description: "Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", @@ -90,17 +98,20 @@ func GetHumanUser() *schema.Resource { displayNameVar: { Type: schema.TypeString, Optional: true, - Description: "DIsplay name of the user", + Description: "Display name of the user", + Computed: true, }, preferredLanguageVar: { Type: schema.TypeString, Optional: true, Description: "Preferred language of the user", + Computed: true, }, genderVar: { Type: schema.TypeString, Optional: true, Description: "Gender of the user", + Computed: true, }, emailVar: { Type: schema.TypeString, @@ -110,7 +121,7 @@ func GetHumanUser() *schema.Resource { isEmailVerifiedVar: { Type: schema.TypeBool, Optional: true, - Description: "Is the email verified of the user", + Description: "Is the email verified of the user, can only be true if password of the user is set", }, phoneVar: { Type: schema.TypeString, @@ -125,13 +136,41 @@ func GetHumanUser() *schema.Resource { initialPasswordVar: { Type: schema.TypeString, Optional: true, - Description: "Initially set password for the user", + Description: "Initially set password for the user, not changeable after creation", + Sensitive: true, }, }, ReadContext: readHumanUser, CreateContext: createHumanUser, DeleteContext: deleteUser, UpdateContext: updateHumanUser, + CustomizeDiff: customdiff.All( + customdiff.IfValue(displayNameVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(displayNameVar, defaultDisplayName(diff.Get(firstNameVar).(string), diff.Get(lastNameVar).(string))) + }), + customdiff.IfValue(genderVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(genderVar, defaultGenderString) + }), + customdiff.IfValue(preferredLanguageVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(preferredLanguageVar, defaultPreferredLanguage) + }), + ), + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -184,6 +223,7 @@ func GetMachineUser() *schema.Resource { CreateContext: createMachineUser, DeleteContext: deleteUser, UpdateContext: updateMachineUser, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } @@ -222,11 +262,13 @@ func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } + firstName := d.Get(firstNameVar).(string) + lastName := d.Get(lastNameVar).(string) addUser := &management2.AddHumanUserRequest{ UserName: d.Get(userNameVar).(string), Profile: &management2.AddHumanUserRequest_Profile{ - FirstName: d.Get(firstNameVar).(string), - LastName: d.Get(lastNameVar).(string), + FirstName: firstName, + LastName: lastName, }, } @@ -234,19 +276,37 @@ func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) if nickname != "" { addUser.Profile.NickName = nickname } + displayname := d.Get(displayNameVar).(string) if displayname != "" { addUser.Profile.DisplayName = displayname + } else { + if err := d.Set(displayNameVar, defaultDisplayName(firstName, lastName)); err != nil { + return diag.Errorf("failed to set default display name for human user: %v", err) + } } prefLang := d.Get(preferredLanguageVar).(string) if prefLang != "" { addUser.Profile.PreferredLanguage = prefLang + } else { + if err := d.Set(preferredLanguageVar, defaultPreferredLanguage); err != nil { + return diag.Errorf("failed to set default preferred language for human user: %v", err) + } } gender := d.Get(genderVar).(string) if gender != "" { addUser.Profile.Gender = user.Gender(user.Gender_value[gender]) + } else { + if err := d.Set(genderVar, defaultGenderString); err != nil { + return diag.Errorf("failed to set default gender for human user: %v", err) + } + } + + pwd := d.Get(initialPasswordVar).(string) + if pwd != "" { + addUser.InitialPassword = pwd } email := d.Get(emailVar).(string) diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant.go index 7e7449a5..b6ec4d6a 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant.go @@ -59,6 +59,7 @@ func GetUserGrant() *schema.Resource { CreateContext: createUserGrant, UpdateContext: updateUserGrant, ReadContext: readUserGrant, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } From 2bbe7a154219e7588553f726578bbe08b5a1e0e2 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 2 Sep 2022 09:12:07 +0200 Subject: [PATCH 012/260] fix: refactor of package structure, added datasources and fixes for read logic --- .gitignore | 2 + docs/data-sources/action.md | 42 ++ docs/data-sources/application_api.md | 41 ++ docs/data-sources/application_oidc.md | 54 ++ docs/data-sources/human_user.md | 51 ++ docs/data-sources/machine_user.md | 43 ++ docs/data-sources/org.md | 34 + docs/data-sources/org_jwt_idp.md | 44 ++ docs/data-sources/org_oidc_idp.md | 46 ++ docs/data-sources/project.md | 43 ++ docs/data-sources/project_role.md | 41 ++ docs/data-sources/trigger_actions.md | 40 ++ docs/index.md | 2 +- docs/resources/action.md | 1 - docs/resources/human_user.md | 2 +- docs/resources/org_oidc_idp.md | 24 +- docs/resources/project.md | 2 +- examples/provider/data-sources/action.tf | 10 + .../provider/data-sources/application_api.tf | 11 + .../provider/data-sources/application_oidc.tf | 11 + examples/provider/data-sources/human_user.tf | 10 + .../provider/data-sources/machine_user.tf | 10 + examples/provider/data-sources/org.tf | 7 + examples/provider/data-sources/org_jwt_idp.tf | 10 + .../provider/data-sources/org_oidc_idp.tf | 10 + examples/provider/data-sources/project.tf | 10 + .../provider/data-sources/project_role.tf | 11 + .../provider/data-sources/trigger_actions.tf | 11 + examples/provider/provider.tf | 2 +- examples/provider/{ => resources}/action.tf | 1 - examples/provider/{ => resources}/app_key.tf | 0 .../{ => resources}/application_api.tf | 0 .../{ => resources}/application_oidc.tf | 0 examples/provider/{ => resources}/domain.tf | 0 .../provider/{ => resources}/domain_policy.tf | 0 .../{ => resources}/granted_human_user.tf | 0 .../provider/{ => resources}/granted_org.tf | 0 .../provider/{ => resources}/human_user.tf | 0 .../provider/{ => resources}/label_policy.tf | 0 .../{ => resources}/lockout_policy.tf | 0 .../provider/{ => resources}/login_policy.tf | 0 .../provider/{ => resources}/machine_key.tf | 0 .../provider/{ => resources}/machine_user.tf | 0 examples/provider/{ => resources}/org.tf | 0 .../provider/{ => resources}/org_jwt_idp.tf | 0 .../provider/{ => resources}/org_member.tf | 0 .../provider/{ => resources}/org_oidc_idp.tf | 0 .../password_complexity_policy.tf | 0 .../{ => resources}/personal_access_token.tf | 0 .../{ => resources}/privacy_policy.tf | 0 examples/provider/{ => resources}/project.tf | 0 .../provider/{ => resources}/project_grant.tf | 0 .../{ => resources}/project_grant_member.tf | 0 .../{ => resources}/project_member.tf | 0 .../provider/{ => resources}/project_role.tf | 0 .../{ => resources}/trigger_actions.tf | 0 .../provider/{ => resources}/user_grant.tf | 0 templates/data-sources/action.md.tmpl | 16 + .../data-sources/application_api.md.tmpl | 16 + .../data-sources/application_oidc.md.tmpl | 16 + templates/data-sources/human_user.md.tmpl | 16 + templates/data-sources/machine_user.md.tmpl | 16 + templates/data-sources/org.md.tmpl | 16 + templates/data-sources/org_jwt_idp.md.tmpl | 16 + templates/data-sources/org_oidc_idp.md.tmpl | 16 + templates/data-sources/project.md.tmpl | 16 + templates/data-sources/project_role.md.tmpl | 16 + .../data-sources/trigger_actions.md.tmpl | 16 + templates/resources/action.md.tmpl | 2 +- templates/resources/application_api.md.tmpl | 2 +- templates/resources/application_key.md.tmpl | 2 +- templates/resources/application_oidc.md.tmpl | 2 +- templates/resources/domain.md.tmpl | 2 +- templates/resources/domain_policy.md.tmpl | 2 +- templates/resources/human_user.md.tmpl | 2 +- templates/resources/label_policy.md.tmpl | 2 +- templates/resources/lockout_policy.md.tmpl | 2 +- templates/resources/login_policy.md.tmpl | 2 +- templates/resources/machine_key.md.tmpl | 2 +- templates/resources/machine_user.md.tmpl | 2 +- templates/resources/org.md.tmpl | 2 +- templates/resources/org_jwt_idp.md.tmpl | 2 +- templates/resources/org_member.md.tmpl | 2 +- templates/resources/org_oidc_idp.md.tmpl | 2 +- .../password_complexity_policy.md.tmpl | 2 +- .../resources/personal_access_token.md.tmpl | 2 +- templates/resources/privacy_policy.md.tmpl | 2 +- templates/resources/project.md.tmpl | 2 +- templates/resources/project_grant.md.tmpl | 2 +- .../resources/project_grant_member.md.tmpl | 2 +- templates/resources/project_member.md.tmpl | 2 +- templates/resources/project_role.md.tmpl | 2 +- templates/resources/trigger_actions.md.tmpl | 2 +- templates/resources/user_grant.md.tmpl | 2 +- zitadel/provider.go | 104 ++- zitadel/v2/action.go | 201 ------ zitadel/v2/action/const.go | 11 + zitadel/v2/action/datasource.go | 49 ++ zitadel/v2/action/funcs.go | 150 +++++ zitadel/v2/action/resource.go | 53 ++ zitadel/v2/app_key.go | 169 ----- zitadel/v2/app_key/const.go | 10 + zitadel/v2/app_key/funcs.go | 114 ++++ zitadel/v2/app_key/resource.go | 61 ++ zitadel/v2/application_api.go | 206 ------ zitadel/v2/application_api/const.go | 11 + zitadel/v2/application_api/datasource.go | 40 ++ zitadel/v2/application_api/funcs.go | 161 +++++ zitadel/v2/application_api/resource.go | 60 ++ zitadel/v2/application_oidc.go | 409 ------------ zitadel/v2/application_oidc/const.go | 24 + zitadel/v2/application_oidc/datasource.go | 120 ++++ zitadel/v2/application_oidc/funcs.go | 276 ++++++++ zitadel/v2/application_oidc/resource.go | 154 +++++ zitadel/v2/domain.go | 157 ----- zitadel/v2/domain/const.go | 9 + zitadel/v2/domain/funcs.go | 112 ++++ zitadel/v2/domain/resource.go | 44 ++ zitadel/v2/domain_policy.go | 170 ----- zitadel/v2/domain_policy/const.go | 8 + zitadel/v2/domain_policy/funcs.go | 131 ++++ zitadel/v2/domain_policy/resource.go | 39 ++ zitadel/v2/helper.go | 54 -- zitadel/v2/{ => helper}/client.go | 6 +- zitadel/v2/helper/helper.go | 96 +++ zitadel/v2/human_user/const.go | 28 + zitadel/v2/human_user/datasource.go | 98 +++ zitadel/v2/human_user/funcs.go | 274 ++++++++ zitadel/v2/human_user/resource.go | 150 +++++ zitadel/v2/idp_jwt.go | 203 ------ zitadel/v2/idp_jwt/const.go | 13 + zitadel/v2/idp_jwt/datasource.go | 60 ++ zitadel/v2/idp_jwt/funcs.go | 168 +++++ zitadel/v2/idp_jwt/resource.go | 67 ++ zitadel/v2/idp_oidc.go | 275 -------- zitadel/v2/idp_oidc/const.go | 15 + zitadel/v2/idp_oidc/datasource.go | 75 +++ zitadel/v2/idp_oidc/funcs.go | 197 ++++++ zitadel/v2/idp_oidc/resource.go | 82 +++ zitadel/v2/label_policy.go | 289 --------- zitadel/v2/label_policy/const.go | 21 + zitadel/v2/label_policy/funcs.go | 172 +++++ zitadel/v2/label_policy/resource.go | 104 +++ zitadel/v2/lockout_policy.go | 149 ----- zitadel/v2/lockout_policy/const.go | 6 + zitadel/v2/lockout_policy/funcs.go | 121 ++++ zitadel/v2/lockout_policy/resource.go | 30 + zitadel/v2/login_policy.go | 432 ------------- zitadel/v2/login_policy/const.go | 21 + zitadel/v2/login_policy/funcs.go | 306 +++++++++ zitadel/v2/login_policy/resource.go | 113 ++++ zitadel/v2/machine_key.go | 157 ----- zitadel/v2/machine_key/const.go | 9 + zitadel/v2/machine_key/funcs.go | 109 ++++ zitadel/v2/machine_key/resource.go | 55 ++ zitadel/v2/machine_user/const.go | 13 + zitadel/v2/machine_user/datasource.go | 57 ++ zitadel/v2/machine_user/funcs.go | 144 +++++ zitadel/v2/machine_user/resource.go | 62 ++ zitadel/v2/org/const.go | 6 + zitadel/v2/org/datasource.go | 23 + zitadel/v2/{org.go => org/funcs.go} | 48 +- zitadel/v2/org/resource.go | 23 + zitadel/v2/org_member.go | 185 ------ zitadel/v2/org_member/const.go | 7 + zitadel/v2/org_member/funcs.go | 148 +++++ zitadel/v2/org_member/resource.go | 38 ++ zitadel/v2/password_complexity_policy.go | 184 ------ .../v2/password_complexity_policy/const.go | 10 + .../v2/password_complexity_policy/funcs.go | 133 ++++ .../v2/password_complexity_policy/resource.go | 49 ++ zitadel/v2/pat.go | 146 ----- zitadel/v2/pat/const.go | 8 + zitadel/v2/pat/funcs.go | 105 ++++ zitadel/v2/pat/resource.go | 41 ++ zitadel/v2/privacy_policy.go | 166 ----- zitadel/v2/privacy_policy/const.go | 8 + zitadel/v2/privacy_policy/funcs.go | 127 ++++ zitadel/v2/privacy_policy/resource.go | 39 ++ zitadel/v2/project.go | 196 ------ zitadel/v2/project/const.go | 12 + zitadel/v2/project/datasource.go | 55 ++ zitadel/v2/project/funcs.go | 132 ++++ zitadel/v2/project/resource.go | 65 ++ zitadel/v2/project_grant.go | 168 ----- zitadel/v2/project_grant/const.go | 8 + zitadel/v2/project_grant/funcs.go | 125 ++++ zitadel/v2/project_grant/resource.go | 43 ++ zitadel/v2/project_grant_member.go | 206 ------ zitadel/v2/project_grant_member/const.go | 9 + zitadel/v2/project_grant_member/funcs.go | 155 +++++ zitadel/v2/project_grant_member/resource.go | 50 ++ zitadel/v2/project_member.go | 193 ------ zitadel/v2/project_member/const.go | 8 + zitadel/v2/project_member/funcs.go | 149 +++++ zitadel/v2/project_member/resource.go | 44 ++ zitadel/v2/project_role.go | 198 ------ zitadel/v2/project_role/const.go | 9 + zitadel/v2/project_role/datasource.go | 38 ++ zitadel/v2/project_role/funcs.go | 152 +++++ zitadel/v2/project_role/resource.go | 45 ++ zitadel/v2/trigger_actions.go | 156 ----- zitadel/v2/trigger_actions/const.go | 8 + zitadel/v2/trigger_actions/datasource.go | 39 ++ zitadel/v2/trigger_actions/funcs.go | 112 ++++ zitadel/v2/trigger_actions/resource.go | 55 ++ zitadel/v2/user.go | 595 ------------------ zitadel/v2/user_grant/const.go | 9 + .../v2/{user_grant.go => user_grant/funcs.go} | 89 +-- zitadel/v2/user_grant/resource.go | 50 ++ 210 files changed, 7358 insertions(+), 5447 deletions(-) create mode 100644 docs/data-sources/action.md create mode 100644 docs/data-sources/application_api.md create mode 100644 docs/data-sources/application_oidc.md create mode 100644 docs/data-sources/human_user.md create mode 100644 docs/data-sources/machine_user.md create mode 100644 docs/data-sources/org.md create mode 100644 docs/data-sources/org_jwt_idp.md create mode 100644 docs/data-sources/org_oidc_idp.md create mode 100644 docs/data-sources/project.md create mode 100644 docs/data-sources/project_role.md create mode 100644 docs/data-sources/trigger_actions.md create mode 100644 examples/provider/data-sources/action.tf create mode 100644 examples/provider/data-sources/application_api.tf create mode 100644 examples/provider/data-sources/application_oidc.tf create mode 100644 examples/provider/data-sources/human_user.tf create mode 100644 examples/provider/data-sources/machine_user.tf create mode 100644 examples/provider/data-sources/org.tf create mode 100644 examples/provider/data-sources/org_jwt_idp.tf create mode 100644 examples/provider/data-sources/org_oidc_idp.tf create mode 100644 examples/provider/data-sources/project.tf create mode 100644 examples/provider/data-sources/project_role.tf create mode 100644 examples/provider/data-sources/trigger_actions.tf rename examples/provider/{ => resources}/action.tf (90%) rename examples/provider/{ => resources}/app_key.tf (100%) rename examples/provider/{ => resources}/application_api.tf (100%) rename examples/provider/{ => resources}/application_oidc.tf (100%) rename examples/provider/{ => resources}/domain.tf (100%) rename examples/provider/{ => resources}/domain_policy.tf (100%) rename examples/provider/{ => resources}/granted_human_user.tf (100%) rename examples/provider/{ => resources}/granted_org.tf (100%) rename examples/provider/{ => resources}/human_user.tf (100%) rename examples/provider/{ => resources}/label_policy.tf (100%) rename examples/provider/{ => resources}/lockout_policy.tf (100%) rename examples/provider/{ => resources}/login_policy.tf (100%) rename examples/provider/{ => resources}/machine_key.tf (100%) rename examples/provider/{ => resources}/machine_user.tf (100%) rename examples/provider/{ => resources}/org.tf (100%) rename examples/provider/{ => resources}/org_jwt_idp.tf (100%) rename examples/provider/{ => resources}/org_member.tf (100%) rename examples/provider/{ => resources}/org_oidc_idp.tf (100%) rename examples/provider/{ => resources}/password_complexity_policy.tf (100%) rename examples/provider/{ => resources}/personal_access_token.tf (100%) rename examples/provider/{ => resources}/privacy_policy.tf (100%) rename examples/provider/{ => resources}/project.tf (100%) rename examples/provider/{ => resources}/project_grant.tf (100%) rename examples/provider/{ => resources}/project_grant_member.tf (100%) rename examples/provider/{ => resources}/project_member.tf (100%) rename examples/provider/{ => resources}/project_role.tf (100%) rename examples/provider/{ => resources}/trigger_actions.tf (100%) rename examples/provider/{ => resources}/user_grant.tf (100%) create mode 100644 templates/data-sources/action.md.tmpl create mode 100644 templates/data-sources/application_api.md.tmpl create mode 100644 templates/data-sources/application_oidc.md.tmpl create mode 100644 templates/data-sources/human_user.md.tmpl create mode 100644 templates/data-sources/machine_user.md.tmpl create mode 100644 templates/data-sources/org.md.tmpl create mode 100644 templates/data-sources/org_jwt_idp.md.tmpl create mode 100644 templates/data-sources/org_oidc_idp.md.tmpl create mode 100644 templates/data-sources/project.md.tmpl create mode 100644 templates/data-sources/project_role.md.tmpl create mode 100644 templates/data-sources/trigger_actions.md.tmpl delete mode 100644 zitadel/v2/action.go create mode 100644 zitadel/v2/action/const.go create mode 100644 zitadel/v2/action/datasource.go create mode 100644 zitadel/v2/action/funcs.go create mode 100644 zitadel/v2/action/resource.go delete mode 100644 zitadel/v2/app_key.go create mode 100644 zitadel/v2/app_key/const.go create mode 100644 zitadel/v2/app_key/funcs.go create mode 100644 zitadel/v2/app_key/resource.go delete mode 100644 zitadel/v2/application_api.go create mode 100644 zitadel/v2/application_api/const.go create mode 100644 zitadel/v2/application_api/datasource.go create mode 100644 zitadel/v2/application_api/funcs.go create mode 100644 zitadel/v2/application_api/resource.go delete mode 100644 zitadel/v2/application_oidc.go create mode 100644 zitadel/v2/application_oidc/const.go create mode 100644 zitadel/v2/application_oidc/datasource.go create mode 100644 zitadel/v2/application_oidc/funcs.go create mode 100644 zitadel/v2/application_oidc/resource.go delete mode 100644 zitadel/v2/domain.go create mode 100644 zitadel/v2/domain/const.go create mode 100644 zitadel/v2/domain/funcs.go create mode 100644 zitadel/v2/domain/resource.go delete mode 100644 zitadel/v2/domain_policy.go create mode 100644 zitadel/v2/domain_policy/const.go create mode 100644 zitadel/v2/domain_policy/funcs.go create mode 100644 zitadel/v2/domain_policy/resource.go delete mode 100644 zitadel/v2/helper.go rename zitadel/v2/{ => helper}/client.go (93%) create mode 100644 zitadel/v2/helper/helper.go create mode 100644 zitadel/v2/human_user/const.go create mode 100644 zitadel/v2/human_user/datasource.go create mode 100644 zitadel/v2/human_user/funcs.go create mode 100644 zitadel/v2/human_user/resource.go delete mode 100644 zitadel/v2/idp_jwt.go create mode 100644 zitadel/v2/idp_jwt/const.go create mode 100644 zitadel/v2/idp_jwt/datasource.go create mode 100644 zitadel/v2/idp_jwt/funcs.go create mode 100644 zitadel/v2/idp_jwt/resource.go delete mode 100644 zitadel/v2/idp_oidc.go create mode 100644 zitadel/v2/idp_oidc/const.go create mode 100644 zitadel/v2/idp_oidc/datasource.go create mode 100644 zitadel/v2/idp_oidc/funcs.go create mode 100644 zitadel/v2/idp_oidc/resource.go delete mode 100644 zitadel/v2/label_policy.go create mode 100644 zitadel/v2/label_policy/const.go create mode 100644 zitadel/v2/label_policy/funcs.go create mode 100644 zitadel/v2/label_policy/resource.go delete mode 100644 zitadel/v2/lockout_policy.go create mode 100644 zitadel/v2/lockout_policy/const.go create mode 100644 zitadel/v2/lockout_policy/funcs.go create mode 100644 zitadel/v2/lockout_policy/resource.go delete mode 100644 zitadel/v2/login_policy.go create mode 100644 zitadel/v2/login_policy/const.go create mode 100644 zitadel/v2/login_policy/funcs.go create mode 100644 zitadel/v2/login_policy/resource.go delete mode 100644 zitadel/v2/machine_key.go create mode 100644 zitadel/v2/machine_key/const.go create mode 100644 zitadel/v2/machine_key/funcs.go create mode 100644 zitadel/v2/machine_key/resource.go create mode 100644 zitadel/v2/machine_user/const.go create mode 100644 zitadel/v2/machine_user/datasource.go create mode 100644 zitadel/v2/machine_user/funcs.go create mode 100644 zitadel/v2/machine_user/resource.go create mode 100644 zitadel/v2/org/const.go create mode 100644 zitadel/v2/org/datasource.go rename zitadel/v2/{org.go => org/funcs.go} (58%) create mode 100644 zitadel/v2/org/resource.go delete mode 100644 zitadel/v2/org_member.go create mode 100644 zitadel/v2/org_member/const.go create mode 100644 zitadel/v2/org_member/funcs.go create mode 100644 zitadel/v2/org_member/resource.go delete mode 100644 zitadel/v2/password_complexity_policy.go create mode 100644 zitadel/v2/password_complexity_policy/const.go create mode 100644 zitadel/v2/password_complexity_policy/funcs.go create mode 100644 zitadel/v2/password_complexity_policy/resource.go delete mode 100644 zitadel/v2/pat.go create mode 100644 zitadel/v2/pat/const.go create mode 100644 zitadel/v2/pat/funcs.go create mode 100644 zitadel/v2/pat/resource.go delete mode 100644 zitadel/v2/privacy_policy.go create mode 100644 zitadel/v2/privacy_policy/const.go create mode 100644 zitadel/v2/privacy_policy/funcs.go create mode 100644 zitadel/v2/privacy_policy/resource.go delete mode 100644 zitadel/v2/project.go create mode 100644 zitadel/v2/project/const.go create mode 100644 zitadel/v2/project/datasource.go create mode 100644 zitadel/v2/project/funcs.go create mode 100644 zitadel/v2/project/resource.go delete mode 100644 zitadel/v2/project_grant.go create mode 100644 zitadel/v2/project_grant/const.go create mode 100644 zitadel/v2/project_grant/funcs.go create mode 100644 zitadel/v2/project_grant/resource.go delete mode 100644 zitadel/v2/project_grant_member.go create mode 100644 zitadel/v2/project_grant_member/const.go create mode 100644 zitadel/v2/project_grant_member/funcs.go create mode 100644 zitadel/v2/project_grant_member/resource.go delete mode 100644 zitadel/v2/project_member.go create mode 100644 zitadel/v2/project_member/const.go create mode 100644 zitadel/v2/project_member/funcs.go create mode 100644 zitadel/v2/project_member/resource.go delete mode 100644 zitadel/v2/project_role.go create mode 100644 zitadel/v2/project_role/const.go create mode 100644 zitadel/v2/project_role/datasource.go create mode 100644 zitadel/v2/project_role/funcs.go create mode 100644 zitadel/v2/project_role/resource.go delete mode 100644 zitadel/v2/trigger_actions.go create mode 100644 zitadel/v2/trigger_actions/const.go create mode 100644 zitadel/v2/trigger_actions/datasource.go create mode 100644 zitadel/v2/trigger_actions/funcs.go create mode 100644 zitadel/v2/trigger_actions/resource.go delete mode 100644 zitadel/v2/user.go create mode 100644 zitadel/v2/user_grant/const.go rename zitadel/v2/{user_grant.go => user_grant/funcs.go} (54%) create mode 100644 zitadel/v2/user_grant/resource.go diff --git a/.gitignore b/.gitignore index 7a3e2fd0..35da205c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* + +/test \ No newline at end of file diff --git a/docs/data-sources/action.md b/docs/data-sources/action.md new file mode 100644 index 00000000..d198d94f --- /dev/null +++ b/docs/data-sources/action.md @@ -0,0 +1,42 @@ +--- +page_title: "zitadel_action Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an action belonging to an organization. +--- + +# zitadel_action (Data Source) + +Datasource representing an action belonging to an organization. + +## Example Usage + +```terraform +data zitadel_action action { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + action_id = "177073621691269123" +} + +output action { + value = data.zitadel_action.action +} +``` + + +## Schema + +### Required + +- `action_id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `allowed_to_fail` (Boolean) when true, the next action will be called even if this action fails +- `id` (String) The ID of this resource. +- `name` (String) +- `script` (String) +- `state` (Number) the state of the action +- `timeout` (String) after which time the action will be terminated if not finished \ No newline at end of file diff --git a/docs/data-sources/application_api.md b/docs/data-sources/application_api.md new file mode 100644 index 00000000..1094a12b --- /dev/null +++ b/docs/data-sources/application_api.md @@ -0,0 +1,41 @@ +--- +page_title: "zitadel_application_api Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an API application belonging to a project, with all configuration possibilities. +--- + +# zitadel_application_api (Data Source) + +Datasource representing an API application belonging to a project, with all configuration possibilities. + +## Example Usage + +```terraform +data zitadel_application_api api_application { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + app_id = "177073625566806019" +} + +output api_application { + value = data.zitadel_application_api.api_application +} +``` + + +## Schema + +### Required + +- `app_id` (String) The ID of this resource. +- `org_id` (String) orgID of the application +- `project_id` (String) ID of the project + +### Read-Only + +- `auth_method_type` (String) Auth method type +- `id` (String) The ID of this resource. +- `name` (String) Name of the application \ No newline at end of file diff --git a/docs/data-sources/application_oidc.md b/docs/data-sources/application_oidc.md new file mode 100644 index 00000000..1d014e95 --- /dev/null +++ b/docs/data-sources/application_oidc.md @@ -0,0 +1,54 @@ +--- +page_title: "zitadel_application_oidc Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an OIDC application belonging to a project, with all configuration possibilities. +--- + +# zitadel_application_oidc (Data Source) + +Datasource representing an OIDC application belonging to a project, with all configuration possibilities. + +## Example Usage + +```terraform +data zitadel_application_oidc oidc_application { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + app_id = "177073626925760515" +} + +output oidc_application { + value = data.zitadel_application_oidc.oidc_application +} +``` + + +## Schema + +### Required + +- `app_id` (String) The ID of this resource. +- `org_id` (String) orgID of the application +- `project_id` (String) ID of the project + +### Read-Only + +- `access_token_role_assertion` (Boolean) Access token role assertion +- `access_token_type` (String) Access token type +- `additional_origins` (List of String) Additional origins +- `app_type` (String) App type +- `auth_method_type` (String) Auth method type +- `clock_skew` (String) Clockskew +- `dev_mode` (Boolean) Dev mode +- `grant_types` (List of String) Grant types +- `id` (String) The ID of this resource. +- `id_token_role_assertion` (Boolean) ID token role assertion +- `id_token_userinfo_assertion` (Boolean) Token userinfo assertion +- `name` (String) Name of the application +- `post_logout_redirect_uris` (List of String) Post logout redirect URIs +- `redirect_uris` (List of String) RedirectURIs +- `response_types` (List of String) Response type +- `version` (String) Version \ No newline at end of file diff --git a/docs/data-sources/human_user.md b/docs/data-sources/human_user.md new file mode 100644 index 00000000..314b3ff0 --- /dev/null +++ b/docs/data-sources/human_user.md @@ -0,0 +1,51 @@ +--- +page_title: "zitadel_human_user Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources. +--- + +# zitadel_human_user (Data Source) + +Datasource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources. + +## Example Usage + +```terraform +data zitadel_human_user human_user { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + user_id = "177073614158299139" +} + +output human_user { + value = data.zitadel_human_user.human_user +} +``` + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `user_id` (String) The ID of this resource. + +### Read-Only + +- `display_name` (String) Display name of the user +- `email` (String) Email of the user +- `first_name` (String) First name of the user +- `gender` (String) Gender of the user +- `id` (String) The ID of this resource. +- `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set +- `is_phone_verified` (Boolean) Is the phone verified of the user +- `last_name` (String) Last name of the user +- `login_names` (List of String) Loginnames +- `nick_name` (String) Nick name of the user +- `phone` (String) Phone of the user +- `preferred_language` (String) Preferred language of the user +- `preferred_login_name` (String) Preferred login name +- `state` (String) State of the user +- `user_name` (String) Username \ No newline at end of file diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md new file mode 100644 index 00000000..475edcc8 --- /dev/null +++ b/docs/data-sources/machine_user.md @@ -0,0 +1,43 @@ +--- +page_title: "zitadel_machine_user Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources. +--- + +# zitadel_machine_user (Data Source) + +Datasource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources. + +## Example Usage + +```terraform +data zitadel_machine_user machine_user { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + user_id = "177073617463410691" +} + +output machine_user { + value = data.zitadel_machine_user.machine_user +} +``` + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `user_id` (String) The ID of this resource. + +### Read-Only + +- `description` (String) Description of the user +- `id` (String) The ID of this resource. +- `login_names` (List of String) Loginnames +- `name` (String) Name of the machine user +- `preferred_login_name` (String) Preferred login name +- `state` (String) State of the user +- `user_name` (String) Username \ No newline at end of file diff --git a/docs/data-sources/org.md b/docs/data-sources/org.md new file mode 100644 index 00000000..1e761573 --- /dev/null +++ b/docs/data-sources/org.md @@ -0,0 +1,34 @@ +--- +page_title: "zitadel_org Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance. +--- + +# zitadel_org (Data Source) + +Datasource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance. + +## Example Usage + +```terraform +data zitadel_org org { + org_id = "177073608051458051" +} + +output org { + value = data.zitadel_org.org +} +``` + + +## Schema + +### Required + +- `org_id` (String) The ID of this resource. + +### Read-Only + +- `id` (String) The ID of this resource. +- `name` (String) Name of the org \ No newline at end of file diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md new file mode 100644 index 00000000..b26b57a8 --- /dev/null +++ b/docs/data-sources/org_jwt_idp.md @@ -0,0 +1,44 @@ +--- +page_title: "zitadel_org_jwt_idp Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a domain of the organization. +--- + +# zitadel_org_jwt_idp (Data Source) + +Datasource representing a domain of the organization. + +## Example Usage + +```terraform +data zitadel_org_jwt_idp org_jwt_idp { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + idp_id = "177073612581240835" +} + +output org_jwt_idp { + value = data.zitadel_org_jwt_idp.org_jwt_idp +} +``` + + +## Schema + +### Required + +- `idp_id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `auto_register` (Boolean) auto register for users from this idp +- `header_name` (String) the name of the header where the JWT is sent in, default is authorization +- `id` (String) The ID of this resource. +- `issuer` (String) the issuer of the jwt (for validation) +- `jwt_endpoint` (String) the endpoint where the jwt can be extracted +- `keys_endpoint` (String) the endpoint to the key (JWK) which are used to sign the JWT with +- `name` (String) Name of the IDP +- `styling_type` (String) Some identity providers specify the styling of the button to their login \ No newline at end of file diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md new file mode 100644 index 00000000..96a1b75d --- /dev/null +++ b/docs/data-sources/org_oidc_idp.md @@ -0,0 +1,46 @@ +--- +page_title: "zitadel_org_oidc_idp Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a OIDC IDP of the organization. +--- + +# zitadel_org_oidc_idp (Data Source) + +Datasource representing a OIDC IDP of the organization. + +## Example Usage + +```terraform +data zitadel_org_oidc_idp org_oidc_idp { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + idp_id = "177073612581240835" +} + +output org_oidc_idp { + value = data.zitadel_org_oidc_idp.org_oidc_idp +} +``` + + +## Schema + +### Required + +- `idp_id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `auto_register` (Boolean) auto register for users from this idp +- `client_id` (String, Sensitive) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `display_name_mapping` (String) definition which field is mapped to the display name of the user +- `id` (String) The ID of this resource. +- `issuer` (String) the oidc issuer of the identity provider +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `styling_type` (String) Some identity providers specify the styling of the button to their login +- `username_mapping` (String) definition which field is mapped to the email of the user \ No newline at end of file diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md new file mode 100644 index 00000000..3816c2bb --- /dev/null +++ b/docs/data-sources/project.md @@ -0,0 +1,43 @@ +--- +page_title: "zitadel_project Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing the project, which can then be granted to different organizations or users directly, containing different applications. +--- + +# zitadel_project (Data Source) + +Datasource representing the project, which can then be granted to different organizations or users directly, containing different applications. + +## Example Usage + +```terraform +data zitadel_project project { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + project_id = "177073620768522243" +} + +output project { + value = data.zitadel_project.project +} +``` + + +## Schema + +### Required + +- `org_id` (String) Organization in which the project is located +- `project_id` (String) The ID of this resource. + +### Read-Only + +- `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project +- `id` (String) The ID of this resource. +- `name` (String) Name of the project +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered +- `project_role_assertion` (Boolean) describes if roles of user should be added in token +- `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project +- `state` (String) State of the project \ No newline at end of file diff --git a/docs/data-sources/project_role.md b/docs/data-sources/project_role.md new file mode 100644 index 00000000..d85cc35e --- /dev/null +++ b/docs/data-sources/project_role.md @@ -0,0 +1,41 @@ +--- +page_title: "zitadel_project_role Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing the project roles, which can be given as authorizations to users. +--- + +# zitadel_project_role (Data Source) + +Datasource representing the project roles, which can be given as authorizations to users. + +## Example Usage + +```terraform +data zitadel_project_role project_role { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + role_key = "key" +} + +output project_role { + value = data.zitadel_project_role.project_role +} +``` + + +## Schema + +### Required + +- `org_id` (String) ID of the organization +- `project_id` (String) ID of the project +- `role_key` (String) Key used for project role + +### Read-Only + +- `display_name` (String) Name used for project role +- `group` (String) Group used for project role +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/data-sources/trigger_actions.md b/docs/data-sources/trigger_actions.md new file mode 100644 index 00000000..08ada025 --- /dev/null +++ b/docs/data-sources/trigger_actions.md @@ -0,0 +1,40 @@ +--- +page_title: "zitadel_trigger_actions Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing triggers, when actions get started +--- + +# zitadel_trigger_actions (Data Source) + +Resource representing triggers, when actions get started + +## Example Usage + +```terraform +data zitadel_trigger_actions trigger_actions { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" + trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" +} + +output trigger_actions { + value = data.zitadel_trigger_actions.trigger_actions +} +``` + + +## Schema + +### Required + +- `flow_type` (String) Type of the flow to which the action triggers belong +- `org_id` (String) ID of the organization +- `trigger_type` (String) Trigger type on when the actions get triggered + +### Read-Only + +- `action_ids` (Set of String) IDs of the triggered actions +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 81858b02..e506d3ad 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,7 +31,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.6" + version = "1.0.0-alpha.8" } } } diff --git a/docs/resources/action.md b/docs/resources/action.md index ffb34837..2ab568b8 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -14,7 +14,6 @@ Resource representing an action belonging to an organization. ```terraform resource zitadel_action action { depends_on = [zitadel_org.org] - provider = zitadel org_id = zitadel_org.org.id name = "actionname" diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 5dd790cb..1b4abebe 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -38,6 +38,7 @@ resource zitadel_human_user human_user { ### Required +- `email` (String) Email of the user - `first_name` (String) First name of the user - `last_name` (String) Last name of the user - `org_id` (String) ID of the organization @@ -46,7 +47,6 @@ resource zitadel_human_user human_user { ### Optional - `display_name` (String) Display name of the user -- `email` (String) Email of the user - `gender` (String) Gender of the user - `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set diff --git a/docs/resources/org_oidc_idp.md b/docs/resources/org_oidc_idp.md index 7f58d6cb..249636c9 100644 --- a/docs/resources/org_oidc_idp.md +++ b/docs/resources/org_oidc_idp.md @@ -12,17 +12,19 @@ Resource representing a OIDC IDP of the organization. ## Example Usage ```terraform -resource zitadel_org_jwt_idp jwt_idp { +resource zitadel_org_oidc_idp oidc_idp { depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id - name = "jwtidp" - styling_type = "STYLING_TYPE_UNSPECIFIED" - jwt_endpoint = "https://jwtendpoint.com" - issuer = "https://google.com" - keys_endpoint = "https://jwtendpoint.com/keys" - header_name = "x-auth-token" - auto_register = false + org_id = zitadel_org.org.id + name = "oidcidp" + styling_type = "STYLING_TYPE_UNSPECIFIED" + client_id = "google" + client_secret = "google_secret" + issuer = "https://google.com" + scopes = ["openid", "profile", "email"] + display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + auto_register = false } ``` @@ -32,8 +34,8 @@ resource zitadel_org_jwt_idp jwt_idp { ### Required - `auto_register` (Boolean) auto register for users from this idp -- `client_id` (String) client id generated by the identity provider -- `client_secret` (String) client secret generated by the identity provider +- `client_id` (String, Sensitive) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider - `display_name_mapping` (String) definition which field is mapped to the display name of the user - `issuer` (String) the oidc issuer of the identity provider - `name` (String) Name of the IDP diff --git a/docs/resources/project.md b/docs/resources/project.md index afca8daf..73e4b3f3 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -41,5 +41,5 @@ resource zitadel_project project { ### Read-Only -- `id` (String) ID of the project +- `id` (String) The ID of this resource. - `state` (String) State of the project \ No newline at end of file diff --git a/examples/provider/data-sources/action.tf b/examples/provider/data-sources/action.tf new file mode 100644 index 00000000..f0f107b3 --- /dev/null +++ b/examples/provider/data-sources/action.tf @@ -0,0 +1,10 @@ +data zitadel_action action { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + action_id = "177073621691269123" +} + +output action { + value = data.zitadel_action.action +} \ No newline at end of file diff --git a/examples/provider/data-sources/application_api.tf b/examples/provider/data-sources/application_api.tf new file mode 100644 index 00000000..83a59d92 --- /dev/null +++ b/examples/provider/data-sources/application_api.tf @@ -0,0 +1,11 @@ +data zitadel_application_api api_application { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + app_id = "177073625566806019" +} + +output api_application { + value = data.zitadel_application_api.api_application +} \ No newline at end of file diff --git a/examples/provider/data-sources/application_oidc.tf b/examples/provider/data-sources/application_oidc.tf new file mode 100644 index 00000000..8d5476b3 --- /dev/null +++ b/examples/provider/data-sources/application_oidc.tf @@ -0,0 +1,11 @@ +data zitadel_application_oidc oidc_application { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + app_id = "177073626925760515" +} + +output oidc_application { + value = data.zitadel_application_oidc.oidc_application +} \ No newline at end of file diff --git a/examples/provider/data-sources/human_user.tf b/examples/provider/data-sources/human_user.tf new file mode 100644 index 00000000..93584dae --- /dev/null +++ b/examples/provider/data-sources/human_user.tf @@ -0,0 +1,10 @@ +data zitadel_human_user human_user { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + user_id = "177073614158299139" +} + +output human_user { + value = data.zitadel_human_user.human_user +} \ No newline at end of file diff --git a/examples/provider/data-sources/machine_user.tf b/examples/provider/data-sources/machine_user.tf new file mode 100644 index 00000000..59b1758c --- /dev/null +++ b/examples/provider/data-sources/machine_user.tf @@ -0,0 +1,10 @@ +data zitadel_machine_user machine_user { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + user_id = "177073617463410691" +} + +output machine_user { + value = data.zitadel_machine_user.machine_user +} \ No newline at end of file diff --git a/examples/provider/data-sources/org.tf b/examples/provider/data-sources/org.tf new file mode 100644 index 00000000..21b23ca7 --- /dev/null +++ b/examples/provider/data-sources/org.tf @@ -0,0 +1,7 @@ +data zitadel_org org { + org_id = "177073608051458051" +} + +output org { + value = data.zitadel_org.org +} diff --git a/examples/provider/data-sources/org_jwt_idp.tf b/examples/provider/data-sources/org_jwt_idp.tf new file mode 100644 index 00000000..c57cfaad --- /dev/null +++ b/examples/provider/data-sources/org_jwt_idp.tf @@ -0,0 +1,10 @@ +data zitadel_org_jwt_idp org_jwt_idp { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + idp_id = "177073612581240835" +} + +output org_jwt_idp { + value = data.zitadel_org_jwt_idp.org_jwt_idp +} \ No newline at end of file diff --git a/examples/provider/data-sources/org_oidc_idp.tf b/examples/provider/data-sources/org_oidc_idp.tf new file mode 100644 index 00000000..4d1b4e23 --- /dev/null +++ b/examples/provider/data-sources/org_oidc_idp.tf @@ -0,0 +1,10 @@ +data zitadel_org_oidc_idp org_oidc_idp { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + idp_id = "177073612581240835" +} + +output org_oidc_idp { + value = data.zitadel_org_oidc_idp.org_oidc_idp +} \ No newline at end of file diff --git a/examples/provider/data-sources/project.tf b/examples/provider/data-sources/project.tf new file mode 100644 index 00000000..8ba021b5 --- /dev/null +++ b/examples/provider/data-sources/project.tf @@ -0,0 +1,10 @@ +data zitadel_project project { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + project_id = "177073620768522243" +} + +output project { + value = data.zitadel_project.project +} \ No newline at end of file diff --git a/examples/provider/data-sources/project_role.tf b/examples/provider/data-sources/project_role.tf new file mode 100644 index 00000000..7f4acebd --- /dev/null +++ b/examples/provider/data-sources/project_role.tf @@ -0,0 +1,11 @@ +data zitadel_project_role project_role { + depends_on = [data.zitadel_org.org, data.zitadel_project.project] + + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + role_key = "key" +} + +output project_role { + value = data.zitadel_project_role.project_role +} \ No newline at end of file diff --git a/examples/provider/data-sources/trigger_actions.tf b/examples/provider/data-sources/trigger_actions.tf new file mode 100644 index 00000000..fa2dae0f --- /dev/null +++ b/examples/provider/data-sources/trigger_actions.tf @@ -0,0 +1,11 @@ +data zitadel_trigger_actions trigger_actions { + depends_on = [data.zitadel_org.org] + + org_id = data.zitadel_org.org.id + flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" + trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" +} + +output trigger_actions { + value = data.zitadel_trigger_actions.trigger_actions +} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index c1bd881f..8398e889 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.6" + version = "1.0.0-alpha.7" } } } diff --git a/examples/provider/action.tf b/examples/provider/resources/action.tf similarity index 90% rename from examples/provider/action.tf rename to examples/provider/resources/action.tf index 03f1d103..d3e01fd4 100644 --- a/examples/provider/action.tf +++ b/examples/provider/resources/action.tf @@ -1,7 +1,6 @@ resource zitadel_action action { depends_on = [zitadel_org.org] - provider = zitadel org_id = zitadel_org.org.id name = "actionname" diff --git a/examples/provider/app_key.tf b/examples/provider/resources/app_key.tf similarity index 100% rename from examples/provider/app_key.tf rename to examples/provider/resources/app_key.tf diff --git a/examples/provider/application_api.tf b/examples/provider/resources/application_api.tf similarity index 100% rename from examples/provider/application_api.tf rename to examples/provider/resources/application_api.tf diff --git a/examples/provider/application_oidc.tf b/examples/provider/resources/application_oidc.tf similarity index 100% rename from examples/provider/application_oidc.tf rename to examples/provider/resources/application_oidc.tf diff --git a/examples/provider/domain.tf b/examples/provider/resources/domain.tf similarity index 100% rename from examples/provider/domain.tf rename to examples/provider/resources/domain.tf diff --git a/examples/provider/domain_policy.tf b/examples/provider/resources/domain_policy.tf similarity index 100% rename from examples/provider/domain_policy.tf rename to examples/provider/resources/domain_policy.tf diff --git a/examples/provider/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf similarity index 100% rename from examples/provider/granted_human_user.tf rename to examples/provider/resources/granted_human_user.tf diff --git a/examples/provider/granted_org.tf b/examples/provider/resources/granted_org.tf similarity index 100% rename from examples/provider/granted_org.tf rename to examples/provider/resources/granted_org.tf diff --git a/examples/provider/human_user.tf b/examples/provider/resources/human_user.tf similarity index 100% rename from examples/provider/human_user.tf rename to examples/provider/resources/human_user.tf diff --git a/examples/provider/label_policy.tf b/examples/provider/resources/label_policy.tf similarity index 100% rename from examples/provider/label_policy.tf rename to examples/provider/resources/label_policy.tf diff --git a/examples/provider/lockout_policy.tf b/examples/provider/resources/lockout_policy.tf similarity index 100% rename from examples/provider/lockout_policy.tf rename to examples/provider/resources/lockout_policy.tf diff --git a/examples/provider/login_policy.tf b/examples/provider/resources/login_policy.tf similarity index 100% rename from examples/provider/login_policy.tf rename to examples/provider/resources/login_policy.tf diff --git a/examples/provider/machine_key.tf b/examples/provider/resources/machine_key.tf similarity index 100% rename from examples/provider/machine_key.tf rename to examples/provider/resources/machine_key.tf diff --git a/examples/provider/machine_user.tf b/examples/provider/resources/machine_user.tf similarity index 100% rename from examples/provider/machine_user.tf rename to examples/provider/resources/machine_user.tf diff --git a/examples/provider/org.tf b/examples/provider/resources/org.tf similarity index 100% rename from examples/provider/org.tf rename to examples/provider/resources/org.tf diff --git a/examples/provider/org_jwt_idp.tf b/examples/provider/resources/org_jwt_idp.tf similarity index 100% rename from examples/provider/org_jwt_idp.tf rename to examples/provider/resources/org_jwt_idp.tf diff --git a/examples/provider/org_member.tf b/examples/provider/resources/org_member.tf similarity index 100% rename from examples/provider/org_member.tf rename to examples/provider/resources/org_member.tf diff --git a/examples/provider/org_oidc_idp.tf b/examples/provider/resources/org_oidc_idp.tf similarity index 100% rename from examples/provider/org_oidc_idp.tf rename to examples/provider/resources/org_oidc_idp.tf diff --git a/examples/provider/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf similarity index 100% rename from examples/provider/password_complexity_policy.tf rename to examples/provider/resources/password_complexity_policy.tf diff --git a/examples/provider/personal_access_token.tf b/examples/provider/resources/personal_access_token.tf similarity index 100% rename from examples/provider/personal_access_token.tf rename to examples/provider/resources/personal_access_token.tf diff --git a/examples/provider/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf similarity index 100% rename from examples/provider/privacy_policy.tf rename to examples/provider/resources/privacy_policy.tf diff --git a/examples/provider/project.tf b/examples/provider/resources/project.tf similarity index 100% rename from examples/provider/project.tf rename to examples/provider/resources/project.tf diff --git a/examples/provider/project_grant.tf b/examples/provider/resources/project_grant.tf similarity index 100% rename from examples/provider/project_grant.tf rename to examples/provider/resources/project_grant.tf diff --git a/examples/provider/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf similarity index 100% rename from examples/provider/project_grant_member.tf rename to examples/provider/resources/project_grant_member.tf diff --git a/examples/provider/project_member.tf b/examples/provider/resources/project_member.tf similarity index 100% rename from examples/provider/project_member.tf rename to examples/provider/resources/project_member.tf diff --git a/examples/provider/project_role.tf b/examples/provider/resources/project_role.tf similarity index 100% rename from examples/provider/project_role.tf rename to examples/provider/resources/project_role.tf diff --git a/examples/provider/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf similarity index 100% rename from examples/provider/trigger_actions.tf rename to examples/provider/resources/trigger_actions.tf diff --git a/examples/provider/user_grant.tf b/examples/provider/resources/user_grant.tf similarity index 100% rename from examples/provider/user_grant.tf rename to examples/provider/resources/user_grant.tf diff --git a/templates/data-sources/action.md.tmpl b/templates/data-sources/action.md.tmpl new file mode 100644 index 00000000..ab867881 --- /dev/null +++ b/templates/data-sources/action.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/action.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/application_api.md.tmpl b/templates/data-sources/application_api.md.tmpl new file mode 100644 index 00000000..c9b313cb --- /dev/null +++ b/templates/data-sources/application_api.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/application_api.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/application_oidc.md.tmpl b/templates/data-sources/application_oidc.md.tmpl new file mode 100644 index 00000000..b29e2473 --- /dev/null +++ b/templates/data-sources/application_oidc.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/application_oidc.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/human_user.md.tmpl b/templates/data-sources/human_user.md.tmpl new file mode 100644 index 00000000..c4268810 --- /dev/null +++ b/templates/data-sources/human_user.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/human_user.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/machine_user.md.tmpl b/templates/data-sources/machine_user.md.tmpl new file mode 100644 index 00000000..ab82e401 --- /dev/null +++ b/templates/data-sources/machine_user.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/machine_user.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/org.md.tmpl b/templates/data-sources/org.md.tmpl new file mode 100644 index 00000000..a359cdac --- /dev/null +++ b/templates/data-sources/org.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/org_jwt_idp.md.tmpl b/templates/data-sources/org_jwt_idp.md.tmpl new file mode 100644 index 00000000..c1ab5a4c --- /dev/null +++ b/templates/data-sources/org_jwt_idp.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_jwt_idp.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/org_oidc_idp.md.tmpl b/templates/data-sources/org_oidc_idp.md.tmpl new file mode 100644 index 00000000..e5a18a4d --- /dev/null +++ b/templates/data-sources/org_oidc_idp.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_oidc_idp.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/project.md.tmpl b/templates/data-sources/project.md.tmpl new file mode 100644 index 00000000..e35a898f --- /dev/null +++ b/templates/data-sources/project.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/project.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/project_role.md.tmpl b/templates/data-sources/project_role.md.tmpl new file mode 100644 index 00000000..ade179f5 --- /dev/null +++ b/templates/data-sources/project_role.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/project_role.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/data-sources/trigger_actions.md.tmpl b/templates/data-sources/trigger_actions.md.tmpl new file mode 100644 index 00000000..90dc4c13 --- /dev/null +++ b/templates/data-sources/trigger_actions.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/trigger_actions.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/action.md.tmpl b/templates/resources/action.md.tmpl index dba55919..74d933cd 100644 --- a/templates/resources/action.md.tmpl +++ b/templates/resources/action.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/action.tf" }} +{{ tffile "examples/provider/resources/action.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/application_api.md.tmpl b/templates/resources/application_api.md.tmpl index ff120262..dd0a9973 100644 --- a/templates/resources/application_api.md.tmpl +++ b/templates/resources/application_api.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/application_api.tf" }} +{{ tffile "examples/provider/resources/application_api.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index f3395ea5..473267f3 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/app_key.tf" }} +{{ tffile "examples/provider/resources/app_key.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/application_oidc.md.tmpl b/templates/resources/application_oidc.md.tmpl index 81d4c763..40d3d2e5 100644 --- a/templates/resources/application_oidc.md.tmpl +++ b/templates/resources/application_oidc.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/application_oidc.tf" }} +{{ tffile "examples/provider/resources/application_oidc.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/domain.md.tmpl b/templates/resources/domain.md.tmpl index 6e7a2280..07cb8624 100644 --- a/templates/resources/domain.md.tmpl +++ b/templates/resources/domain.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/domain.tf" }} +{{ tffile "examples/provider/resources/domain.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/domain_policy.md.tmpl b/templates/resources/domain_policy.md.tmpl index ddcdab44..252f3ebd 100644 --- a/templates/resources/domain_policy.md.tmpl +++ b/templates/resources/domain_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/domain_policy.tf" }} +{{ tffile "examples/provider/resources/domain_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/human_user.md.tmpl b/templates/resources/human_user.md.tmpl index 139dcd38..4dbdefcc 100644 --- a/templates/resources/human_user.md.tmpl +++ b/templates/resources/human_user.md.tmpl @@ -13,6 +13,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/human_user.tf" }} +{{ tffile "examples/provider/resources/human_user.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/label_policy.md.tmpl b/templates/resources/label_policy.md.tmpl index d3bb74dd..0e397709 100644 --- a/templates/resources/label_policy.md.tmpl +++ b/templates/resources/label_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/label_policy.tf" }} +{{ tffile "examples/provider/resources/label_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/lockout_policy.md.tmpl b/templates/resources/lockout_policy.md.tmpl index 0c6ee571..201466f6 100644 --- a/templates/resources/lockout_policy.md.tmpl +++ b/templates/resources/lockout_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/lockout_policy.tf" }} +{{ tffile "examples/provider/resources/lockout_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/login_policy.md.tmpl b/templates/resources/login_policy.md.tmpl index 798ebf7e..9cf97c1b 100644 --- a/templates/resources/login_policy.md.tmpl +++ b/templates/resources/login_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/login_policy.tf" }} +{{ tffile "examples/provider/resources/login_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/machine_key.md.tmpl b/templates/resources/machine_key.md.tmpl index 90174f04..3c99ef02 100644 --- a/templates/resources/machine_key.md.tmpl +++ b/templates/resources/machine_key.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/machine_key.tf" }} +{{ tffile "examples/provider/resources/machine_key.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/machine_user.md.tmpl b/templates/resources/machine_user.md.tmpl index 2947a2df..2d747b76 100644 --- a/templates/resources/machine_user.md.tmpl +++ b/templates/resources/machine_user.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/machine_user.tf" }} +{{ tffile "examples/provider/resources/machine_user.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org.md.tmpl b/templates/resources/org.md.tmpl index 533d3c52..84e4f17b 100644 --- a/templates/resources/org.md.tmpl +++ b/templates/resources/org.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/org.tf" }} +{{ tffile "examples/provider/resources/org.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_jwt_idp.md.tmpl b/templates/resources/org_jwt_idp.md.tmpl index 6946a79f..944e1b63 100644 --- a/templates/resources/org_jwt_idp.md.tmpl +++ b/templates/resources/org_jwt_idp.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/org_jwt_idp.tf" }} +{{ tffile "examples/provider/resources/org_jwt_idp.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_member.md.tmpl b/templates/resources/org_member.md.tmpl index 239ae240..f10ecd05 100644 --- a/templates/resources/org_member.md.tmpl +++ b/templates/resources/org_member.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/org_member.tf" }} +{{ tffile "examples/provider/resources/org_member.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_oidc_idp.md.tmpl b/templates/resources/org_oidc_idp.md.tmpl index 6946a79f..f5ef5f38 100644 --- a/templates/resources/org_oidc_idp.md.tmpl +++ b/templates/resources/org_oidc_idp.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/org_jwt_idp.tf" }} +{{ tffile "examples/provider/resources/org_oidc_idp.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/password_complexity_policy.md.tmpl b/templates/resources/password_complexity_policy.md.tmpl index d68917e8..ca1593bf 100644 --- a/templates/resources/password_complexity_policy.md.tmpl +++ b/templates/resources/password_complexity_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/password_complexity_policy.tf" }} +{{ tffile "examples/provider/resources/password_complexity_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/personal_access_token.md.tmpl b/templates/resources/personal_access_token.md.tmpl index b73bd3b0..c2334ff0 100644 --- a/templates/resources/personal_access_token.md.tmpl +++ b/templates/resources/personal_access_token.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/personal_access_token.tf" }} +{{ tffile "examples/provider/resources/personal_access_token.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/privacy_policy.md.tmpl b/templates/resources/privacy_policy.md.tmpl index 8f8669c0..cb607535 100644 --- a/templates/resources/privacy_policy.md.tmpl +++ b/templates/resources/privacy_policy.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/privacy_policy.tf" }} +{{ tffile "examples/provider/resources/privacy_policy.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project.md.tmpl b/templates/resources/project.md.tmpl index 61d79abf..a913694e 100644 --- a/templates/resources/project.md.tmpl +++ b/templates/resources/project.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/project.tf" }} +{{ tffile "examples/provider/resources/project.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_grant.md.tmpl b/templates/resources/project_grant.md.tmpl index 0a99f11b..2a9dbb41 100644 --- a/templates/resources/project_grant.md.tmpl +++ b/templates/resources/project_grant.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/project_grant.tf" }} +{{ tffile "examples/provider/resources/project_grant.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_grant_member.md.tmpl b/templates/resources/project_grant_member.md.tmpl index 27b68166..c2ea58ff 100644 --- a/templates/resources/project_grant_member.md.tmpl +++ b/templates/resources/project_grant_member.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/project_grant_member.tf" }} +{{ tffile "examples/provider/resources/project_grant_member.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_member.md.tmpl b/templates/resources/project_member.md.tmpl index fecd8e25..626865ea 100644 --- a/templates/resources/project_member.md.tmpl +++ b/templates/resources/project_member.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/project_member.tf" }} +{{ tffile "examples/provider/resources/project_member.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/project_role.md.tmpl b/templates/resources/project_role.md.tmpl index 3b880229..b9e52b05 100644 --- a/templates/resources/project_role.md.tmpl +++ b/templates/resources/project_role.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/project_role.tf" }} +{{ tffile "examples/provider/resources/project_role.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/trigger_actions.md.tmpl b/templates/resources/trigger_actions.md.tmpl index 61f6253f..ba7202c9 100644 --- a/templates/resources/trigger_actions.md.tmpl +++ b/templates/resources/trigger_actions.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/trigger_actions.tf" }} +{{ tffile "examples/provider/resources/trigger_actions.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/user_grant.md.tmpl b/templates/resources/user_grant.md.tmpl index a47b3868..e13c1c22 100644 --- a/templates/resources/user_grant.md.tmpl +++ b/templates/resources/user_grant.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/user_grant.tf" }} +{{ tffile "examples/provider/resources/user_grant.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index e23d8ccd..858c3097 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -6,68 +6,106 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - v2 "github.com/zitadel/terraform-provider-zitadel/zitadel/v2" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_jwt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" ) func Provider() *schema.Provider { return &schema.Provider{ - DataSourcesMap: map[string]*schema.Resource{}, + DataSourcesMap: map[string]*schema.Resource{ + "zitadel_org": org.GetDatasource(), + "zitadel_human_user": human_user.GetDatasource(), + "zitadel_machine_user": machine_user.GetDatasource(), + "zitadel_project": project.GetDatasource(), + "zitadel_project_role": project_role.GetDatasource(), + "zitadel_action": action.GetDatasource(), + "zitadel_application_oidc": application_oidc.GetDatasource(), + "zitadel_application_api": application_api.GetDatasource(), + "zitadel_trigger_actions": trigger_actions.GetDatasource(), + "zitadel_org_jwt_idp": idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": idp_oidc.GetDatasource(), + }, Schema: map[string]*schema.Schema{ - v2.DomainVar: { + helper.DomainVar: { Type: schema.TypeString, Required: true, Description: "Domain used to connect to the ZITADEL instance", }, - v2.InsecureVar: { + helper.InsecureVar: { Type: schema.TypeBool, Optional: true, Description: "Use insecure connection", }, - v2.TokenVar: { + helper.TokenVar: { Type: schema.TypeString, Required: true, Description: "Path to the file containing credentials to connect to ZITADEL", }, - v2.PortVar: { + helper.PortVar: { Type: schema.TypeString, Optional: true, Description: "Used port if not the default ports 80 or 443 are configured", }, }, ResourcesMap: map[string]*schema.Resource{ - "zitadel_org": v2.OrgResource(), - "zitadel_human_user": v2.GetHumanUser(), - "zitadel_machine_user": v2.GetMachineUser(), - "zitadel_project": v2.GetProject(), - "zitadel_project_role": v2.GetProjectRole(), - "zitadel_domain": v2.GetDomain(), - "zitadel_action": v2.GetAction(), - "zitadel_application_oidc": v2.GetApplicationOIDC(), - "zitadel_application_api": v2.GetApplicationAPI(), - "zitadel_application_key": v2.GetAppKey(), - "zitadel_project_grant": v2.GetProjectGrant(), - "zitadel_user_grant": v2.GetUserGrant(), - "zitadel_org_member": v2.GetOrgMember(), - "zitadel_project_member": v2.GetProjectMember(), - "zitadel_project_grant_member": v2.GetProjectGrantMember(), - "zitadel_domain_policy": v2.GetDomainPolicy(), - "zitadel_label_policy": v2.GetLabelPolicy(), - "zitadel_lockout_policy": v2.GetLockoutPolicy(), - "zitadel_login_policy": v2.GetLoginPolicy(), - "zitadel_password_complexity_policy": v2.GetPasswordComplexityPolicy(), - "zitadel_privacy_policy": v2.GetPrivacyPolicy(), - "zitadel_trigger_actions": v2.GetTriggerActions(), - "zitadel_personal_access_token": v2.GetPAT(), - "zitadel_machine_key": v2.GetMachineKey(), - "zitadel_org_jwt_idp": v2.GetOrgJWTIDP(), - "zitadel_org_oidc_idp": v2.GetOrgOIDCIDP(), + "zitadel_org": org.GetResource(), + "zitadel_human_user": human_user.GetResource(), + "zitadel_machine_user": machine_user.GetResource(), + "zitadel_project": project.GetResource(), + "zitadel_project_role": project_role.GetResource(), + "zitadel_domain": domain.GetResource(), + "zitadel_action": action.GetResource(), + "zitadel_application_oidc": application_oidc.GetResource(), + "zitadel_application_api": application_api.GetResource(), + "zitadel_application_key": app_key.GetResource(), + "zitadel_project_grant": project_grant.GetResource(), + "zitadel_user_grant": user_grant.GetResource(), + "zitadel_org_member": org_member.GetResource(), + "zitadel_project_member": project_member.GetResource(), + "zitadel_project_grant_member": project_grant_member.GetResource(), + "zitadel_domain_policy": domain_policy.GetResource(), + "zitadel_label_policy": label_policy.GetResource(), + "zitadel_lockout_policy": lockout_policy.GetResource(), + "zitadel_login_policy": login_policy.GetResource(), + "zitadel_password_complexity_policy": password_complexity_policy.GetResource(), + "zitadel_privacy_policy": privacy_policy.GetResource(), + "zitadel_trigger_actions": trigger_actions.GetResource(), + "zitadel_personal_access_token": pat.GetResource(), + "zitadel_machine_key": machine_key.GetResource(), + "zitadel_org_jwt_idp": idp_jwt.GetResource(), + "zitadel_org_oidc_idp": idp_oidc.GetResource(), }, ConfigureContextFunc: providerConfigure, } } func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { - clientinfo, err := v2.GetClientInfo(d) + clientinfo, err := helper.GetClientInfo(d) if err != nil { return nil, diag.FromErr(err) } diff --git a/zitadel/v2/action.go b/zitadel/v2/action.go deleted file mode 100644 index 2279b2ed..00000000 --- a/zitadel/v2/action.go +++ /dev/null @@ -1,201 +0,0 @@ -package v2 - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/durationpb" -) - -const ( - actionOrgId = "org_id" - actionState = "state" - actionName = "name" - actionScript = "script" - actionTimeout = "timeout" - actionAllowedToFail = "allowed_to_fail" -) - -func GetAction() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing an action belonging to an organization.", - Schema: map[string]*schema.Schema{ - actionOrgId: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - actionState: { - Type: schema.TypeInt, - Computed: true, - Description: "the state of the action", - }, - actionName: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - actionScript: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - actionTimeout: { - Type: schema.TypeString, - Required: true, - Description: "after which time the action will be terminated if not finished", - }, - actionAllowedToFail: { - Type: schema.TypeBool, - Required: true, - Description: "when true, the next action will be called even if this action fails", - }, - }, - CreateContext: createAction, - DeleteContext: deleteAction, - ReadContext: readAction, - UpdateContext: updateAction, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func updateAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) - if err != nil { - return diag.FromErr(err) - } - - timeout, err := time.ParseDuration(d.Get(actionTimeout).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateAction(ctx, &management.UpdateActionRequest{ - Id: d.Id(), - Name: d.Get(actionName).(string), - Script: d.Get(actionScript).(string), - Timeout: durationpb.New(timeout), - AllowedToFail: d.Get(actionAllowedToFail).(bool), - }) - if err != nil { - return diag.Errorf("failed to update action: %v", err) - } - return nil -} - -func deleteAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.DeleteAction(ctx, &management.DeleteActionRequest{ - Id: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete action: %v", err) - } - return nil -} - -func createAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) - if err != nil { - return diag.FromErr(err) - } - - timeout, err := time.ParseDuration(d.Get(actionTimeout).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.CreateAction(ctx, &management.CreateActionRequest{ - Name: d.Get(actionName).(string), - Script: d.Get(actionScript).(string), - Timeout: durationpb.New(timeout), - AllowedToFail: d.Get(actionAllowedToFail).(bool), - }) - if err != nil { - return diag.Errorf("failed to create action: %v", err) - } - d.SetId(resp.GetId()) - return nil -} - -func readAction(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListActions(ctx, &management.ListActionsRequest{ - Queries: []*management.ActionQuery{ - {Query: &management.ActionQuery_ActionIdQuery{ - ActionIdQuery: &action.ActionIDQuery{ - Id: d.Id(), - }, - }}, - }, - }) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read action: %v", err) - } - - if len(resp.Result) == 1 { - action := resp.Result[0] - set := map[string]interface{}{ - actionOrgId: action.GetDetails().GetResourceOwner(), - actionName: action.GetName(), - actionState: action.GetState(), - actionScript: action.GetScript(), - actionTimeout: action.GetTimeout().AsDuration().String(), - actionAllowedToFail: action.GetAllowedToFail(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of action: %v", k, err) - } - } - d.SetId(action.GetId()) - return nil - } - - d.SetId("") - return nil -} diff --git a/zitadel/v2/action/const.go b/zitadel/v2/action/const.go new file mode 100644 index 00000000..f1f878af --- /dev/null +++ b/zitadel/v2/action/const.go @@ -0,0 +1,11 @@ +package action + +const ( + actionIDVar = "action_id" + orgIDVar = "org_id" + stateVar = "state" + nameVar = "name" + scriptVar = "script" + timeoutVar = "timeout" + allowedToFailVar = "allowed_to_fail" +) diff --git a/zitadel/v2/action/datasource.go b/zitadel/v2/action/datasource.go new file mode 100644 index 00000000..7a2057f6 --- /dev/null +++ b/zitadel/v2/action/datasource.go @@ -0,0 +1,49 @@ +package action + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an action belonging to an organization.", + Schema: map[string]*schema.Schema{ + actionIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + stateVar: { + Type: schema.TypeInt, + Computed: true, + Description: "the state of the action", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + scriptVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + timeoutVar: { + Type: schema.TypeString, + Computed: true, + Description: "after which time the action will be terminated if not finished", + }, + allowedToFailVar: { + Type: schema.TypeBool, + Computed: true, + Description: "when true, the next action will be called even if this action fails", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go new file mode 100644 index 00000000..9ab2ac6b --- /dev/null +++ b/zitadel/v2/action/funcs.go @@ -0,0 +1,150 @@ +package action + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + timeout, err := time.ParseDuration(d.Get(timeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateAction(ctx, &management.UpdateActionRequest{ + Id: d.Id(), + Name: d.Get(nameVar).(string), + Script: d.Get(scriptVar).(string), + Timeout: durationpb.New(timeout), + AllowedToFail: d.Get(allowedToFailVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update action: %v", err) + } + return nil +} + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.DeleteAction(ctx, &management.DeleteActionRequest{ + Id: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete action: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + timeout, err := time.ParseDuration(d.Get(timeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.CreateAction(ctx, &management.CreateActionRequest{ + Name: d.Get(nameVar).(string), + Script: d.Get(scriptVar).(string), + Timeout: durationpb.New(timeout), + AllowedToFail: d.Get(allowedToFailVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create action: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.ListActions(ctx, &management.ListActionsRequest{ + Queries: []*management.ActionQuery{ + {Query: &management.ActionQuery_ActionIdQuery{ + ActionIdQuery: &action.ActionIDQuery{ + Id: helper.GetID(d, actionIDVar), + }, + }}, + }, + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read action: %v", err) + } + + if len(resp.Result) == 1 { + action := resp.Result[0] + set := map[string]interface{}{ + orgIDVar: action.GetDetails().GetResourceOwner(), + nameVar: action.GetName(), + stateVar: action.GetState(), + scriptVar: action.GetScript(), + timeoutVar: action.GetTimeout().AsDuration().String(), + allowedToFailVar: action.GetAllowedToFail(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of action: %v", k, err) + } + } + d.SetId(action.GetId()) + return nil + } + + d.SetId("") + return nil +} diff --git a/zitadel/v2/action/resource.go b/zitadel/v2/action/resource.go new file mode 100644 index 00000000..007846eb --- /dev/null +++ b/zitadel/v2/action/resource.go @@ -0,0 +1,53 @@ +package action + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an action belonging to an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + stateVar: { + Type: schema.TypeInt, + Computed: true, + Description: "the state of the action", + /* Not necessary as long as only active users are created + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return EnumValueValidation(actionState, value, action.ActionState_value) + },*/ + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + scriptVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + timeoutVar: { + Type: schema.TypeString, + Required: true, + Description: "after which time the action will be terminated if not finished", + }, + allowedToFailVar: { + Type: schema.TypeBool, + Required: true, + Description: "when true, the next action will be called even if this action fails", + }, + }, + CreateContext: create, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/app_key.go b/zitadel/v2/app_key.go deleted file mode 100644 index 9215f4b1..00000000 --- a/zitadel/v2/app_key.go +++ /dev/null @@ -1,169 +0,0 @@ -package v2 - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/timestamppb" -) - -const ( - appKeyOrgIDVar = "org_id" - appKeyProjectIDVar = "project_id" - appKeyAppIDVar = "app_id" - appKeyKeyTypeVar = "key_type" - appKeyKeyDetailsVar = "key_details" - appKeyExpirationDateVar = "expiration_date" -) - -func GetAppKey() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a app key", - Schema: map[string]*schema.Schema{ - appKeyOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - appKeyProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - appKeyAppIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the application", - ForceNew: true, - }, - appKeyKeyTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Type of the app key", - ForceNew: true, - }, - appKeyExpirationDateVar: { - Type: schema.TypeString, - Required: true, - Description: "Expiration date of the app key", - ForceNew: true, - }, - appKeyKeyDetailsVar: { - Type: schema.TypeString, - Computed: true, - Description: "Value of the app key", - Sensitive: true, - }, - }, - DeleteContext: deleteAppKey, - CreateContext: createAppKey, - ReadContext: readAppKey, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(appKeyOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveAppKey(ctx, &management2.RemoveAppKeyRequest{ - ProjectId: d.Get(appKeyProjectIDVar).(string), - AppId: d.Get(appKeyAppIDVar).(string), - KeyId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete app key: %v", err) - } - return nil -} - -func createAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(appKeyOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - t, err := time.Parse(time.RFC3339, d.Get(appKeyExpirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) - } - - keyType := d.Get(appKeyKeyTypeVar).(string) - resp, err := client.AddAppKey(ctx, &management2.AddAppKeyRequest{ - ProjectId: d.Get(appKeyProjectIDVar).(string), - AppId: d.Get(appKeyAppIDVar).(string), - Type: authn.KeyType(authn.KeyType_value[keyType]), - ExpirationDate: timestamppb.New(t), - }) - - d.SetId(resp.GetId()) - if err := d.Set(appKeyKeyDetailsVar, string(resp.GetKeyDetails())); err != nil { - return diag.FromErr(err) - } - - return nil -} - -func readAppKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(appKeyOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(appKeyProjectIDVar).(string) - appID := d.Get(appKeyAppIDVar).(string) - resp, err := client.GetAppKey(ctx, &management2.GetAppKeyRequest{ - ProjectId: projectID, - AppId: appID, - KeyId: d.Id(), - }) - if err != nil { - d.SetId("") - return nil - } - d.SetId(resp.GetKey().GetId()) - - set := map[string]interface{}{ - appKeyExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), - appKeyProjectIDVar: projectID, - appKeyAppIDVar: appID, - appKeyOrgIDVar: orgID, - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of app key: %v", k, err) - } - } - return nil -} diff --git a/zitadel/v2/app_key/const.go b/zitadel/v2/app_key/const.go new file mode 100644 index 00000000..1d150e7f --- /dev/null +++ b/zitadel/v2/app_key/const.go @@ -0,0 +1,10 @@ +package app_key + +const ( + orgIDVar = "org_id" + projectIDVar = "project_id" + appIDVar = "app_id" + keyTypeVar = "key_type" + keyDetailsVar = "key_details" + expirationDateVar = "expiration_date" +) diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/app_key/funcs.go new file mode 100644 index 00000000..89214062 --- /dev/null +++ b/zitadel/v2/app_key/funcs.go @@ -0,0 +1,114 @@ +package app_key + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveAppKey(ctx, &management.RemoveAppKeyRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Get(appIDVar).(string), + KeyId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete app key: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + + keyType := d.Get(keyTypeVar).(string) + resp, err := client.AddAppKey(ctx, &management.AddAppKeyRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Get(appIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), + ExpirationDate: timestamppb.New(t), + }) + + d.SetId(resp.GetId()) + if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + appID := d.Get(appIDVar).(string) + resp, err := client.GetAppKey(ctx, &management.GetAppKeyRequest{ + ProjectId: projectID, + AppId: appID, + KeyId: d.Id(), + }) + if err != nil { + d.SetId("") + return nil + } + d.SetId(resp.GetKey().GetId()) + + set := map[string]interface{}{ + expirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), + projectIDVar: projectID, + appIDVar: appID, + orgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of app key: %v", k, err) + } + } + return nil +} diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go new file mode 100644 index 00000000..a840e04b --- /dev/null +++ b/zitadel/v2/app_key/resource.go @@ -0,0 +1,61 @@ +package app_key + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a app key", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + appIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the application", + ForceNew: true, + }, + keyTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the app key", + ForceNew: true, + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) + }, + }, + expirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the app key", + ForceNew: true, + }, + keyDetailsVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the app key", + Sensitive: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/application_api.go b/zitadel/v2/application_api.go deleted file mode 100644 index e26f4455..00000000 --- a/zitadel/v2/application_api.go +++ /dev/null @@ -1,206 +0,0 @@ -package v2 - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -func GetApplicationAPI() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing an API application belonging to a project, with all configuration possibilities.", - Schema: map[string]*schema.Schema{ - applicationOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - ForceNew: true, - }, - applicationProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - applicationNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the application", - }, - applicationAuthMethodTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Auth method type", - }, - applicationClientID: { - Type: schema.TypeString, - Computed: true, - Description: "generated ID for this config", - Sensitive: true, - }, - applicationClientSecret: { - Type: schema.TypeString, - Computed: true, - Description: "generated secret for this config", - Sensitive: true, - }, - }, - DeleteContext: deleteApplicationAPI, - CreateContext: createApplicationAPI, - UpdateContext: updateApplicationAPI, - ReadContext: readApplicationAPI, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteApplicationAPI(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveApp(ctx, &management2.RemoveAppRequest{ - ProjectId: d.Get(applicationProjectIDVar).(string), - AppId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete applicationAPI: %v", err) - } - return nil -} - -func updateApplicationAPI(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(applicationProjectIDVar).(string) - appID := d.Id() - apiApp, err := getApp(ctx, client, projectID, appID) - - appName := d.Get(applicationNameVar).(string) - if apiApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management2.UpdateAppRequest{ - ProjectId: projectID, - AppId: d.Id(), - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) - } - } - - apiConfig := apiApp.GetApiConfig() - authMethod := d.Get(applicationAuthMethodTypeVar).(string) - if apiConfig.GetAuthMethodType().String() != authMethod { - _, err = client.UpdateAPIAppConfig(ctx, &management2.UpdateAPIAppConfigRequest{ - ProjectId: d.Get(applicationProjectIDVar).(string), - AppId: d.Id(), - AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[authMethod]), - }) - if err != nil { - return diag.Errorf("failed to update applicationAPI: %v", err) - } - } - return nil -} - -func createApplicationAPI(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.AddAPIApp(ctx, &management2.AddAPIAppRequest{ - ProjectId: d.Get(applicationProjectIDVar).(string), - Name: d.Get(applicationNameVar).(string), - AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[(d.Get(applicationAuthMethodTypeVar).(string))]), - }) - - set := map[string]interface{}{ - applicationClientID: resp.GetClientId(), - applicationClientSecret: resp.GetClientSecret(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of applicationAPI: %v", k, err) - } - } - if err != nil { - return diag.Errorf("failed to create applicationAPI: %v", err) - } - d.SetId(resp.GetAppId()) - return nil -} - -func readApplicationAPI(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - d.SetId("") - return nil - //return diag.FromErr(err) - } - - app, err := getApp(ctx, client, d.Get(applicationProjectIDVar).(string), d.Id()) - if err != nil { - return diag.Errorf("failed to read project: %v", err) - } - - api := app.GetApiConfig() - set := map[string]interface{}{ - applicationOrgIdVar: app.GetDetails().GetResourceOwner(), - applicationNameVar: app.GetName(), - applicationAuthMethodTypeVar: api.GetAuthMethodType().String(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of applicationAPI: %v", k, err) - } - } - d.SetId(app.GetId()) - return nil -} - -func getApp(ctx context.Context, client *management.Client, projectID string, appID string) (*app.App, error) { - resp, err := client.GetAppByID(ctx, &management2.GetAppByIDRequest{ProjectId: projectID, AppId: appID}) - if err != nil { - return nil, fmt.Errorf("failed to read project: %v", err) - } - - return resp.GetApp(), err -} diff --git a/zitadel/v2/application_api/const.go b/zitadel/v2/application_api/const.go new file mode 100644 index 00000000..80f99aff --- /dev/null +++ b/zitadel/v2/application_api/const.go @@ -0,0 +1,11 @@ +package application_api + +const ( + appIDVar = "app_id" + orgIDVar = "org_id" + projectIDVar = "project_id" + nameVar = "name" + authMethodTypeVar = "auth_method_type" + clientID = "client_id" + clientSecret = "client_secret" +) diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/v2/application_api/datasource.go new file mode 100644 index 00000000..dec165c1 --- /dev/null +++ b/zitadel/v2/application_api/datasource.go @@ -0,0 +1,40 @@ +package application_api + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an API application belonging to a project, with all configuration possibilities.", + Schema: map[string]*schema.Schema{ + appIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "orgID of the application", + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the application", + }, + authMethodTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Auth method type", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go new file mode 100644 index 00000000..ea8a6326 --- /dev/null +++ b/zitadel/v2/application_api/funcs.go @@ -0,0 +1,161 @@ +package application_api + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveApp(ctx, &management.RemoveAppRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete applicationAPI: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + appID := d.Id() + apiApp, err := getApp(ctx, client, projectID, appID) + + appName := d.Get(nameVar).(string) + if apiApp.GetName() != appName { + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: d.Id(), + Name: appName, + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) + } + } + + apiConfig := apiApp.GetApiConfig() + authMethod := d.Get(authMethodTypeVar).(string) + if apiConfig.GetAuthMethodType().String() != authMethod { + _, err = client.UpdateAPIAppConfig(ctx, &management.UpdateAPIAppConfigRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Id(), + AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[authMethod]), + }) + if err != nil { + return diag.Errorf("failed to update applicationAPI: %v", err) + } + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.AddAPIApp(ctx, &management.AddAPIAppRequest{ + ProjectId: d.Get(projectIDVar).(string), + Name: d.Get(nameVar).(string), + AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[(d.Get(authMethodTypeVar).(string))]), + }) + + set := map[string]interface{}{ + clientID: resp.GetClientId(), + clientSecret: resp.GetClientSecret(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationAPI: %v", k, err) + } + } + if err != nil { + return diag.Errorf("failed to create applicationAPI: %v", err) + } + d.SetId(resp.GetAppId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + app, err := getApp(ctx, client, d.Get(projectIDVar).(string), helper.GetID(d, appIDVar)) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read api applicationAPI: %v", err) + } + + api := app.GetApiConfig() + set := map[string]interface{}{ + orgIDVar: app.GetDetails().GetResourceOwner(), + nameVar: app.GetName(), + authMethodTypeVar: api.GetAuthMethodType().String(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationAPI: %v", k, err) + } + } + d.SetId(app.GetId()) + return nil +} + +func getApp(ctx context.Context, client *management2.Client, projectID string, appID string) (*app.App, error) { + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: projectID, AppId: appID}) + if err != nil { + return nil, fmt.Errorf("failed to read applicationAPI: %v", err) + } + + return resp.GetApp(), err +} diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go new file mode 100644 index 00000000..909d1adb --- /dev/null +++ b/zitadel/v2/application_api/resource.go @@ -0,0 +1,60 @@ +package application_api + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an API application belonging to a project, with all configuration possibilities.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "orgID of the application", + ForceNew: true, + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the application", + }, + authMethodTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Auth method type", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(authMethodTypeVar, value, app.APIAuthMethodType_value) + }, + }, + clientID: { + Type: schema.TypeString, + Computed: true, + Description: "generated ID for this config", + Sensitive: true, + }, + clientSecret: { + Type: schema.TypeString, + Computed: true, + Description: "generated secret for this config", + Sensitive: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/application_oidc.go b/zitadel/v2/application_oidc.go deleted file mode 100644 index 7a2bfa28..00000000 --- a/zitadel/v2/application_oidc.go +++ /dev/null @@ -1,409 +0,0 @@ -package v2 - -import ( - "context" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/durationpb" -) - -const ( - applicationOrgIdVar = "org_id" - applicationProjectIDVar = "project_id" - applicationNameVar = "name" - applicationRedirectURIsVar = "redirect_uris" - applicationResponseTypesVar = "response_types" - applicationGrantTypesVar = "grant_types" - applicationAppTypeVar = "app_type" - applicationAuthMethodTypeVar = "auth_method_type" - applicationPostLogoutRedirectURIsVar = "post_logout_redirect_uris" - applicationVersionVar = "version" - applicationDevModeVar = "dev_mode" - applicationAccessTokenTypeVar = "access_token_type" - applicationAccessTokenRoleAssertionVar = "access_token_role_assertion" - applicationIdTokenRoleAssertionVar = "id_token_role_assertion" - applicationIdTokenUserinfoAssertionVar = "id_token_userinfo_assertion" - applicationClockSkewVar = "clock_skew" - applicationAdditionalOriginsVar = "additional_origins" - applicationClientID = "client_id" - applicationClientSecret = "client_secret" -) - -func GetApplicationOIDC() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing an OIDC application belonging to a project, with all configuration possibilities.", - Schema: map[string]*schema.Schema{ - applicationOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - ForceNew: true, - }, - applicationProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - applicationNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the application", - }, - applicationRedirectURIsVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "RedirectURIs", - }, - applicationResponseTypesVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "Response type", - }, - applicationGrantTypesVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "Grant types", - }, - applicationAppTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "App type", - }, - applicationAuthMethodTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Auth method type", - }, - applicationPostLogoutRedirectURIsVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - Description: "Post logout redirect URIs", - }, - applicationVersionVar: { - Type: schema.TypeString, - Optional: true, - Description: "Version", - }, - applicationDevModeVar: { - Type: schema.TypeBool, - Optional: true, - Description: "Dev mode", - }, - applicationAccessTokenTypeVar: { - Type: schema.TypeString, - Optional: true, - Description: "Access token type", - }, - applicationAccessTokenRoleAssertionVar: { - Type: schema.TypeBool, - Optional: true, - Description: "Access token role assertion", - }, - applicationIdTokenRoleAssertionVar: { - Type: schema.TypeBool, - Optional: true, - Description: "ID token role assertion", - }, - applicationIdTokenUserinfoAssertionVar: { - Type: schema.TypeBool, - Optional: true, - Description: "Token userinfo assertion", - }, - applicationClockSkewVar: { - Type: schema.TypeString, - Required: true, - Description: "Clockskew", - }, - applicationAdditionalOriginsVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - Description: "Additional origins", - }, - applicationClientID: { - Type: schema.TypeString, - Computed: true, - Description: "generated ID for this config", - Sensitive: true, - }, - applicationClientSecret: { - Type: schema.TypeString, - Computed: true, - Description: "generated secret for this config", - Sensitive: true, - }, - }, - DeleteContext: deleteApplicationOIDC, - CreateContext: createApplicationOIDC, - UpdateContext: updateApplicationOIDC, - ReadContext: readApplicationOIDC, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteApplicationOIDC(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveApp(ctx, &management2.RemoveAppRequest{ - ProjectId: d.Get(applicationProjectIDVar).(string), - AppId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete applicationOIDC: %v", err) - } - return nil -} - -func updateApplicationOIDC(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - respTypes := make([]app.OIDCResponseType, 0) - for _, respType := range d.Get(applicationResponseTypesVar).([]interface{}) { - respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) - } - grantTypes := make([]app.OIDCGrantType, 0) - for _, grantType := range d.Get(applicationGrantTypesVar).([]interface{}) { - grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) - } - - dur, err := time.ParseDuration(d.Get(applicationClockSkewVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(applicationProjectIDVar).(string) - appID := d.Id() - apiApp, err := getApp(ctx, client, projectID, appID) - - appName := d.Get(applicationNameVar).(string) - if apiApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management2.UpdateAppRequest{ - ProjectId: projectID, - AppId: appID, - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) - } - } - - oidcConfig := apiApp.GetOidcConfig() - redirecURIs := interfaceToStringSlice(d.Get(applicationRedirectURIsVar)) - appType := d.Get(applicationAppTypeVar).(string) - authMethodType := d.Get(applicationAuthMethodTypeVar).(string) - postLogoutRedirectURIs := interfaceToStringSlice(d.Get(applicationPostLogoutRedirectURIsVar)) - devMode := d.Get(applicationDevModeVar).(bool) - accessTokenType := d.Get(applicationAccessTokenTypeVar).(string) - accessTokenRoleAssertion := d.Get(applicationAccessTokenRoleAssertionVar).(bool) - idTokenRoleAssertion := d.Get(applicationIdTokenRoleAssertionVar).(bool) - idTokenUserinfoAssertion := d.Get(applicationIdTokenUserinfoAssertionVar).(bool) - clockSkew := durationpb.New(dur) - additionalOrigins := interfaceToStringSlice(d.Get(applicationAdditionalOriginsVar)) - if !reflect.DeepEqual(redirecURIs, oidcConfig.GetRedirectUris()) || - !reflect.DeepEqual(respTypes, oidcConfig.GetResponseTypes()) || - !reflect.DeepEqual(grantTypes, oidcConfig.GetGrantTypes()) || - appType != oidcConfig.AppType.String() || - authMethodType != oidcConfig.AuthMethodType.String() || - !reflect.DeepEqual(postLogoutRedirectURIs, oidcConfig.GetPostLogoutRedirectUris()) || - devMode != oidcConfig.DevMode || - accessTokenType != oidcConfig.AccessTokenType.String() || - accessTokenRoleAssertion != oidcConfig.AccessTokenRoleAssertion || - clockSkew.String() != oidcConfig.ClockSkew.String() || - !reflect.DeepEqual(additionalOrigins, oidcConfig.GetAdditionalOrigins()) { - _, err = client.UpdateOIDCAppConfig(ctx, &management2.UpdateOIDCAppConfigRequest{ - ProjectId: projectID, - AppId: appID, - RedirectUris: redirecURIs, - ResponseTypes: respTypes, - GrantTypes: grantTypes, - AppType: app.OIDCAppType(app.OIDCAppType_value[appType]), - AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[authMethodType]), - PostLogoutRedirectUris: postLogoutRedirectURIs, - DevMode: devMode, - AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[accessTokenType]), - AccessTokenRoleAssertion: accessTokenRoleAssertion, - IdTokenRoleAssertion: idTokenRoleAssertion, - IdTokenUserinfoAssertion: idTokenUserinfoAssertion, - ClockSkew: clockSkew, - AdditionalOrigins: additionalOrigins, - }) - if err != nil { - return diag.Errorf("failed to update applicationOIDC: %v", err) - } - } - return nil -} - -func createApplicationOIDC(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - respTypes := make([]app.OIDCResponseType, 0) - for _, respType := range d.Get(applicationResponseTypesVar).([]interface{}) { - respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) - } - grantTypes := make([]app.OIDCGrantType, 0) - for _, grantType := range d.Get(applicationGrantTypesVar).([]interface{}) { - grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) - } - - dur, err := time.ParseDuration(d.Get(applicationClockSkewVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.AddOIDCApp(ctx, &management2.AddOIDCAppRequest{ - ProjectId: d.Get(applicationProjectIDVar).(string), - Name: d.Get(applicationNameVar).(string), - RedirectUris: interfaceToStringSlice(d.Get(applicationRedirectURIsVar)), - ResponseTypes: respTypes, - GrantTypes: grantTypes, - AppType: app.OIDCAppType(app.OIDCAppType_value[(d.Get(applicationAppTypeVar).(string))]), - AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[(d.Get(applicationAuthMethodTypeVar).(string))]), - PostLogoutRedirectUris: interfaceToStringSlice(d.Get(applicationPostLogoutRedirectURIsVar)), - DevMode: d.Get(applicationDevModeVar).(bool), - AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[(d.Get(applicationAccessTokenTypeVar).(string))]), - AccessTokenRoleAssertion: d.Get(applicationAccessTokenRoleAssertionVar).(bool), - IdTokenRoleAssertion: d.Get(applicationIdTokenRoleAssertionVar).(bool), - IdTokenUserinfoAssertion: d.Get(applicationIdTokenUserinfoAssertionVar).(bool), - ClockSkew: durationpb.New(dur), - AdditionalOrigins: interfaceToStringSlice(d.Get(applicationAdditionalOriginsVar)), - }) - - set := map[string]interface{}{ - applicationClientID: resp.GetClientId(), - applicationClientSecret: resp.GetClientSecret(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of applicationOIDC: %v", k, err) - } - } - - if err != nil { - return diag.Errorf("failed to create applicationOIDC: %v", err) - } - d.SetId(resp.GetAppId()) - return nil -} - -func readApplicationOIDC(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(applicationOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetAppByID(ctx, &management2.GetAppByIDRequest{ProjectId: d.Get(applicationProjectIDVar).(string), AppId: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read application: %v", err) - } - - app := resp.GetApp() - oidc := app.GetOidcConfig() - grantTypes := make([]string, 0) - for _, grantType := range oidc.GetGrantTypes() { - grantTypes = append(grantTypes, grantType.String()) - } - responseTypes := make([]string, 0) - for _, responseType := range oidc.GetResponseTypes() { - responseTypes = append(responseTypes, responseType.String()) - } - clockSkew := oidc.GetClockSkew().String() - if clockSkew == "" { - clockSkew = "0s" - } - - set := map[string]interface{}{ - applicationOrgIdVar: app.GetDetails().GetResourceOwner(), - applicationNameVar: app.GetName(), - applicationRedirectURIsVar: oidc.GetRedirectUris(), - applicationResponseTypesVar: responseTypes, - applicationGrantTypesVar: grantTypes, - applicationAppTypeVar: oidc.GetAppType().String(), - applicationAuthMethodTypeVar: oidc.GetAuthMethodType().String(), - applicationPostLogoutRedirectURIsVar: oidc.GetPostLogoutRedirectUris(), - applicationVersionVar: oidc.GetVersion().String(), - applicationDevModeVar: oidc.GetDevMode(), - applicationAccessTokenTypeVar: oidc.GetAccessTokenType().String(), - applicationAccessTokenRoleAssertionVar: oidc.GetAccessTokenRoleAssertion(), - applicationIdTokenRoleAssertionVar: oidc.GetIdTokenRoleAssertion(), - applicationIdTokenUserinfoAssertionVar: oidc.GetIdTokenUserinfoAssertion(), - applicationClockSkewVar: clockSkew, - applicationAdditionalOriginsVar: oidc.GetAdditionalOrigins(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of applicationOIDC: %v", k, err) - } - } - d.SetId(app.GetId()) - return nil -} - -func interfaceToStringSlice(in interface{}) []string { - slice := in.([]interface{}) - ret := make([]string, 0) - for _, item := range slice { - ret = append(ret, item.(string)) - } - return ret -} diff --git a/zitadel/v2/application_oidc/const.go b/zitadel/v2/application_oidc/const.go new file mode 100644 index 00000000..aa160871 --- /dev/null +++ b/zitadel/v2/application_oidc/const.go @@ -0,0 +1,24 @@ +package application_oidc + +const ( + appIDVar = "app_id" + orgIDVar = "org_id" + projectIDVar = "project_id" + nameVar = "name" + redirectURIsVar = "redirect_uris" + responseTypesVar = "response_types" + grantTypesVar = "grant_types" + appTypeVar = "app_type" + authMethodTypeVar = "auth_method_type" + postLogoutRedirectURIsVar = "post_logout_redirect_uris" + versionVar = "version" + devModeVar = "dev_mode" + accessTokenTypeVar = "access_token_type" + accessTokenRoleAssertionVar = "access_token_role_assertion" + idTokenRoleAssertionVar = "id_token_role_assertion" + idTokenUserinfoAssertionVar = "id_token_userinfo_assertion" + clockSkewVar = "clock_skew" + additionalOriginsVar = "additional_origins" + clientID = "client_id" + clientSecret = "client_secret" +) diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/v2/application_oidc/datasource.go new file mode 100644 index 00000000..fda887ad --- /dev/null +++ b/zitadel/v2/application_oidc/datasource.go @@ -0,0 +1,120 @@ +package application_oidc + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an OIDC application belonging to a project, with all configuration possibilities.", + Schema: map[string]*schema.Schema{ + appIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "orgID of the application", + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the application", + }, + redirectURIsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "RedirectURIs", + }, + responseTypesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Response type", + }, + grantTypesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Grant types", + }, + appTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "App type", + }, + authMethodTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Auth method type", + }, + postLogoutRedirectURIsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Post logout redirect URIs", + }, + versionVar: { + Type: schema.TypeString, + Computed: true, + Description: "Version", + }, + devModeVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Dev mode", + }, + accessTokenTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Access token type", + }, + accessTokenRoleAssertionVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Access token role assertion", + }, + idTokenRoleAssertionVar: { + Type: schema.TypeBool, + Computed: true, + Description: "ID token role assertion", + }, + idTokenUserinfoAssertionVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Token userinfo assertion", + }, + clockSkewVar: { + Type: schema.TypeString, + Computed: true, + Description: "Clockskew", + }, + additionalOriginsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Additional origins", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go new file mode 100644 index 00000000..968a1455 --- /dev/null +++ b/zitadel/v2/application_oidc/funcs.go @@ -0,0 +1,276 @@ +package application_oidc + +import ( + "context" + "fmt" + "reflect" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + management2 "github.com/zitadel/zitadel-go/v2/pkg/client/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveApp(ctx, &management.RemoveAppRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete applicationOIDC: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + respTypes := make([]app.OIDCResponseType, 0) + for _, respType := range d.Get(responseTypesVar).([]interface{}) { + respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) + } + grantTypes := make([]app.OIDCGrantType, 0) + for _, grantType := range d.Get(grantTypesVar).([]interface{}) { + grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) + } + + dur, err := time.ParseDuration(d.Get(clockSkewVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + appID := d.Id() + oidcApp, err := getApp(ctx, client, projectID, appID) + if err != nil { + return diag.FromErr(err) + } + + appName := d.Get(nameVar).(string) + if oidcApp.GetName() != appName { + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: appID, + Name: appName, + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) + } + } + + oidcConfig := oidcApp.GetOidcConfig() + redirecURIs := interfaceToStringSlice(d.Get(redirectURIsVar)) + appType := d.Get(appTypeVar).(string) + authMethodType := d.Get(authMethodTypeVar).(string) + postLogoutRedirectURIs := interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)) + devMode := d.Get(devModeVar).(bool) + accessTokenType := d.Get(accessTokenTypeVar).(string) + accessTokenRoleAssertion := d.Get(accessTokenRoleAssertionVar).(bool) + idTokenRoleAssertion := d.Get(idTokenRoleAssertionVar).(bool) + idTokenUserinfoAssertion := d.Get(idTokenUserinfoAssertionVar).(bool) + clockSkew := durationpb.New(dur) + additionalOrigins := interfaceToStringSlice(d.Get(additionalOriginsVar)) + if !reflect.DeepEqual(redirecURIs, oidcConfig.GetRedirectUris()) || + !reflect.DeepEqual(respTypes, oidcConfig.GetResponseTypes()) || + !reflect.DeepEqual(grantTypes, oidcConfig.GetGrantTypes()) || + appType != oidcConfig.AppType.String() || + authMethodType != oidcConfig.AuthMethodType.String() || + !reflect.DeepEqual(postLogoutRedirectURIs, oidcConfig.GetPostLogoutRedirectUris()) || + devMode != oidcConfig.DevMode || + accessTokenType != oidcConfig.AccessTokenType.String() || + accessTokenRoleAssertion != oidcConfig.AccessTokenRoleAssertion || + clockSkew.String() != oidcConfig.ClockSkew.String() || + !reflect.DeepEqual(additionalOrigins, oidcConfig.GetAdditionalOrigins()) { + _, err = client.UpdateOIDCAppConfig(ctx, &management.UpdateOIDCAppConfigRequest{ + ProjectId: projectID, + AppId: appID, + RedirectUris: redirecURIs, + ResponseTypes: respTypes, + GrantTypes: grantTypes, + AppType: app.OIDCAppType(app.OIDCAppType_value[appType]), + AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[authMethodType]), + PostLogoutRedirectUris: postLogoutRedirectURIs, + DevMode: devMode, + AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[accessTokenType]), + AccessTokenRoleAssertion: accessTokenRoleAssertion, + IdTokenRoleAssertion: idTokenRoleAssertion, + IdTokenUserinfoAssertion: idTokenUserinfoAssertion, + ClockSkew: clockSkew, + AdditionalOrigins: additionalOrigins, + }) + if err != nil { + return diag.Errorf("failed to update applicationOIDC: %v", err) + } + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + respTypes := make([]app.OIDCResponseType, 0) + for _, respType := range d.Get(responseTypesVar).([]interface{}) { + respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) + } + grantTypes := make([]app.OIDCGrantType, 0) + for _, grantType := range d.Get(grantTypesVar).([]interface{}) { + grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) + } + + dur, err := time.ParseDuration(d.Get(clockSkewVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.AddOIDCApp(ctx, &management.AddOIDCAppRequest{ + ProjectId: d.Get(projectIDVar).(string), + Name: d.Get(nameVar).(string), + RedirectUris: interfaceToStringSlice(d.Get(redirectURIsVar)), + ResponseTypes: respTypes, + GrantTypes: grantTypes, + AppType: app.OIDCAppType(app.OIDCAppType_value[(d.Get(appTypeVar).(string))]), + AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[(d.Get(authMethodTypeVar).(string))]), + PostLogoutRedirectUris: interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)), + DevMode: d.Get(devModeVar).(bool), + AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[(d.Get(accessTokenTypeVar).(string))]), + AccessTokenRoleAssertion: d.Get(accessTokenRoleAssertionVar).(bool), + IdTokenRoleAssertion: d.Get(idTokenRoleAssertionVar).(bool), + IdTokenUserinfoAssertion: d.Get(idTokenUserinfoAssertionVar).(bool), + ClockSkew: durationpb.New(dur), + AdditionalOrigins: interfaceToStringSlice(d.Get(additionalOriginsVar)), + }) + + set := map[string]interface{}{ + clientID: resp.GetClientId(), + clientSecret: resp.GetClientSecret(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationOIDC: %v", k, err) + } + } + + if err != nil { + return diag.Errorf("failed to create applicationOIDC: %v", err) + } + d.SetId(resp.GetAppId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + oidcApp, err := getApp(ctx, client, projectID, helper.GetID(d, appIDVar)) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read application: %v", err) + } + + oidc := oidcApp.GetOidcConfig() + grantTypes := make([]string, 0) + for _, grantType := range oidc.GetGrantTypes() { + grantTypes = append(grantTypes, grantType.String()) + } + responseTypes := make([]string, 0) + for _, responseType := range oidc.GetResponseTypes() { + responseTypes = append(responseTypes, responseType.String()) + } + clockSkew := oidc.GetClockSkew().String() + if clockSkew == "" { + clockSkew = "0s" + } + + set := map[string]interface{}{ + orgIDVar: oidcApp.GetDetails().GetResourceOwner(), + nameVar: oidcApp.GetName(), + redirectURIsVar: oidc.GetRedirectUris(), + responseTypesVar: responseTypes, + grantTypesVar: grantTypes, + appTypeVar: oidc.GetAppType().String(), + authMethodTypeVar: oidc.GetAuthMethodType().String(), + postLogoutRedirectURIsVar: oidc.GetPostLogoutRedirectUris(), + versionVar: oidc.GetVersion().String(), + devModeVar: oidc.GetDevMode(), + accessTokenTypeVar: oidc.GetAccessTokenType().String(), + accessTokenRoleAssertionVar: oidc.GetAccessTokenRoleAssertion(), + idTokenRoleAssertionVar: oidc.GetIdTokenRoleAssertion(), + idTokenUserinfoAssertionVar: oidc.GetIdTokenUserinfoAssertion(), + clockSkewVar: clockSkew, + additionalOriginsVar: oidc.GetAdditionalOrigins(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of applicationOIDC: %v", k, err) + } + } + d.SetId(oidcApp.GetId()) + return nil +} + +func interfaceToStringSlice(in interface{}) []string { + slice := in.([]interface{}) + ret := make([]string, 0) + for _, item := range slice { + ret = append(ret, item.(string)) + } + return ret +} + +func getApp(ctx context.Context, client *management2.Client, projectID string, appID string) (*app.App, error) { + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: projectID, AppId: appID}) + if err != nil { + return nil, fmt.Errorf("failed to read project: %v", err) + } + + return resp.GetApp(), err +} diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go new file mode 100644 index 00000000..e6ca4825 --- /dev/null +++ b/zitadel/v2/application_oidc/resource.go @@ -0,0 +1,154 @@ +package application_oidc + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an OIDC application belonging to a project, with all configuration possibilities.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "orgID of the application", + ForceNew: true, + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the application", + }, + redirectURIsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "RedirectURIs", + }, + responseTypesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "Response type", + /* Not yet supported + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return enumValuesValidation(applicationAuthMethodTypeVar, value, app.OIDCResponseType_value) + },*/ + }, + grantTypesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "Grant types", + /* Not yet supported + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return enumValuesValidation(applicationGrantTypesVar, value, app.OIDCGrantType_value) + },*/ + }, + appTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "App type", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(appTypeVar, value, app.OIDCAppType_value) + }, + }, + authMethodTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Auth method type", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(authMethodTypeVar, value, app.OIDCAuthMethodType_value) + }, + }, + postLogoutRedirectURIsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "Post logout redirect URIs", + }, + versionVar: { + Type: schema.TypeString, + Optional: true, + Description: "Version", + }, + devModeVar: { + Type: schema.TypeBool, + Optional: true, + Description: "Dev mode", + }, + accessTokenTypeVar: { + Type: schema.TypeString, + Optional: true, + Description: "Access token type", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(accessTokenTypeVar, value, app.OIDCTokenType_value) + }, + }, + accessTokenRoleAssertionVar: { + Type: schema.TypeBool, + Optional: true, + Description: "Access token role assertion", + }, + idTokenRoleAssertionVar: { + Type: schema.TypeBool, + Optional: true, + Description: "ID token role assertion", + }, + idTokenUserinfoAssertionVar: { + Type: schema.TypeBool, + Optional: true, + Description: "Token userinfo assertion", + }, + clockSkewVar: { + Type: schema.TypeString, + Required: true, + Description: "Clockskew", + }, + additionalOriginsVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "Additional origins", + }, + clientID: { + Type: schema.TypeString, + Computed: true, + Description: "generated ID for this config", + Sensitive: true, + }, + clientSecret: { + Type: schema.TypeString, + Computed: true, + Description: "generated secret for this config", + Sensitive: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/domain.go b/zitadel/v2/domain.go deleted file mode 100644 index 05049d5c..00000000 --- a/zitadel/v2/domain.go +++ /dev/null @@ -1,157 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" -) - -const ( - domainOrgIdVar = "org_id" - domainNameVar = "name" - domainIsVerified = "is_verified" - domainIsPrimary = "is_primary" - domainValidationType = "validation_type" -) - -func GetDomain() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a domain of the organization.", - Schema: map[string]*schema.Schema{ - domainNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the domain", - ForceNew: true, - }, - domainOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - domainIsVerified: { - Type: schema.TypeBool, - Computed: true, - Description: "Is domain verified", - }, - domainIsPrimary: { - Type: schema.TypeBool, - Computed: true, - Description: "Is domain primary", - }, - domainValidationType: { - Type: schema.TypeInt, - Computed: true, - Description: "Validation type", - }, - }, - ReadContext: readDomain, - CreateContext: createDomain, - DeleteContext: deleteDomain, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteDomain(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(domainOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveOrgDomain(ctx, &management2.RemoveOrgDomainRequest{ - Domain: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete domain: %v", err) - } - return nil -} - -func createDomain(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(domainOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - name := d.Get(domainNameVar).(string) - _, err = client.AddOrgDomain(ctx, &management2.AddOrgDomainRequest{ - Domain: name, - }) - if err != nil { - return diag.Errorf("failed to create domain: %v", err) - } - d.SetId(name) - return nil -} - -func readDomain(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(domainOrgIdVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.ListOrgDomains(ctx, &management2.ListOrgDomainsRequest{ - Queries: []*org.DomainSearchQuery{ - {Query: &org.DomainSearchQuery_DomainNameQuery{ - DomainNameQuery: &org.DomainNameQuery{ - Name: d.Id(), - Method: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS, - }, - }, - }, - }, - }) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read domain: %v", err) - } - - if len(resp.Result) == 1 { - domain := resp.Result[0] - set := map[string]interface{}{ - domainNameVar: domain.GetDomainName(), - domainOrgIdVar: domain.GetOrgId(), - domainIsVerified: domain.GetIsVerified(), - domainIsPrimary: domain.GetIsPrimary(), - domainValidationType: domain.GetValidationType().Number(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of domain: %v", k, err) - } - } - d.SetId(domain.GetDomainName()) - return nil - } - - d.SetId("") - return nil -} diff --git a/zitadel/v2/domain/const.go b/zitadel/v2/domain/const.go new file mode 100644 index 00000000..80d8a9ed --- /dev/null +++ b/zitadel/v2/domain/const.go @@ -0,0 +1,9 @@ +package domain + +const ( + orgIDVar = "org_id" + nameVar = "name" + isVerifiedVar = "is_verified" + isPrimaryVar = "is_primary" + validationTypeVar = "validation_type" +) diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go new file mode 100644 index 00000000..0d8e72a5 --- /dev/null +++ b/zitadel/v2/domain/funcs.go @@ -0,0 +1,112 @@ +package domain + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrgDomain(ctx, &management.RemoveOrgDomainRequest{ + Domain: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete domain: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + name := d.Get(nameVar).(string) + _, err = client.AddOrgDomain(ctx, &management.AddOrgDomainRequest{ + Domain: name, + }) + if err != nil { + return diag.Errorf("failed to create domain: %v", err) + } + d.SetId(name) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.ListOrgDomains(ctx, &management.ListOrgDomainsRequest{ + Queries: []*org.DomainSearchQuery{ + {Query: &org.DomainSearchQuery_DomainNameQuery{ + DomainNameQuery: &org.DomainNameQuery{ + Name: d.Id(), + Method: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS, + }, + }, + }, + }, + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read domain: %v", err) + } + + if len(resp.Result) == 1 { + domain := resp.Result[0] + set := map[string]interface{}{ + nameVar: domain.GetDomainName(), + orgIDVar: domain.GetOrgId(), + isVerifiedVar: domain.GetIsVerified(), + isPrimaryVar: domain.GetIsPrimary(), + validationTypeVar: domain.GetValidationType().Number(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of domain: %v", k, err) + } + } + d.SetId(domain.GetDomainName()) + return nil + } + + d.SetId("") + return nil +} diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go new file mode 100644 index 00000000..73fd2680 --- /dev/null +++ b/zitadel/v2/domain/resource.go @@ -0,0 +1,44 @@ +package domain + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a domain of the organization.", + Schema: map[string]*schema.Schema{ + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the domain", + ForceNew: true, + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + isVerifiedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Is domain verified", + }, + isPrimaryVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Is domain primary", + }, + validationTypeVar: { + Type: schema.TypeInt, + Computed: true, + Description: "Validation type", + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/domain_policy.go b/zitadel/v2/domain_policy.go deleted file mode 100644 index 72a8a8c5..00000000 --- a/zitadel/v2/domain_policy.go +++ /dev/null @@ -1,170 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - admin2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - domainPolicyOrgIdVar = "org_id" - domainPolicyUserLoginMustBeDomain = "user_login_must_be_domain" - domainPolicyValidateOrgDomain = "validate_org_domains" - domainPolicySmtpSender = "smtp_sender_address_matches_instance_domain" -) - -func GetDomainPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom domain policy of an organization.", - Schema: map[string]*schema.Schema{ - domainPolicyOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, - domainPolicyUserLoginMustBeDomain: { - Type: schema.TypeBool, - Required: true, - Description: "User login must be domain", - }, - domainPolicyValidateOrgDomain: { - Type: schema.TypeBool, - Required: true, - Description: "Validate organization domains", - }, - domainPolicySmtpSender: { - Type: schema.TypeBool, - Required: true, - Description: "", - }, - }, - ReadContext: readDomainPolicy, - CreateContext: createDomainPolicy, - DeleteContext: deleteDomainPolicy, - UpdateContext: updateDomainPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getAdminClient(clientinfo) - if err != nil { - return diag.FromErr(err) - } - org := d.Get(domainPolicyOrgIdVar).(string) - - _, err = client.ResetCustomDomainPolicyToDefault(ctx, &admin2.ResetCustomDomainPolicyToDefaultRequest{ - OrgId: org, - }) - if err != nil { - return diag.Errorf("failed to reset domain policy: %v", err) - } - return nil -} - -func updateDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getAdminClient(clientinfo) - if err != nil { - return diag.FromErr(err) - } - org := d.Get(domainPolicyOrgIdVar).(string) - - _, err = client.UpdateCustomDomainPolicy(ctx, &admin2.UpdateCustomDomainPolicyRequest{ - OrgId: org, - UserLoginMustBeDomain: d.Get(domainPolicyUserLoginMustBeDomain).(bool), - ValidateOrgDomains: d.Get(domainPolicyValidateOrgDomain).(bool), - SmtpSenderAddressMatchesInstanceDomain: d.Get(domainPolicySmtpSender).(bool), - }) - if err != nil { - return diag.Errorf("failed to update domain policy: %v", err) - } - d.SetId(org) - return nil -} - -func createDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getAdminClient(clientinfo) - if err != nil { - return diag.FromErr(err) - } - org := d.Get(domainPolicyOrgIdVar).(string) - - _, err = client.AddCustomDomainPolicy(ctx, &admin2.AddCustomDomainPolicyRequest{ - OrgId: org, - UserLoginMustBeDomain: d.Get(domainPolicyUserLoginMustBeDomain).(bool), - ValidateOrgDomains: d.Get(domainPolicyValidateOrgDomain).(bool), - SmtpSenderAddressMatchesInstanceDomain: d.Get(domainPolicySmtpSender).(bool), - }) - if err != nil { - return diag.Errorf("failed to create domain policy: %v", err) - } - d.SetId(org) - return nil -} - -func readDomainPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(domainPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetDomainPolicy(ctx, &management2.GetDomainPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get domain policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - domainPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - domainPolicyUserLoginMustBeDomain: policy.GetUserLoginMustBeDomain(), - domainPolicyValidateOrgDomain: policy.GetValidateOrgDomains(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of domain: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/domain_policy/const.go b/zitadel/v2/domain_policy/const.go new file mode 100644 index 00000000..422a290e --- /dev/null +++ b/zitadel/v2/domain_policy/const.go @@ -0,0 +1,8 @@ +package domain_policy + +const ( + orgIDVar = "org_id" + userLoginMustBeDomainVar = "user_login_must_be_domain" + validateOrgDomainVar = "validate_org_domains" + smtpSenderVar = "smtp_sender_address_matches_instance_domain" +) diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go new file mode 100644 index 00000000..3d411a7d --- /dev/null +++ b/zitadel/v2/domain_policy/funcs.go @@ -0,0 +1,131 @@ +package domain_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + org := d.Get(orgIDVar).(string) + + _, err = client.ResetCustomDomainPolicyToDefault(ctx, &admin.ResetCustomDomainPolicyToDefaultRequest{ + OrgId: org, + }) + if err != nil { + return diag.Errorf("failed to reset domain policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + org := d.Get(orgIDVar).(string) + + _, err = client.UpdateCustomDomainPolicy(ctx, &admin.UpdateCustomDomainPolicyRequest{ + OrgId: org, + UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), + SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update domain policy: %v", err) + } + d.SetId(org) + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + org := d.Get(orgIDVar).(string) + + _, err = client.AddCustomDomainPolicy(ctx, &admin.AddCustomDomainPolicyRequest{ + OrgId: org, + UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), + SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create domain policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetDomainPolicy(ctx, &management.GetDomainPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get domain policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), + validateOrgDomainVar: policy.GetValidateOrgDomains(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of domain: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/v2/domain_policy/resource.go new file mode 100644 index 00000000..08edb597 --- /dev/null +++ b/zitadel/v2/domain_policy/resource.go @@ -0,0 +1,39 @@ +package domain_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom domain policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + userLoginMustBeDomainVar: { + Type: schema.TypeBool, + Required: true, + Description: "User login must be domain", + }, + validateOrgDomainVar: { + Type: schema.TypeBool, + Required: true, + Description: "Validate organization domains", + }, + smtpSenderVar: { + Type: schema.TypeBool, + Required: true, + Description: "", + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/helper.go b/zitadel/v2/helper.go deleted file mode 100644 index b8630336..00000000 --- a/zitadel/v2/helper.go +++ /dev/null @@ -1,54 +0,0 @@ -package v2 - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -type stringified struct { - str string -} - -func (s *stringified) String() string { - return s.str -} - -type stringify interface { - String() string -} - -func setToStringSlice(set *schema.Set) []string { - slice := make([]string, 0) - for _, secondFactor := range set.List() { - slice = append(slice, secondFactor.(string)) - } - return slice -} - -func getAddAndDelete(current []stringify, desired []string) ([]string, []string) { - addSlice := make([]string, 0) - deleteSlice := make([]string, 0) - - for _, desiredItem := range desired { - found := false - for _, currentItem := range current { - if desiredItem == currentItem.String() { - found = true - } - } - if !found { - addSlice = append(addSlice, desiredItem) - } - } - - for _, currentItem := range current { - found := false - for _, desiredItem := range desired { - if desiredItem == currentItem.String() { - found = true - } - } - if !found { - deleteSlice = append(deleteSlice, currentItem.String()) - } - } - - return addSlice, deleteSlice -} diff --git a/zitadel/v2/client.go b/zitadel/v2/helper/client.go similarity index 93% rename from zitadel/v2/client.go rename to zitadel/v2/helper/client.go index 183a482d..c9d75064 100644 --- a/zitadel/v2/client.go +++ b/zitadel/v2/helper/client.go @@ -1,4 +1,4 @@ -package v2 +package helper import ( "fmt" @@ -62,7 +62,7 @@ func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { }, nil } -func getAdminClient(info *ClientInfo) (*admin.Client, error) { +func GetAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( info.Issuer, info.Domain, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}, @@ -75,7 +75,7 @@ func getAdminClient(info *ClientInfo) (*admin.Client, error) { return client, nil } -func getManagementClient(info *ClientInfo, orgID string) (*management.Client, error) { +func GetManagementClient(info *ClientInfo, orgID string) (*management.Client, error) { options := info.Options if orgID != "" { options = append(options, zitadel.WithOrgID(orgID)) diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go new file mode 100644 index 00000000..a389519b --- /dev/null +++ b/zitadel/v2/helper/helper.go @@ -0,0 +1,96 @@ +package helper + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +type Stringified struct { + Str string +} + +func (s *Stringified) String() string { + return s.Str +} + +type Stringify interface { + String() string +} + +func SetToStringSlice(set *schema.Set) []string { + slice := make([]string, 0) + for _, secondFactor := range set.List() { + slice = append(slice, secondFactor.(string)) + } + return slice +} + +func GetAddAndDelete(current []Stringify, desired []string) ([]string, []string) { + addSlice := make([]string, 0) + deleteSlice := make([]string, 0) + + for _, desiredItem := range desired { + found := false + for _, currentItem := range current { + if desiredItem == currentItem.String() { + found = true + } + } + if !found { + addSlice = append(addSlice, desiredItem) + } + } + + for _, currentItem := range current { + found := false + for _, desiredItem := range desired { + if desiredItem == currentItem.String() { + found = true + } + } + if !found { + deleteSlice = append(deleteSlice, currentItem.String()) + } + } + + return addSlice, deleteSlice +} + +func EnumValuesValidation(ty string, checkValuesSet interface{}, enumValues map[string]int32) diag.Diagnostics { + values, ok := checkValuesSet.(*schema.Set) + if !ok { + return diag.Errorf("Attribute %s is no set for enum value check", ty) + } + + for _, value := range values.List() { + _, ok := enumValues[value.(string)] + if !ok { + return diag.Errorf("Attribute %s has unsupported enum value \"%s\"", ty, value) + } + } + return nil +} + +func EnumValueValidation(ty string, checkValue interface{}, enumValues map[string]int32) diag.Diagnostics { + value, ok := checkValue.(string) + if !ok { + return diag.Errorf("Attribute %s is no string for enum value check", ty) + } + + _, ok = enumValues[value] + if !ok { + return diag.Errorf("Attribute %s has unsupported enum value \"%s\"", ty, value) + } + return nil +} + +func GetID(d *schema.ResourceData, idVar string) string { + idStr := "" + id, ok := d.GetOk(idVar) + if ok { + idStr = id.(string) + } else { + idStr = d.Id() + } + return idStr +} diff --git a/zitadel/v2/human_user/const.go b/zitadel/v2/human_user/const.go new file mode 100644 index 00000000..84519b75 --- /dev/null +++ b/zitadel/v2/human_user/const.go @@ -0,0 +1,28 @@ +package human_user + +const ( + userIDVar = "user_id" + orgIDVar = "org_id" + userStateVar = "state" + userNameVar = "user_name" + loginNamesVar = "login_names" + preferredLoginNameVar = "preferred_login_name" + + firstNameVar = "first_name" + lastNameVar = "last_name" + nickNameVar = "nick_name" + displayNameVar = "display_name" + preferredLanguageVar = "preferred_language" + genderVar = "gender" + + isEmailVerifiedVar = "is_email_verified" + emailVar = "email" + + isPhoneVerifiedVar = "is_phone_verified" + phoneVar = "phone" + + initialPasswordVar = "initial_password" + + defaultGenderString = "GENDER_UNSPECIFIED" + defaultPreferredLanguage = "und" +) diff --git a/zitadel/v2/human_user/datasource.go b/zitadel/v2/human_user/datasource.go new file mode 100644 index 00000000..1ad13f91 --- /dev/null +++ b/zitadel/v2/human_user/datasource.go @@ -0,0 +1,98 @@ +package human_user + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", + Schema: map[string]*schema.Schema{ + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + userStateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the user", + }, + userNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Username", + }, + loginNamesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Loginnames", + }, + preferredLoginNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Preferred login name", + }, + firstNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "First name of the user", + }, + lastNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Last name of the user", + }, + nickNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Nick name of the user", + }, + displayNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the user", + }, + preferredLanguageVar: { + Type: schema.TypeString, + Description: "Preferred language of the user", + Computed: true, + }, + genderVar: { + Type: schema.TypeString, + Description: "Gender of the user", + Computed: true, + }, + emailVar: { + Type: schema.TypeString, + Computed: true, + Description: "Email of the user", + }, + isEmailVerifiedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Is the email verified of the user, can only be true if password of the user is set", + }, + phoneVar: { + Type: schema.TypeString, + Computed: true, + Description: "Phone of the user", + }, + isPhoneVerifiedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Is the phone verified of the user", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go new file mode 100644 index 00000000..b9e215e4 --- /dev/null +++ b/zitadel/v2/human_user/funcs.go @@ -0,0 +1,274 @@ +package human_user + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveUser(ctx, &management.RemoveUserRequest{ + Id: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete user: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + firstName := d.Get(firstNameVar).(string) + lastName := d.Get(lastNameVar).(string) + addUser := &management.AddHumanUserRequest{ + UserName: d.Get(userNameVar).(string), + Profile: &management.AddHumanUserRequest_Profile{ + FirstName: firstName, + LastName: lastName, + }, + } + + nickname := d.Get(nickNameVar).(string) + if nickname != "" { + addUser.Profile.NickName = nickname + } + + displayname := d.Get(displayNameVar).(string) + if displayname != "" { + addUser.Profile.DisplayName = displayname + } else { + if err := d.Set(displayNameVar, defaultDisplayName(firstName, lastName)); err != nil { + return diag.Errorf("failed to set default display name for human user: %v", err) + } + } + + prefLang := d.Get(preferredLanguageVar).(string) + if prefLang != "" { + addUser.Profile.PreferredLanguage = prefLang + } else { + if err := d.Set(preferredLanguageVar, defaultPreferredLanguage); err != nil { + return diag.Errorf("failed to set default preferred language for human user: %v", err) + } + } + + gender := d.Get(genderVar).(string) + if gender != "" { + addUser.Profile.Gender = user.Gender(user.Gender_value[gender]) + } else { + if err := d.Set(genderVar, defaultGenderString); err != nil { + return diag.Errorf("failed to set default gender for human user: %v", err) + } + } + + pwd := d.Get(initialPasswordVar).(string) + if pwd != "" { + addUser.InitialPassword = pwd + } + + email := d.Get(emailVar).(string) + if email != "" { + isVerified := d.Get(isEmailVerifiedVar) + addUser.Email = &management.AddHumanUserRequest_Email{ + Email: email, + IsEmailVerified: false, + } + if isVerified != nil { + addUser.Email.IsEmailVerified = isVerified.(bool) + } + } + + phone := d.Get(phoneVar).(string) + if phone != "" { + isVerified := d.Get(isPhoneVerifiedVar) + addUser.Phone = &management.AddHumanUserRequest_Phone{ + Phone: phone, + IsPhoneVerified: false, + } + if isVerified != nil { + addUser.Phone.IsPhoneVerified = isVerified.(bool) + } + } + + respUser, err := client.AddHumanUser(ctx, addUser) + if err != nil { + return diag.Errorf("failed to create human user: %v", err) + } + d.SetId(respUser.UserId) + + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + currentUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: d.Id()}) + if err != nil { + return diag.FromErr(err) + } + + username := d.Get(userNameVar).(string) + if currentUser.GetUser().GetUserName() != username { + _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ + UserId: d.Id(), + UserName: username, + }) + if err != nil { + return diag.Errorf("failed to update username: %v", err) + } + } + + nickname := d.Get(nickNameVar) + displayname := d.Get(displayNameVar) + prefLang := d.Get(preferredLanguageVar) + gender := d.Get(genderVar) + email := d.Get(emailVar) + emailVerfied := d.Get(isEmailVerifiedVar) + phone := d.Get(phoneVar) + phoneVerified := d.Get(isPhoneVerifiedVar) + + currentHuman := currentUser.GetUser().GetHuman() + if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || + currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || + (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || + (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || + (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || + (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { + + _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ + UserId: d.Id(), + FirstName: d.Get(firstNameVar).(string), + LastName: d.Get(lastNameVar).(string), + NickName: d.Get(nickNameVar).(string), + DisplayName: d.Get(displayNameVar).(string), + PreferredLanguage: d.Get(preferredLanguageVar).(string), + Gender: user.Gender(user.Gender_value[gender.(string)]), + }) + if err != nil { + return diag.Errorf("failed to update human profile: %v", err) + } + } + + if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { + _, err = client.UpdateHumanEmail(ctx, &management.UpdateHumanEmailRequest{ + UserId: d.Id(), + Email: email.(string), + IsEmailVerified: emailVerfied.(bool), + }) + if err != nil { + return diag.Errorf("failed to update human email: %v", err) + } + } + + if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { + _, err = client.UpdateHumanPhone(ctx, &management.UpdateHumanPhoneRequest{ + UserId: d.Id(), + Phone: phone.(string), + IsPhoneVerified: phoneVerified.(bool), + }) + if err != nil { + return diag.Errorf("failed to update human phone: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get list of users: %v", err) + } + + user := respUser.GetUser() + set := map[string]interface{}{ + orgIDVar: user.GetDetails().GetResourceOwner(), + userStateVar: user.GetState().String(), + userNameVar: user.GetUserName(), + loginNamesVar: user.GetLoginNames(), + preferredLoginNameVar: user.GetPreferredLoginName(), + } + + if human := user.GetHuman(); human != nil { + if profile := human.GetProfile(); profile != nil { + set[firstNameVar] = profile.GetFirstName() + set[lastNameVar] = profile.GetLastName() + set[displayNameVar] = profile.GetDisplayName() + set[nickNameVar] = profile.GetNickName() + set[preferredLanguageVar] = profile.GetPreferredLanguage() + if gender := profile.GetGender().String(); gender != "" { + set[genderVar] = gender + } + } + if email := human.GetEmail(); email != nil { + set[emailVar] = email.GetEmail() + set[isEmailVerifiedVar] = email.GetIsEmailVerified() + } + if phone := human.GetPhone(); phone != nil { + set[phoneVar] = phone.GetPhone() + set[isPhoneVerifiedVar] = phone.GetIsPhoneVerified() + } + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of user: %v", k, err) + } + } + d.SetId(user.GetId()) + return nil +} + +func defaultDisplayName(firstName, lastName string) string { + return firstName + " " + lastName +} diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go new file mode 100644 index 00000000..33b53730 --- /dev/null +++ b/zitadel/v2/human_user/resource.go @@ -0,0 +1,150 @@ +package human_user + +import ( + "context" + + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + userStateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the user", + /* Not necessary as long as only active users are created + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return EnumValueValidation(userStateVar, value.(string), user.UserState_value) + },*/ + }, + userNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Username", + }, + loginNamesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Loginnames", + ForceNew: true, + }, + preferredLoginNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Preferred login name", + ForceNew: true, + }, + + firstNameVar: { + Type: schema.TypeString, + Required: true, + Description: "First name of the user", + }, + lastNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Last name of the user", + }, + nickNameVar: { + Type: schema.TypeString, + Optional: true, + Description: "Nick name of the user", + }, + displayNameVar: { + Type: schema.TypeString, + Optional: true, + Description: "Display name of the user", + Computed: true, + }, + preferredLanguageVar: { + Type: schema.TypeString, + Optional: true, + Description: "Preferred language of the user", + Computed: true, + }, + genderVar: { + Type: schema.TypeString, + Optional: true, + Description: "Gender of the user", + Computed: true, + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(genderVar, value.(string), user.Gender_value) + }, + }, + emailVar: { + Type: schema.TypeString, + Required: true, + Description: "Email of the user", + }, + isEmailVerifiedVar: { + Type: schema.TypeBool, + Optional: true, + Description: "Is the email verified of the user, can only be true if password of the user is set", + }, + phoneVar: { + Type: schema.TypeString, + Optional: true, + Description: "Phone of the user", + }, + isPhoneVerifiedVar: { + Type: schema.TypeBool, + Optional: true, + Description: "Is the phone verified of the user", + }, + initialPasswordVar: { + Type: schema.TypeString, + Optional: true, + Description: "Initially set password for the user, not changeable after creation", + Sensitive: true, + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + UpdateContext: update, + CustomizeDiff: customdiff.All( + customdiff.IfValue(displayNameVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(displayNameVar, defaultDisplayName(diff.Get(firstNameVar).(string), diff.Get(lastNameVar).(string))) + }), + customdiff.IfValue(genderVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(genderVar, defaultGenderString) + }), + customdiff.IfValue(preferredLanguageVar, func(ctx context.Context, value, meta interface{}) bool { + if value == "" { + return true + } + return false + }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { + return diff.SetNew(preferredLanguageVar, defaultPreferredLanguage) + }), + ), + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/idp_jwt.go b/zitadel/v2/idp_jwt.go deleted file mode 100644 index 5568c7d7..00000000 --- a/zitadel/v2/idp_jwt.go +++ /dev/null @@ -1,203 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - idpJwtEndpoint = "jwt_endpoint" - idpKeysEndpoint = "keys_endpoint" - idpHeaderName = "header_name" -) - -func GetOrgJWTIDP() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a domain of the organization.", - Schema: map[string]*schema.Schema{ - idpOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idpNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idpStylingTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Some identity providers specify the styling of the button to their login", - }, - idpJwtEndpoint: { - Type: schema.TypeString, - Required: true, - Description: "the endpoint where the jwt can be extracted", - }, - idpKeysEndpoint: { - Type: schema.TypeString, - Required: true, - Description: "the endpoint to the key (JWK) which are used to sign the JWT with", - }, - idpIssuerVar: { - Type: schema.TypeString, - Required: true, - Description: "the issuer of the jwt (for validation)", - }, - idpHeaderName: { - Type: schema.TypeString, - Required: true, - Description: "the name of the header where the JWT is sent in, default is authorization", - }, - idpAutoRegister: { - Type: schema.TypeBool, - Required: true, - Description: "auto register for users from this idp", - }, - }, - ReadContext: readOrgJWTIDP, - CreateContext: createOrgJWTIDP, - UpdateContext: updateOrgJWTIDP, - DeleteContext: deleteOrgIDP, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} -func createOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - stylingType := d.Get(idpStylingTypeVar) - resp, err := client.AddOrgJWTIDP(ctx, &management2.AddOrgJWTIDPRequest{ - Name: d.Get(idpNameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), - JwtEndpoint: d.Get(idpJwtEndpoint).(string), - Issuer: d.Get(idpIssuerVar).(string), - KeysEndpoint: d.Get(idpKeysEndpoint).(string), - HeaderName: d.Get(idpHeaderName).(string), - AutoRegister: d.Get(idpAutoRegister).(bool), - }) - if err != nil { - return diag.Errorf("failed to create jwt idp: %v", err) - } - d.SetId(resp.IdpId) - return nil -} - -func updateOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Get("id").(string)}) - if err != nil { - return diag.Errorf("failed to read jwt idp: %v", err) - } - - idpID := d.Id() - name := d.Get(idpNameVar).(string) - stylingType := d.Get(idpStylingTypeVar).(string) - autoRegister := d.Get(idpAutoRegister).(bool) - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - _, err := client.UpdateOrgIDP(ctx, &management2.UpdateOrgIDPRequest{ - IdpId: idpID, - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp: %v", err) - } - } - - jwt := resp.GetIdp().GetJwtConfig() - jwtEndpoint := d.Get(idpJwtEndpoint).(string) - issuer := d.Get(idpIssuerVar).(string) - keysEndpoint := d.Get(idpKeysEndpoint).(string) - headerName := d.Get(idpHeaderName).(string) - - //either nothing changed on the IDP or something besides the secret changed - if jwt.GetJwtEndpoint() != jwtEndpoint || - jwt.GetIssuer() != issuer || - jwt.GetKeysEndpoint() != keysEndpoint || - jwt.GetHeaderName() != headerName { - - _, err = client.UpdateOrgIDPJWTConfig(ctx, &management2.UpdateOrgIDPJWTConfigRequest{ - IdpId: idpID, - JwtEndpoint: jwtEndpoint, - Issuer: issuer, - KeysEndpoint: keysEndpoint, - HeaderName: headerName, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp config: %v", err) - } - } - return nil -} - -func readOrgJWTIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read jwt idp: %v", err) - } - - idp := resp.GetIdp() - jwt := idp.GetJwtConfig() - set := map[string]interface{}{ - idpOrgIDVar: idp.GetDetails().ResourceOwner, - idpNameVar: idp.GetName(), - idpStylingTypeVar: idp.GetStylingType().String(), - idpJwtEndpoint: jwt.GetJwtEndpoint(), - idpIssuerVar: jwt.GetIssuer(), - idpKeysEndpoint: jwt.GetKeysEndpoint(), - idpHeaderName: jwt.GetHeaderName(), - idpAutoRegister: idp.GetAutoRegister(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of jwt idp: %v", k, err) - } - } - d.SetId(idp.Id) - return nil -} diff --git a/zitadel/v2/idp_jwt/const.go b/zitadel/v2/idp_jwt/const.go new file mode 100644 index 00000000..daa64cbd --- /dev/null +++ b/zitadel/v2/idp_jwt/const.go @@ -0,0 +1,13 @@ +package idp_jwt + +const ( + idpIDVar = "idp_id" + orgIDVar = "org_id" + nameVar = "name" + stylingTypeVar = "styling_type" + issuerVar = "issuer" + autoRegisterVar = "auto_register" + jwtEndpointVar = "jwt_endpoint" + keysEndpointVar = "keys_endpoint" + headerNameVar = "header_name" +) diff --git a/zitadel/v2/idp_jwt/datasource.go b/zitadel/v2/idp_jwt/datasource.go new file mode 100644 index 00000000..261a4489 --- /dev/null +++ b/zitadel/v2/idp_jwt/datasource.go @@ -0,0 +1,60 @@ +package idp_jwt + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a domain of the organization.", + Schema: map[string]*schema.Schema{ + idpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + stylingTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Some identity providers specify the styling of the button to their login", + }, + jwtEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the endpoint where the jwt can be extracted", + }, + keysEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the endpoint to the key (JWK) which are used to sign the JWT with", + }, + issuerVar: { + Type: schema.TypeString, + Computed: true, + Description: "the issuer of the jwt (for validation)", + }, + headerNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "the name of the header where the JWT is sent in, default is authorization", + }, + autoRegisterVar: { + Type: schema.TypeBool, + Computed: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/idp_jwt/funcs.go b/zitadel/v2/idp_jwt/funcs.go new file mode 100644 index 00000000..75f93e24 --- /dev/null +++ b/zitadel/v2/idp_jwt/funcs.go @@ -0,0 +1,168 @@ +package idp_jwt + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrgIDP(ctx, &management.RemoveOrgIDPRequest{ + IdpId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete oidc idp: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + stylingType := d.Get(stylingTypeVar) + resp, err := client.AddOrgJWTIDP(ctx, &management.AddOrgJWTIDPRequest{ + Name: d.Get(nameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + JwtEndpoint: d.Get(jwtEndpointVar).(string), + Issuer: d.Get(issuerVar).(string), + KeysEndpoint: d.Get(keysEndpointVar).(string), + HeaderName: d.Get(headerNameVar).(string), + AutoRegister: d.Get(autoRegisterVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create jwt idp: %v", err) + } + d.SetId(resp.IdpId) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: d.Get("id").(string)}) + if err != nil { + return diag.Errorf("failed to read jwt idp: %v", err) + } + + idpID := d.Id() + name := d.Get(nameVar).(string) + stylingType := d.Get(stylingTypeVar).(string) + autoRegister := d.Get(autoRegisterVar).(bool) + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: idpID, + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp: %v", err) + } + } + + jwt := resp.GetIdp().GetJwtConfig() + jwtEndpoint := d.Get(jwtEndpointVar).(string) + issuer := d.Get(issuerVar).(string) + keysEndpoint := d.Get(keysEndpointVar).(string) + headerName := d.Get(headerNameVar).(string) + + //either nothing changed on the IDP or something besides the secret changed + if jwt.GetJwtEndpoint() != jwtEndpoint || + jwt.GetIssuer() != issuer || + jwt.GetKeysEndpoint() != keysEndpoint || + jwt.GetHeaderName() != headerName { + + _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ + IdpId: idpID, + JwtEndpoint: jwtEndpoint, + Issuer: issuer, + KeysEndpoint: keysEndpoint, + HeaderName: headerName, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp config: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: helper.GetID(d, idpIDVar)}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read jwt idp: %v", err) + } + + idp := resp.GetIdp() + jwt := idp.GetJwtConfig() + set := map[string]interface{}{ + orgIDVar: idp.GetDetails().ResourceOwner, + nameVar: idp.GetName(), + stylingTypeVar: idp.GetStylingType().String(), + jwtEndpointVar: jwt.GetJwtEndpoint(), + issuerVar: jwt.GetIssuer(), + keysEndpointVar: jwt.GetKeysEndpoint(), + headerNameVar: jwt.GetHeaderName(), + autoRegisterVar: idp.GetAutoRegister(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of jwt idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_jwt/resource.go b/zitadel/v2/idp_jwt/resource.go new file mode 100644 index 00000000..f116f618 --- /dev/null +++ b/zitadel/v2/idp_jwt/resource.go @@ -0,0 +1,67 @@ +package idp_jwt + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a domain of the organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + stylingTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Some identity providers specify the styling of the button to their login", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) + }, + }, + jwtEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the endpoint where the jwt can be extracted", + }, + keysEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the endpoint to the key (JWK) which are used to sign the JWT with", + }, + issuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the issuer of the jwt (for validation)", + }, + headerNameVar: { + Type: schema.TypeString, + Required: true, + Description: "the name of the header where the JWT is sent in, default is authorization", + }, + autoRegisterVar: { + Type: schema.TypeBool, + Required: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: read, + CreateContext: create, + UpdateContext: update, + DeleteContext: delete, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/idp_oidc.go b/zitadel/v2/idp_oidc.go deleted file mode 100644 index 1b1235df..00000000 --- a/zitadel/v2/idp_oidc.go +++ /dev/null @@ -1,275 +0,0 @@ -package v2 - -import ( - "context" - "reflect" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - idpOrgIDVar = "org_id" - idpNameVar = "name" - idpStylingTypeVar = "styling_type" - idpClientIDVar = "client_id" - idpClientSecretVar = "client_secret" - idpIssuerVar = "issuer" - idpScopesVar = "scopes" - idpDisplayNameMapping = "display_name_mapping" - idpUsernameMapping = "username_mapping" - idpAutoRegister = "auto_register" -) - -func GetOrgOIDCIDP() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a OIDC IDP of the organization.", - Schema: map[string]*schema.Schema{ - idpOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idpNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idpStylingTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Some identity providers specify the styling of the button to their login", - }, - idpClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idpClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - }, - idpIssuerVar: { - Type: schema.TypeString, - Required: true, - Description: "the oidc issuer of the identity provider", - }, - idpScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idpDisplayNameMapping: { - Type: schema.TypeString, - Required: true, - Description: "definition which field is mapped to the display name of the user", - }, - idpUsernameMapping: { - Type: schema.TypeString, - Required: true, - Description: "definition which field is mapped to the email of the user", - }, - idpAutoRegister: { - Type: schema.TypeBool, - Required: true, - Description: "auto register for users from this idp", - }, - }, - ReadContext: readOrgOIDCIDP, - UpdateContext: updateOrgOIDCIDP, - CreateContext: createOrgOIDCIDP, - DeleteContext: deleteOrgIDP, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteOrgIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveOrgIDP(ctx, &management2.RemoveOrgIDPRequest{ - IdpId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete oidc idp: %v", err) - } - return nil -} - -func createOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - scopes := make([]string, 0) - scopesSet := d.Get(idpScopesVar).(*schema.Set) - for _, scope := range scopesSet.List() { - scopes = append(scopes, scope.(string)) - } - - stylingType := d.Get(idpStylingTypeVar) - displayNameMapping := d.Get(idpDisplayNameMapping).(string) - usernameMapping := d.Get(idpUsernameMapping).(string) - resp, err := client.AddOrgOIDCIDP(ctx, &management2.AddOrgOIDCIDPRequest{ - Name: d.Get(idpNameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), - ClientId: d.Get(idpClientIDVar).(string), - ClientSecret: d.Get(idpClientSecretVar).(string), - Issuer: d.Get(idpIssuerVar).(string), - Scopes: scopes, - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), - AutoRegister: d.Get(idpAutoRegister).(bool), - }) - if err != nil { - return diag.Errorf("failed to create oidc idp: %v", err) - } - d.SetId(resp.GetIdpId()) - - return nil -} - -func updateOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) - if err != nil { - return diag.Errorf("failed to read oidc idp: %v", err) - } - - idpID := d.Id() - name := d.Get(idpNameVar).(string) - stylingType := d.Get(idpStylingTypeVar).(string) - autoRegister := d.Get(idpAutoRegister).(bool) - changed := false - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - changed = true - _, err := client.UpdateOrgIDP(ctx, &management2.UpdateOrgIDPRequest{ - IdpId: idpID, - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update oidc idp: %v", err) - } - } - - oidc := resp.GetIdp().GetOidcConfig() - clientID := d.Get(idpClientIDVar).(string) - clientSecret := d.Get(idpClientSecretVar).(string) - issuer := d.Get(idpIssuerVar).(string) - scopesSet := d.Get(idpScopesVar).(*schema.Set) - displayNameMapping := d.Get(idpDisplayNameMapping).(string) - usernameMapping := d.Get(idpUsernameMapping).(string) - - scopes := make([]string, 0) - for _, scope := range scopesSet.List() { - scopes = append(scopes, scope.(string)) - } - - //either nothing changed on the IDP or something besides the secret changed - if (oidc.GetClientId() != clientID || - oidc.GetIssuer() != issuer || - !reflect.DeepEqual(oidc.GetScopes(), scopes) || - oidc.GetDisplayNameMapping().String() != displayNameMapping || - oidc.GetUsernameMapping().String() != usernameMapping) || - !changed { - - _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management2.UpdateOrgIDPOIDCConfigRequest{ - IdpId: idpID, - ClientId: clientID, - ClientSecret: clientSecret, - Issuer: issuer, - Scopes: scopes, - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), - }) - if err != nil { - return diag.Errorf("failed to update oidc idp config: %v", err) - } - } - d.SetId(idpID) - return nil -} - -func readOrgOIDCIDP(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(idpOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read oidc idp: %v", err) - } - - idp := resp.GetIdp() - oidc := idp.GetOidcConfig() - set := map[string]interface{}{ - idpOrgIDVar: idp.GetDetails().GetResourceOwner(), - idpNameVar: idp.GetName(), - idpStylingTypeVar: idp.GetStylingType().String(), - idpClientIDVar: oidc.GetClientId(), - idpClientSecretVar: d.Get(idpClientSecretVar).(string), - idpIssuerVar: oidc.GetIssuer(), - idpScopesVar: oidc.GetScopes(), - idpDisplayNameMapping: oidc.GetDisplayNameMapping().String(), - idpUsernameMapping: oidc.GetUsernameMapping().String(), - idpAutoRegister: idp.GetAutoRegister(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of oidc idp: %v", k, err) - } - } - d.SetId(idp.Id) - - return nil -} diff --git a/zitadel/v2/idp_oidc/const.go b/zitadel/v2/idp_oidc/const.go new file mode 100644 index 00000000..46939473 --- /dev/null +++ b/zitadel/v2/idp_oidc/const.go @@ -0,0 +1,15 @@ +package idp_oidc + +const ( + idpIDVar = "idp_id" + orgIDVar = "org_id" + nameVar = "name" + stylingTypeVar = "styling_type" + clientIDVar = "client_id" + clientSecretVar = "client_secret" + issuerVar = "issuer" + scopesVar = "scopes" + displayNameMappingVar = "display_name_mapping" + usernameMappingVar = "username_mapping" + autoRegisterVar = "auto_register" +) diff --git a/zitadel/v2/idp_oidc/datasource.go b/zitadel/v2/idp_oidc/datasource.go new file mode 100644 index 00000000..6fe5cedc --- /dev/null +++ b/zitadel/v2/idp_oidc/datasource.go @@ -0,0 +1,75 @@ +package idp_oidc + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a OIDC IDP of the organization.", + Schema: map[string]*schema.Schema{ + idpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + stylingTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Some identity providers specify the styling of the button to their login", + }, + clientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + Sensitive: true, + }, + clientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + issuerVar: { + Type: schema.TypeString, + Computed: true, + Description: "the oidc issuer of the identity provider", + }, + scopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + displayNameMappingVar: { + Type: schema.TypeString, + Computed: true, + Description: "definition which field is mapped to the display name of the user", + }, + usernameMappingVar: { + Type: schema.TypeString, + Computed: true, + Description: "definition which field is mapped to the email of the user", + }, + autoRegisterVar: { + Type: schema.TypeBool, + Computed: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/idp_oidc/funcs.go b/zitadel/v2/idp_oidc/funcs.go new file mode 100644 index 00000000..60256993 --- /dev/null +++ b/zitadel/v2/idp_oidc/funcs.go @@ -0,0 +1,197 @@ +package idp_oidc + +import ( + "context" + "reflect" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrgIDP(ctx, &management.RemoveOrgIDPRequest{ + IdpId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete oidc idp: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + scopes := make([]string, 0) + scopesSet := d.Get(scopesVar).(*schema.Set) + for _, scope := range scopesSet.List() { + scopes = append(scopes, scope.(string)) + } + + stylingType := d.Get(stylingTypeVar) + displayNameMapping := d.Get(displayNameMappingVar).(string) + usernameMapping := d.Get(usernameMappingVar).(string) + resp, err := client.AddOrgOIDCIDP(ctx, &management.AddOrgOIDCIDPRequest{ + Name: d.Get(nameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + ClientId: d.Get(clientIDVar).(string), + ClientSecret: d.Get(clientSecretVar).(string), + Issuer: d.Get(issuerVar).(string), + Scopes: scopes, + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + AutoRegister: d.Get(autoRegisterVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create oidc idp: %v", err) + } + d.SetId(resp.GetIdpId()) + + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: d.Id()}) + if err != nil { + return diag.Errorf("failed to read oidc idp: %v", err) + } + + idpID := d.Id() + name := d.Get(nameVar).(string) + stylingType := d.Get(stylingTypeVar).(string) + autoRegister := d.Get(autoRegisterVar).(bool) + changed := false + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + changed = true + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: idpID, + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update oidc idp: %v", err) + } + } + + oidc := resp.GetIdp().GetOidcConfig() + clientID := d.Get(clientIDVar).(string) + clientSecret := d.Get(clientSecretVar).(string) + issuer := d.Get(issuerVar).(string) + scopesSet := d.Get(scopesVar).(*schema.Set) + displayNameMapping := d.Get(displayNameMappingVar).(string) + usernameMapping := d.Get(usernameMappingVar).(string) + + scopes := make([]string, 0) + for _, scope := range scopesSet.List() { + scopes = append(scopes, scope.(string)) + } + + //either nothing changed on the IDP or something besides the secret changed + if (oidc.GetClientId() != clientID || + oidc.GetIssuer() != issuer || + !reflect.DeepEqual(oidc.GetScopes(), scopes) || + oidc.GetDisplayNameMapping().String() != displayNameMapping || + oidc.GetUsernameMapping().String() != usernameMapping) || + !changed { + + _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ + IdpId: idpID, + ClientId: clientID, + ClientSecret: clientSecret, + Issuer: issuer, + Scopes: scopes, + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + }) + if err != nil { + return diag.Errorf("failed to update oidc idp config: %v", err) + } + } + d.SetId(idpID) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: helper.GetID(d, idpIDVar)}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read oidc idp: %v", err) + } + + idp := resp.GetIdp() + oidc := idp.GetOidcConfig() + set := map[string]interface{}{ + orgIDVar: idp.GetDetails().GetResourceOwner(), + nameVar: idp.GetName(), + stylingTypeVar: idp.GetStylingType().String(), + clientIDVar: oidc.GetClientId(), + clientSecretVar: d.Get(clientSecretVar).(string), + issuerVar: oidc.GetIssuer(), + scopesVar: oidc.GetScopes(), + displayNameMappingVar: oidc.GetDisplayNameMapping().String(), + usernameMappingVar: oidc.GetUsernameMapping().String(), + autoRegisterVar: idp.GetAutoRegister(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + + return nil +} diff --git a/zitadel/v2/idp_oidc/resource.go b/zitadel/v2/idp_oidc/resource.go new file mode 100644 index 00000000..c62d9941 --- /dev/null +++ b/zitadel/v2/idp_oidc/resource.go @@ -0,0 +1,82 @@ +package idp_oidc + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP of the organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + stylingTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Some identity providers specify the styling of the button to their login", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) + }, + }, + clientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + Sensitive: true, + }, + clientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + issuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the oidc issuer of the identity provider", + }, + scopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + displayNameMappingVar: { + Type: schema.TypeString, + Required: true, + Description: "definition which field is mapped to the display name of the user", + }, + usernameMappingVar: { + Type: schema.TypeString, + Required: true, + Description: "definition which field is mapped to the email of the user", + }, + autoRegisterVar: { + Type: schema.TypeBool, + Required: true, + Description: "auto register for users from this idp", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: delete, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/label_policy.go b/zitadel/v2/label_policy.go deleted file mode 100644 index 099aae72..00000000 --- a/zitadel/v2/label_policy.go +++ /dev/null @@ -1,289 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - labelPolicyOrgIdVar = "org_id" - labelPolicyPrimaryColor = "primary_color" - labelPolicyHideLoginNameSuffix = "hide_login_name_suffix" - labelPolicyWarnColor = "warn_color" - labelPolicyBackgroundColor = "background_color" - labelPolicyFontColor = "font_color" - labelPolicyPrimaryColorDark = "primary_color_dark" - labelPolicyBackgroundColorDark = "background_color_dark" - labelPolicyWarnColorDark = "warn_color_dark" - labelPolicyFontColorDark = "font_color_dark" - labelPolicyDisableWatermark = "disable_watermark" - labelPolicyLogoURL = "logo_url" - labelPolicyIconURL = "icon_url" - labelPolicyLogoURLDark = "logo_url_dark" - labelPolicyIconURLDark = "icon_url_dark" - labelPolicyFontURL = "font_url" - labelPolicySetActive = "set_active" -) - -func GetLabelPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom label policy of an organization.", - Schema: map[string]*schema.Schema{ - labelPolicyOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, - labelPolicyPrimaryColor: { - Type: schema.TypeString, - Required: true, - Description: "hex value for primary color", - }, - labelPolicyHideLoginNameSuffix: { - Type: schema.TypeBool, - Required: true, - Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes", - }, - labelPolicyWarnColor: { - Type: schema.TypeString, - Required: true, - Description: "hex value for warn color", - }, - labelPolicyBackgroundColor: { - Type: schema.TypeString, - Required: true, - Description: "hex value for background color", - }, - labelPolicyFontColor: { - Type: schema.TypeString, - Required: true, - Description: "hex value for font color", - }, - labelPolicyPrimaryColorDark: { - Type: schema.TypeString, - Required: true, - Description: "hex value for primary color dark theme", - }, - labelPolicyBackgroundColorDark: { - Type: schema.TypeString, - Required: true, - Description: "hex value for background color dark theme", - }, - labelPolicyWarnColorDark: { - Type: schema.TypeString, - Required: true, - Description: "hex value for warn color dark theme", - }, - labelPolicyFontColorDark: { - Type: schema.TypeString, - Required: true, - Description: "hex value for font color dark theme", - }, - labelPolicyDisableWatermark: { - Type: schema.TypeBool, - Required: true, - Description: "disable watermark", - }, - labelPolicyLogoURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyIconURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyLogoURLDark: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyIconURLDark: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicyFontURL: { - Type: schema.TypeString, - Computed: true, - Description: "", - }, - labelPolicySetActive: { - Type: schema.TypeBool, - Optional: true, - Description: "set the label policy active after creating/updating", - }, - }, - ReadContext: readLabelPolicy, - CreateContext: createLabelPolicy, - DeleteContext: deleteLabelPolicy, - UpdateContext: updateLabelPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(labelPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.ResetLabelPolicyToDefault(ctx, &management2.ResetLabelPolicyToDefaultRequest{}) - if err != nil { - return diag.Errorf("failed to reset label policy: %v", err) - } - return nil -} - -func updateLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(labelPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateCustomLabelPolicy(ctx, &management2.UpdateCustomLabelPolicyRequest{ - PrimaryColor: d.Get(labelPolicyPrimaryColor).(string), - HideLoginNameSuffix: d.Get(labelPolicyHideLoginNameSuffix).(bool), - WarnColor: d.Get(labelPolicyWarnColor).(string), - BackgroundColor: d.Get(labelPolicyBackgroundColor).(string), - FontColor: d.Get(labelPolicyFontColor).(string), - PrimaryColorDark: d.Get(labelPolicyPrimaryColorDark).(string), - BackgroundColorDark: d.Get(labelPolicyBackgroundColorDark).(string), - WarnColorDark: d.Get(labelPolicyWarnColorDark).(string), - FontColorDark: d.Get(labelPolicyFontColorDark).(string), - DisableWatermark: d.Get(labelPolicyDisableWatermark).(bool), - }) - if err != nil { - return diag.Errorf("failed to update label policy: %v", err) - } - d.SetId(org) - - active := d.Get(labelPolicySetActive) - if active != nil { - activeBool := active.(bool) - if activeBool { - if _, err := client.ActivateCustomLabelPolicy(ctx, &management2.ActivateCustomLabelPolicyRequest{}); err != nil { - return diag.Errorf("failed to activate label policy: %v", err) - } - } - } - return nil -} - -func createLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(labelPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.AddCustomLabelPolicy(ctx, &management2.AddCustomLabelPolicyRequest{ - PrimaryColor: d.Get(labelPolicyPrimaryColor).(string), - HideLoginNameSuffix: d.Get(labelPolicyHideLoginNameSuffix).(bool), - WarnColor: d.Get(labelPolicyWarnColor).(string), - BackgroundColor: d.Get(labelPolicyBackgroundColor).(string), - FontColor: d.Get(labelPolicyFontColor).(string), - PrimaryColorDark: d.Get(labelPolicyPrimaryColorDark).(string), - BackgroundColorDark: d.Get(labelPolicyBackgroundColorDark).(string), - WarnColorDark: d.Get(labelPolicyWarnColorDark).(string), - FontColorDark: d.Get(labelPolicyFontColorDark).(string), - DisableWatermark: d.Get(labelPolicyDisableWatermark).(bool), - }) - if err != nil { - return diag.Errorf("failed to create label policy: %v", err) - } - d.SetId(org) - - active := d.Get(labelPolicySetActive) - if active != nil { - activeBool := active.(bool) - if activeBool { - if _, err := client.ActivateCustomLabelPolicy(ctx, &management2.ActivateCustomLabelPolicyRequest{}); err != nil { - return diag.Errorf("failed to activate label policy: %v", err) - } - } - } - return nil -} - -func readLabelPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(domainPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetPreviewLabelPolicy(ctx, &management2.GetPreviewLabelPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get domain policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - labelPolicyPrimaryColor: policy.GetPrimaryColor(), - labelPolicyHideLoginNameSuffix: policy.GetHideLoginNameSuffix(), - labelPolicyWarnColor: policy.GetWarnColor(), - labelPolicyBackgroundColor: policy.GetBackgroundColor(), - labelPolicyFontColor: policy.GetFontColor(), - labelPolicyPrimaryColorDark: policy.GetPrimaryColorDark(), - labelPolicyBackgroundColorDark: policy.GetBackgroundColorDark(), - labelPolicyWarnColorDark: policy.GetWarnColorDark(), - labelPolicyFontColorDark: policy.GetFontColorDark(), - labelPolicyDisableWatermark: policy.GetDisableWatermark(), - labelPolicyLogoURL: policy.GetLogoUrl(), - labelPolicyIconURL: policy.GetIconUrl(), - labelPolicyLogoURLDark: policy.GetLogoUrlDark(), - labelPolicyIconURLDark: policy.GetIconUrlDark(), - labelPolicyFontURL: policy.GetFontUrl(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of label policy: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/label_policy/const.go b/zitadel/v2/label_policy/const.go new file mode 100644 index 00000000..04420a05 --- /dev/null +++ b/zitadel/v2/label_policy/const.go @@ -0,0 +1,21 @@ +package label_policy + +const ( + orgIDVar = "org_id" + primaryColorVar = "primary_color" + hideLoginNameSuffixVar = "hide_login_name_suffix" + warnColorVar = "warn_color" + backgroundColorVar = "background_color" + fontColorVar = "font_color" + primaryColorDarkVar = "primary_color_dark" + backgroundColorDarkVar = "background_color_dark" + warnColorDarkVar = "warn_color_dark" + fontColorDarkVar = "font_color_dark" + disableWatermarkVar = "disable_watermark" + logoURLVar = "logo_url" + iconURLVar = "icon_url" + logoURLDarkVar = "logo_url_dark" + iconURLDarkVar = "icon_url_dark" + fontURLVar = "font_url" + setActiveVar = "set_active" +) diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go new file mode 100644 index 00000000..eec12dcc --- /dev/null +++ b/zitadel/v2/label_policy/funcs.go @@ -0,0 +1,172 @@ +package label_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetLabelPolicyToDefault(ctx, &management.ResetLabelPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset label policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateCustomLabelPolicy(ctx, &management.UpdateCustomLabelPolicyRequest{ + PrimaryColor: d.Get(primaryColorVar).(string), + HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), + WarnColor: d.Get(warnColorVar).(string), + BackgroundColor: d.Get(backgroundColorVar).(string), + FontColor: d.Get(fontColorVar).(string), + PrimaryColorDark: d.Get(primaryColorDarkVar).(string), + BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), + WarnColorDark: d.Get(warnColorDarkVar).(string), + FontColorDark: d.Get(fontColorDarkVar).(string), + DisableWatermark: d.Get(disableWatermarkVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update label policy: %v", err) + } + d.SetId(org) + + active := d.Get(setActiveVar) + if active != nil { + activeBool := active.(bool) + if activeBool { + if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate label policy: %v", err) + } + } + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.AddCustomLabelPolicy(ctx, &management.AddCustomLabelPolicyRequest{ + PrimaryColor: d.Get(primaryColorVar).(string), + HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), + WarnColor: d.Get(warnColorVar).(string), + BackgroundColor: d.Get(backgroundColorVar).(string), + FontColor: d.Get(fontColorVar).(string), + PrimaryColorDark: d.Get(primaryColorDarkVar).(string), + BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), + WarnColorDark: d.Get(warnColorDarkVar).(string), + FontColorDark: d.Get(fontColorDarkVar).(string), + DisableWatermark: d.Get(disableWatermarkVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create label policy: %v", err) + } + d.SetId(org) + + active := d.Get(setActiveVar) + if active != nil { + activeBool := active.(bool) + if activeBool { + if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate label policy: %v", err) + } + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetPreviewLabelPolicy(ctx, &management.GetPreviewLabelPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get domain policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + primaryColorVar: policy.GetPrimaryColor(), + hideLoginNameSuffixVar: policy.GetHideLoginNameSuffix(), + warnColorVar: policy.GetWarnColor(), + backgroundColorVar: policy.GetBackgroundColor(), + fontColorVar: policy.GetFontColor(), + primaryColorDarkVar: policy.GetPrimaryColorDark(), + backgroundColorDarkVar: policy.GetBackgroundColorDark(), + warnColorDarkVar: policy.GetWarnColorDark(), + fontColorDarkVar: policy.GetFontColorDark(), + disableWatermarkVar: policy.GetDisableWatermark(), + logoURLVar: policy.GetLogoUrl(), + iconURLVar: policy.GetIconUrl(), + logoURLDarkVar: policy.GetLogoUrlDark(), + iconURLDarkVar: policy.GetIconUrlDark(), + fontURLVar: policy.GetFontUrl(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of label policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go new file mode 100644 index 00000000..7b821d5f --- /dev/null +++ b/zitadel/v2/label_policy/resource.go @@ -0,0 +1,104 @@ +package label_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom label policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + primaryColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for primary color", + }, + hideLoginNameSuffixVar: { + Type: schema.TypeBool, + Required: true, + Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes", + }, + warnColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for warn color", + }, + backgroundColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for background color", + }, + fontColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for font color", + }, + primaryColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for primary color dark theme", + }, + backgroundColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for background color dark theme", + }, + warnColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for warn color dark theme", + }, + fontColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for font color dark theme", + }, + disableWatermarkVar: { + Type: schema.TypeBool, + Required: true, + Description: "disable watermark", + }, + logoURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + iconURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + logoURLDarkVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + iconURLDarkVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + fontURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + setActiveVar: { + Type: schema.TypeBool, + Optional: true, + Description: "set the label policy active after creating/updating", + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/lockout_policy.go b/zitadel/v2/lockout_policy.go deleted file mode 100644 index 2711635a..00000000 --- a/zitadel/v2/lockout_policy.go +++ /dev/null @@ -1,149 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - lockoutPolicyOrgIdVar = "org_id" - lockoutPolicyMaxPasswordAttempts = "max_password_attempts" -) - -func GetLockoutPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom lockout policy of an organization.", - Schema: map[string]*schema.Schema{ - lockoutPolicyOrgIdVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - ForceNew: true, - }, - lockoutPolicyMaxPasswordAttempts: { - Type: schema.TypeInt, - Required: true, - Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", - }, - }, - DeleteContext: deleteLockoutPolicy, - CreateContext: createLockoutPolicy, - UpdateContext: updateLockoutPolicy, - ReadContext: readLockoutPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(lockoutPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.ResetLockoutPolicyToDefault(ctx, &management2.ResetLockoutPolicyToDefaultRequest{}) - if err != nil { - return diag.Errorf("failed to reset lockout policy: %v", err) - } - return nil -} - -func updateLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(lockoutPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateCustomLockoutPolicy(ctx, &management2.UpdateCustomLockoutPolicyRequest{ - MaxPasswordAttempts: uint32(d.Get(lockoutPolicyMaxPasswordAttempts).(int)), - }) - if err != nil { - return diag.Errorf("failed to update lockout policy: %v", err) - } - d.SetId(org) - return nil -} - -func createLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(lockoutPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.AddCustomLockoutPolicy(ctx, &management2.AddCustomLockoutPolicyRequest{ - MaxPasswordAttempts: uint32(d.Get(lockoutPolicyMaxPasswordAttempts).(int)), - }) - if err != nil { - return diag.Errorf("failed to create lockout policy: %v", err) - } - d.SetId(org) - return nil -} - -func readLockoutPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(domainPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetLockoutPolicy(ctx, &management2.GetLockoutPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get lockout policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - lockoutPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - lockoutPolicyMaxPasswordAttempts: policy.GetMaxPasswordAttempts(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of lockout policy: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/lockout_policy/const.go b/zitadel/v2/lockout_policy/const.go new file mode 100644 index 00000000..675bc38a --- /dev/null +++ b/zitadel/v2/lockout_policy/const.go @@ -0,0 +1,6 @@ +package lockout_policy + +const ( + orgIDVar = "org_id" + maxPasswordAttemptsVar = "max_password_attempts" +) diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go new file mode 100644 index 00000000..62ecd6c5 --- /dev/null +++ b/zitadel/v2/lockout_policy/funcs.go @@ -0,0 +1,121 @@ +package lockout_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetLockoutPolicyToDefault(ctx, &management.ResetLockoutPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset lockout policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateCustomLockoutPolicy(ctx, &management.UpdateCustomLockoutPolicyRequest{ + MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + }) + if err != nil { + return diag.Errorf("failed to update lockout policy: %v", err) + } + d.SetId(org) + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.AddCustomLockoutPolicy(ctx, &management.AddCustomLockoutPolicyRequest{ + MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + }) + if err != nil { + return diag.Errorf("failed to create lockout policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetLockoutPolicy(ctx, &management.GetLockoutPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get lockout policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + maxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of lockout policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/lockout_policy/resource.go b/zitadel/v2/lockout_policy/resource.go new file mode 100644 index 00000000..ced801b9 --- /dev/null +++ b/zitadel/v2/lockout_policy/resource.go @@ -0,0 +1,30 @@ +package lockout_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom lockout policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Id for the organization", + ForceNew: true, + }, + maxPasswordAttemptsVar: { + Type: schema.TypeInt, + Required: true, + Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/login_policy.go b/zitadel/v2/login_policy.go deleted file mode 100644 index 0548bdbf..00000000 --- a/zitadel/v2/login_policy.go +++ /dev/null @@ -1,432 +0,0 @@ -package v2 - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" - "google.golang.org/protobuf/types/known/durationpb" -) - -const ( - loginPolicyOrgIdVar = "org_id" - loginPolicyAllowUsernamePassword = "user_login" - loginPolicyAllowRegister = "allow_register" - loginPolicyAllowExternalIDP = "allow_external_idp" - loginPolicyForceMFA = "force_mfa" - loginPolicyPasswordlessType = "passwordless_type" - loginPolicyHidePasswordReset = "hide_password_reset" - loginPolicyPasswordCheckLifetime = "password_check_lifetime" - loginPolicyExternalLoginCheckLifetime = "external_login_check_lifetime" - loginPolicyMFAInitSkipLifetime = "mfa_init_skip_lifetime" - loginPolicySecondFactorCheckLifetime = "second_factor_check_lifetime" - loginPolicyMultiFactorCheckLifetime = "multi_factor_check_lifetime" - loginPolicyIgnoreUnknownUsernames = "ignore_unknown_usernames" - loginPolicyDefaultRedirectURI = "default_redirect_uri" - loginPolicySecondFactorsVar = "second_factors" - loginPolicyMultiFactorsVar = "multi_factors" - loginPolicyIDPsVar = "idps" -) - -func GetLoginPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom login policy of an organization.", - Schema: map[string]*schema.Schema{ - loginPolicyOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, - loginPolicyAllowUsernamePassword: { - Type: schema.TypeBool, - Required: true, - Description: "defines if a user is allowed to login with his username and password", - }, - loginPolicyAllowRegister: { - Type: schema.TypeBool, - Required: true, - Description: "defines if a person is allowed to register a user on this organisation", - }, - loginPolicyAllowExternalIDP: { - Type: schema.TypeBool, - Required: true, - Description: "defines if a user is allowed to add a defined identity provider. E.g. Google auth", - }, - loginPolicyForceMFA: { - Type: schema.TypeBool, - Required: true, - Description: "defines if a user MUST use a multi factor to log in", - }, - loginPolicyPasswordlessType: { - Type: schema.TypeString, - Required: true, - Description: "defines if passwordless is allowed for users", - }, - loginPolicyHidePasswordReset: { - Type: schema.TypeBool, - Required: true, - Description: "defines if password reset link should be shown in the login screen", - }, - loginPolicyIgnoreUnknownUsernames: { - Type: schema.TypeBool, - Required: true, - Description: "defines if unknown username on login screen directly return an error or always display the password screen", - }, - loginPolicyDefaultRedirectURI: { - Type: schema.TypeString, - Required: true, - Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", - }, - loginPolicyPasswordCheckLifetime: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - loginPolicyExternalLoginCheckLifetime: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - loginPolicyMFAInitSkipLifetime: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - loginPolicySecondFactorCheckLifetime: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - loginPolicyMultiFactorCheckLifetime: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - loginPolicySecondFactorsVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "allowed second factors", - }, - loginPolicyMultiFactorsVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "allowed multi factors", - }, - loginPolicyIDPsVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "allowed idps to login or register", - }, - }, - CreateContext: createLoginPolicy, - UpdateContext: updateLoginPolicy, - DeleteContext: deleteLoginPolicy, - ReadContext: readLoginPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(loginPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.ResetLoginPolicyToDefault(ctx, &management2.ResetLoginPolicyToDefaultRequest{}) - if err != nil { - return diag.Errorf("failed to reset login policy: %v", err) - } - return nil -} - -func updateLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(loginPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - current, err := client.GetLoginPolicy(ctx, &management2.GetLoginPolicyRequest{}) - if err != nil { - return diag.FromErr(err) - } - - passwordCheckLT, err := time.ParseDuration(d.Get(loginPolicyPasswordCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - externalLoginCheckLT, err := time.ParseDuration(d.Get(loginPolicyExternalLoginCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - mfaInitSkipLT, err := time.ParseDuration(d.Get(loginPolicyMFAInitSkipLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - secondFactorCheckLT, err := time.ParseDuration(d.Get(loginPolicySecondFactorCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - - multiFactorCheckLT, err := time.ParseDuration(d.Get(loginPolicyMultiFactorCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - - allowUsernamePassword := d.Get(loginPolicyAllowUsernamePassword).(bool) - allowRegister := d.Get(loginPolicyAllowRegister).(bool) - allowExternalIdp := d.Get(loginPolicyAllowExternalIDP).(bool) - forceMfa := d.Get(loginPolicyForceMFA).(bool) - passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]) - hidePasswordReset := d.Get(loginPolicyHidePasswordReset).(bool) - ignoreUnkownUsernames := d.Get(loginPolicyIgnoreUnknownUsernames).(bool) - defaultRedirectUri := d.Get(loginPolicyDefaultRedirectURI).(string) - currentPolicy := current.GetPolicy() - if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || - currentPolicy.GetAllowRegister() != allowRegister || - currentPolicy.GetAllowExternalIdp() != allowExternalIdp || - currentPolicy.GetForceMfa() != forceMfa || - currentPolicy.GetPasswordlessType() != passwordlessType || - currentPolicy.GetHidePasswordReset() != hidePasswordReset || - currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || - currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { - - _, err = client.UpdateCustomLoginPolicy(ctx, &management2.UpdateCustomLoginPolicyRequest{ - AllowUsernamePassword: allowUsernamePassword, - AllowRegister: allowRegister, - AllowExternalIdp: allowExternalIdp, - ForceMfa: forceMfa, - PasswordlessType: passwordlessType, - HidePasswordReset: hidePasswordReset, - IgnoreUnknownUsernames: ignoreUnkownUsernames, - DefaultRedirectUri: defaultRedirectUri, - PasswordCheckLifetime: durationpb.New(passwordCheckLT), - ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), - MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), - SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), - MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), - }) - if err != nil { - return diag.Errorf("failed to update login policy: %v", err) - } - } - d.SetId(org) - - secondFactors := setToStringSlice(d.Get(loginPolicySecondFactorsVar).(*schema.Set)) - currentSecondFactors := make([]stringify, 0) - for _, secondFactor := range current.GetPolicy().GetSecondFactors() { - currentSecondFactors = append(currentSecondFactors, secondFactor) - } - addSecondFactor, deleteSecondFactors := getAddAndDelete(currentSecondFactors, secondFactors) - - for _, factor := range addSecondFactor { - if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management2.AddSecondFactorToLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) - } - } - for _, factor := range deleteSecondFactors { - if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &management2.RemoveSecondFactorFromLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) - } - } - - multiFactors := setToStringSlice(d.Get(loginPolicyMultiFactorsVar).(*schema.Set)) - currentMultiFactors := make([]stringify, 0) - for _, multiFactor := range current.GetPolicy().GetMultiFactors() { - currentMultiFactors = append(currentMultiFactors, multiFactor) - } - addMultiFactor, deleteMultiFactors := getAddAndDelete(currentMultiFactors, multiFactors) - for _, factor := range addMultiFactor { - if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management2.AddMultiFactorToLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) - } - } - for _, factor := range deleteMultiFactors { - if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &management2.RemoveMultiFactorFromLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) - } - } - - idps := setToStringSlice(d.Get(loginPolicyIDPsVar).(*schema.Set)) - currentIdps := make([]stringify, 0) - for _, currentIdp := range current.GetPolicy().GetIdps() { - currentIdps = append(currentIdps, &stringified{currentIdp.IdpId}) - } - addIdps, deleteIdps := getAddAndDelete(currentIdps, idps) - for _, addIdp := range addIdps { - var ownertype idp.IDPOwnerType - _, err := client.GetOrgIDPByID(ctx, &management2.GetOrgIDPByIDRequest{Id: addIdp}) - if err != nil { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM - } else { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG - } - if _, err := client.AddIDPToLoginPolicy(ctx, &management2.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { - return diag.FromErr(err) - } - } - for _, deleteIdp := range deleteIdps { - if _, err := client.RemoveIDPFromLoginPolicy(ctx, &management2.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { - return diag.FromErr(err) - } - } - - return nil -} - -func createLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(loginPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - passwordCheckLT, err := time.ParseDuration(d.Get(loginPolicyPasswordCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - externalLoginCheckLT, err := time.ParseDuration(d.Get(loginPolicyExternalLoginCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - mfaInitSkipLT, err := time.ParseDuration(d.Get(loginPolicyMFAInitSkipLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - secondFactorCheckLT, err := time.ParseDuration(d.Get(loginPolicySecondFactorCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - multiFactorCheckLT, err := time.ParseDuration(d.Get(loginPolicyMultiFactorCheckLifetime).(string)) - if err != nil { - return diag.FromErr(err) - } - secondFactors := make([]policy.SecondFactorType, 0) - secondFactorsSet := d.Get(loginPolicySecondFactorsVar).(*schema.Set) - for _, factor := range secondFactorsSet.List() { - secondFactors = append(secondFactors, policy.SecondFactorType(policy.SecondFactorType_value[factor.(string)])) - } - multiFactors := make([]policy.MultiFactorType, 0) - multiFactorsSet := d.Get(loginPolicyMultiFactorsVar).(*schema.Set) - for _, factor := range multiFactorsSet.List() { - multiFactors = append(multiFactors, policy.MultiFactorType(policy.MultiFactorType_value[factor.(string)])) - } - - _, err = client.AddCustomLoginPolicy(ctx, &management2.AddCustomLoginPolicyRequest{ - AllowUsernamePassword: d.Get(loginPolicyAllowUsernamePassword).(bool), - AllowRegister: d.Get(loginPolicyAllowRegister).(bool), - AllowExternalIdp: d.Get(loginPolicyAllowExternalIDP).(bool), - ForceMfa: d.Get(loginPolicyForceMFA).(bool), - PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(loginPolicyPasswordlessType).(string)]), - HidePasswordReset: d.Get(loginPolicyHidePasswordReset).(bool), - IgnoreUnknownUsernames: d.Get(loginPolicyIgnoreUnknownUsernames).(bool), - DefaultRedirectUri: d.Get(loginPolicyDefaultRedirectURI).(string), - PasswordCheckLifetime: durationpb.New(passwordCheckLT), - ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), - MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), - SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), - MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), - SecondFactors: secondFactors, - MultiFactors: multiFactors, - }) - if err != nil { - return diag.Errorf("failed to create login policy: %v", err) - } - d.SetId(org) - return nil -} - -func readLoginPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(domainPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetLoginPolicy(ctx, &management2.GetLoginPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get login policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - loginPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - loginPolicyAllowUsernamePassword: policy.GetAllowUsernamePassword(), - loginPolicyAllowRegister: policy.GetAllowRegister(), - loginPolicyAllowExternalIDP: policy.GetAllowExternalIdp(), - loginPolicyForceMFA: policy.GetForceMfa(), - loginPolicyPasswordlessType: policy.GetPasswordlessType().String(), - loginPolicyHidePasswordReset: policy.GetHidePasswordReset(), - loginPolicyPasswordCheckLifetime: policy.GetPasswordCheckLifetime().AsDuration().String(), - loginPolicyExternalLoginCheckLifetime: policy.GetExternalLoginCheckLifetime().AsDuration().String(), - loginPolicyMFAInitSkipLifetime: policy.GetMfaInitSkipLifetime().AsDuration().String(), - loginPolicySecondFactorCheckLifetime: policy.GetSecondFactorCheckLifetime().AsDuration().String(), - loginPolicyMultiFactorCheckLifetime: policy.GetMultiFactorCheckLifetime().AsDuration().String(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of login policy: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/login_policy/const.go b/zitadel/v2/login_policy/const.go new file mode 100644 index 00000000..c310b402 --- /dev/null +++ b/zitadel/v2/login_policy/const.go @@ -0,0 +1,21 @@ +package login_policy + +const ( + orgIDVar = "org_id" + allowUsernamePasswordVar = "user_login" + allowRegisterVar = "allow_register" + allowExternalIDPVar = "allow_external_idp" + forceMFAVar = "force_mfa" + passwordlessTypeVar = "passwordless_type" + hidePasswordResetVar = "hide_password_reset" + passwordCheckLifetimeVar = "password_check_lifetime" + externalLoginCheckLifetimeVar = "external_login_check_lifetime" + mfaInitSkipLifetimeVar = "mfa_init_skip_lifetime" + secondFactorCheckLifetimeVar = "second_factor_check_lifetime" + multiFactorCheckLifetimeVar = "multi_factor_check_lifetime" + ignoreUnknownUsernamesVar = "ignore_unknown_usernames" + defaultRedirectURIVar = "default_redirect_uri" + secondFactorsVar = "second_factors" + multiFactorsVar = "multi_factors" + idpsVar = "idps" +) diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go new file mode 100644 index 00000000..eb045262 --- /dev/null +++ b/zitadel/v2/login_policy/funcs.go @@ -0,0 +1,306 @@ +package login_policy + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetLoginPolicyToDefault(ctx, &management.ResetLoginPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset login policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + current, err := client.GetLoginPolicy(ctx, &management.GetLoginPolicyRequest{}) + if err != nil { + return diag.FromErr(err) + } + + passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) + allowRegister := d.Get(allowRegisterVar).(bool) + allowExternalIdp := d.Get(allowExternalIDPVar).(bool) + forceMfa := d.Get(forceMFAVar).(bool) + passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) + hidePasswordReset := d.Get(hidePasswordResetVar).(bool) + ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) + defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) + currentPolicy := current.GetPolicy() + if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || + currentPolicy.GetAllowRegister() != allowRegister || + currentPolicy.GetAllowExternalIdp() != allowExternalIdp || + currentPolicy.GetForceMfa() != forceMfa || + currentPolicy.GetPasswordlessType() != passwordlessType || + currentPolicy.GetHidePasswordReset() != hidePasswordReset || + currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || + currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { + + _, err = client.UpdateCustomLoginPolicy(ctx, &management.UpdateCustomLoginPolicyRequest{ + AllowUsernamePassword: allowUsernamePassword, + AllowRegister: allowRegister, + AllowExternalIdp: allowExternalIdp, + ForceMfa: forceMfa, + PasswordlessType: passwordlessType, + HidePasswordReset: hidePasswordReset, + IgnoreUnknownUsernames: ignoreUnkownUsernames, + DefaultRedirectUri: defaultRedirectUri, + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + }) + if err != nil { + return diag.Errorf("failed to update login policy: %v", err) + } + } + d.SetId(org) + + secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) + currentSecondFactors := make([]helper.Stringify, 0) + for _, secondFactor := range current.GetPolicy().GetSecondFactors() { + currentSecondFactors = append(currentSecondFactors, secondFactor) + } + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + + for _, factor := range addSecondFactor { + if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management.AddSecondFactorToLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteSecondFactors { + if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &management.RemoveSecondFactorFromLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) + currentMultiFactors := make([]helper.Stringify, 0) + for _, multiFactor := range current.GetPolicy().GetMultiFactors() { + currentMultiFactors = append(currentMultiFactors, multiFactor) + } + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) + for _, factor := range addMultiFactor { + if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management.AddMultiFactorToLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteMultiFactors { + if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &management.RemoveMultiFactorFromLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) + currentIdps := make([]helper.Stringify, 0) + for _, currentIdp := range current.GetPolicy().GetIdps() { + currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) + } + addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) + for _, addIdp := range addIdps { + var ownertype idp.IDPOwnerType + _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) + if err != nil { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM + } else { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + } + if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + return diag.FromErr(err) + } + } + for _, deleteIdp := range deleteIdps { + if _, err := client.RemoveIDPFromLoginPolicy(ctx, &management.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { + return diag.FromErr(err) + } + } + + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + secondFactors := make([]policy.SecondFactorType, 0) + secondFactorsSet := d.Get(secondFactorsVar).(*schema.Set) + for _, factor := range secondFactorsSet.List() { + secondFactors = append(secondFactors, policy.SecondFactorType(policy.SecondFactorType_value[factor.(string)])) + } + multiFactors := make([]policy.MultiFactorType, 0) + multiFactorsSet := d.Get(multiFactorsVar).(*schema.Set) + for _, factor := range multiFactorsSet.List() { + multiFactors = append(multiFactors, policy.MultiFactorType(policy.MultiFactorType_value[factor.(string)])) + } + + _, err = client.AddCustomLoginPolicy(ctx, &management.AddCustomLoginPolicyRequest{ + AllowUsernamePassword: d.Get(allowUsernamePasswordVar).(bool), + AllowRegister: d.Get(allowRegisterVar).(bool), + AllowExternalIdp: d.Get(allowExternalIDPVar).(bool), + ForceMfa: d.Get(forceMFAVar).(bool), + PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), + HidePasswordReset: d.Get(hidePasswordResetVar).(bool), + IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), + DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + SecondFactors: secondFactors, + MultiFactors: multiFactors, + }) + if err != nil { + return diag.Errorf("failed to create login policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetLoginPolicy(ctx, &management.GetLoginPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get login policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + allowUsernamePasswordVar: policy.GetAllowUsernamePassword(), + allowRegisterVar: policy.GetAllowRegister(), + allowExternalIDPVar: policy.GetAllowExternalIdp(), + forceMFAVar: policy.GetForceMfa(), + passwordlessTypeVar: policy.GetPasswordlessType().String(), + hidePasswordResetVar: policy.GetHidePasswordReset(), + passwordCheckLifetimeVar: policy.GetPasswordCheckLifetime().AsDuration().String(), + externalLoginCheckLifetimeVar: policy.GetExternalLoginCheckLifetime().AsDuration().String(), + mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), + secondFactorCheckLifetimeVar: policy.GetSecondFactorCheckLifetime().AsDuration().String(), + multiFactorCheckLifetimeVar: policy.GetMultiFactorCheckLifetime().AsDuration().String(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of login policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go new file mode 100644 index 00000000..9482127e --- /dev/null +++ b/zitadel/v2/login_policy/resource.go @@ -0,0 +1,113 @@ +package login_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom login policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + allowUsernamePasswordVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user is allowed to login with his username and password", + }, + allowRegisterVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a person is allowed to register a user on this organisation", + }, + allowExternalIDPVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user is allowed to add a defined identity provider. E.g. Google auth", + }, + forceMFAVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user MUST use a multi factor to log in", + }, + passwordlessTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "defines if passwordless is allowed for users", + }, + hidePasswordResetVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if password reset link should be shown in the login screen", + }, + ignoreUnknownUsernamesVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if unknown username on login screen directly return an error or always display the password screen", + }, + defaultRedirectURIVar: { + Type: schema.TypeString, + Required: true, + Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", + }, + passwordCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + externalLoginCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + mfaInitSkipLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + secondFactorCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + multiFactorCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + secondFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed second factors", + }, + multiFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed multi factors", + }, + idpsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed idps to login or register", + }, + }, + CreateContext: create, + UpdateContext: update, + DeleteContext: delete, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/machine_key.go b/zitadel/v2/machine_key.go deleted file mode 100644 index e3105fd1..00000000 --- a/zitadel/v2/machine_key.go +++ /dev/null @@ -1,157 +0,0 @@ -package v2 - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/timestamppb" -) - -const ( - machineKeyOrgIDVar = "org_id" - machineKeyUserIDVar = "user_id" - machineKeyKeyTypeVar = "key_type" - machineKeyKeyDetailsVar = "key_details" - machineKeyExpirationDateVar = "expiration_date" -) - -func GetMachineKey() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a machine key", - Schema: map[string]*schema.Schema{ - machineKeyOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - machineKeyUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - machineKeyKeyTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Type of the machine key", - ForceNew: true, - }, - machineKeyExpirationDateVar: { - Type: schema.TypeString, - Required: true, - Description: "Expiration date of the machine key", - ForceNew: true, - }, - machineKeyKeyDetailsVar: { - Type: schema.TypeString, - Computed: true, - Description: "Value of the machine key", - Sensitive: true, - }, - }, - DeleteContext: deleteMachineKey, - CreateContext: createMachineKey, - ReadContext: readMachineKey, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(machineKeyOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveMachineKey(ctx, &management2.RemoveMachineKeyRequest{ - UserId: d.Get(machineKeyUserIDVar).(string), - KeyId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete machine key: %v", err) - } - return nil -} - -func createMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(machineKeyOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - t, err := time.Parse(time.RFC3339, d.Get(machineKeyExpirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) - } - - keyType := d.Get(machineKeyKeyTypeVar).(string) - resp, err := client.AddMachineKey(ctx, &management2.AddMachineKeyRequest{ - UserId: d.Get(machineKeyUserIDVar).(string), - Type: authn.KeyType(authn.KeyType_value[keyType]), - ExpirationDate: timestamppb.New(t), - }) - d.SetId(resp.GetKeyId()) - - if err := d.Set(machineKeyKeyDetailsVar, string(resp.GetKeyDetails())); err != nil { - return diag.FromErr(err) - } - - return nil -} - -func readMachineKey(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(machineKeyOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(machineKeyUserIDVar).(string) - resp, err := client.GetMachineKeyByIDs(ctx, &management2.GetMachineKeyByIDsRequest{ - UserId: userID, - KeyId: d.Id(), - }) - if err != nil { - d.SetId("") - return nil - } - d.SetId(resp.GetKey().GetId()) - - set := map[string]interface{}{ - machineKeyExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), - machineKeyUserIDVar: userID, - machineKeyOrgIDVar: orgID, - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of machine key: %v", k, err) - } - } - return nil -} diff --git a/zitadel/v2/machine_key/const.go b/zitadel/v2/machine_key/const.go new file mode 100644 index 00000000..ce57aa59 --- /dev/null +++ b/zitadel/v2/machine_key/const.go @@ -0,0 +1,9 @@ +package machine_key + +const ( + orgIDVar = "org_id" + userIDVar = "user_id" + keyTypeVar = "key_type" + keyDetailsVar = "key_details" + expirationDateVar = "expiration_date" +) diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go new file mode 100644 index 00000000..9c38e1be --- /dev/null +++ b/zitadel/v2/machine_key/funcs.go @@ -0,0 +1,109 @@ +package machine_key + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveMachineKey(ctx, &management.RemoveMachineKeyRequest{ + UserId: d.Get(userIDVar).(string), + KeyId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete machine key: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + + keyType := d.Get(keyTypeVar).(string) + resp, err := client.AddMachineKey(ctx, &management.AddMachineKeyRequest{ + UserId: d.Get(userIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), + ExpirationDate: timestamppb.New(t), + }) + d.SetId(resp.GetKeyId()) + + if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + resp, err := client.GetMachineKeyByIDs(ctx, &management.GetMachineKeyByIDsRequest{ + UserId: userID, + KeyId: d.Id(), + }) + if err != nil { + d.SetId("") + return nil + } + d.SetId(resp.GetKey().GetId()) + + set := map[string]interface{}{ + expirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), + userIDVar: userID, + orgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of machine key: %v", k, err) + } + } + return nil +} diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go new file mode 100644 index 00000000..c0c56090 --- /dev/null +++ b/zitadel/v2/machine_key/resource.go @@ -0,0 +1,55 @@ +package machine_key + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a machine key", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + keyTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the machine key", + ForceNew: true, + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) + }, + }, + expirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the machine key", + ForceNew: true, + }, + keyDetailsVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the machine key", + Sensitive: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/machine_user/const.go b/zitadel/v2/machine_user/const.go new file mode 100644 index 00000000..848aa89c --- /dev/null +++ b/zitadel/v2/machine_user/const.go @@ -0,0 +1,13 @@ +package machine_user + +const ( + userIDVar = "user_id" + orgIDVar = "org_id" + userStateVar = "state" + userNameVar = "user_name" + loginNamesVar = "login_names" + preferredLoginNameVar = "preferred_login_name" + + nameVar = "name" + descriptionVar = "description" +) diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go new file mode 100644 index 00000000..deee8018 --- /dev/null +++ b/zitadel/v2/machine_user/datasource.go @@ -0,0 +1,57 @@ +package machine_user + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", + Schema: map[string]*schema.Schema{ + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + userStateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the user", + }, + userNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Username", + }, + loginNamesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Loginnames", + }, + preferredLoginNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Preferred login name", + }, + + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the machine user", + }, + descriptionVar: { + Type: schema.TypeString, + Computed: true, + Description: "Description of the user", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go new file mode 100644 index 00000000..66a6e4b9 --- /dev/null +++ b/zitadel/v2/machine_user/funcs.go @@ -0,0 +1,144 @@ +package machine_user + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveUser(ctx, &management.RemoveUserRequest{ + Id: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete user: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + respUser, err := client.AddMachineUser(ctx, &management.AddMachineUserRequest{ + UserName: d.Get(userNameVar).(string), + Name: d.Get(nameVar).(string), + Description: d.Get(descriptionVar).(string), + }) + if err != nil { + return diag.Errorf("failed to create machine user: %v", err) + } + d.SetId(respUser.UserId) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + currentUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: d.Id()}) + if err != nil { + return diag.FromErr(err) + } + + username := d.Get(userNameVar).(string) + if currentUser.GetUser().GetUserName() != username { + _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ + UserId: d.Id(), + UserName: username, + }) + if err != nil { + return diag.Errorf("failed to update username: %v", err) + } + } + + currentMachine := currentUser.GetUser().GetMachine() + if currentMachine.GetName() != d.Get(nameVar).(string) || currentMachine.GetDescription() != d.Get(descriptionVar).(string) { + _, err := client.UpdateMachine(ctx, &management.UpdateMachineRequest{ + UserId: d.Id(), + Name: d.Get(nameVar).(string), + Description: d.Get(descriptionVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update machine user: %v", err) + } + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get list of users: %v", err) + } + + user := respUser.GetUser() + set := map[string]interface{}{ + orgIDVar: user.GetDetails().GetResourceOwner(), + userStateVar: user.GetState().String(), + userNameVar: user.GetUserName(), + loginNamesVar: user.GetLoginNames(), + preferredLoginNameVar: user.GetPreferredLoginName(), + } + if machine := user.GetMachine(); machine != nil { + set[nameVar] = machine.GetName() + set[descriptionVar] = machine.GetDescription() + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of user: %v", k, err) + } + } + d.SetId(user.GetId()) + return nil +} diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go new file mode 100644 index 00000000..03a6ffcb --- /dev/null +++ b/zitadel/v2/machine_user/resource.go @@ -0,0 +1,62 @@ +package machine_user + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + userStateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the user", + /* Not necessary as long as only active users are created + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return EnumValueValidation(userStateVar, value.(string), user.UserState_value) + },*/ + }, + userNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Username", + }, + loginNamesVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Loginnames", + }, + preferredLoginNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Preferred login name", + }, + + nameVar: { + Type: schema.TypeString, + Optional: true, + Description: "Name of the machine user", + }, + descriptionVar: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the user", + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/org/const.go b/zitadel/v2/org/const.go new file mode 100644 index 00000000..8a14f9af --- /dev/null +++ b/zitadel/v2/org/const.go @@ -0,0 +1,6 @@ +package org + +const ( + nameVar = "name" + orgIDVar = "org_id" +) diff --git a/zitadel/v2/org/datasource.go b/zitadel/v2/org/datasource.go new file mode 100644 index 00000000..6127fb10 --- /dev/null +++ b/zitadel/v2/org/datasource.go @@ -0,0 +1,23 @@ +package org + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the org", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/org.go b/zitadel/v2/org/funcs.go similarity index 58% rename from zitadel/v2/org.go rename to zitadel/v2/org/funcs.go index e5e2590d..859ce979 100644 --- a/zitadel/v2/org.go +++ b/zitadel/v2/org/funcs.go @@ -1,4 +1,4 @@ -package v2 +package org import ( "context" @@ -9,52 +9,32 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) -const ( - nameVar = "name" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) -func OrgResource() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", - Schema: map[string]*schema.Schema{ - nameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the org", - }, - }, - CreateContext: createOrg, - DeleteContext: deleteOrg, - ReadContext: readOrg, - UpdateContext: updateOrg, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { /*client, ok := m.(*management.Client) if !ok { return diag.Errorf("failed to get client") } - _, err := client.DeactivateOrg(ctx, &management2.DeactivateOrgRequest{}) + _, err := client.DeactivateOrg(ctx, &management.DeactivateOrgRequest{}) if err != nil { return diag.FromErr(err) }*/ return nil } -func createOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, "") + client, err := helper.GetManagementClient(clientinfo, "") if err != nil { return diag.FromErr(err) } @@ -70,15 +50,15 @@ func createOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag. return nil } -func updateOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(actionOrgId).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Id()) if err != nil { return diag.FromErr(err) } @@ -92,15 +72,15 @@ func updateOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag. return nil } -func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getAdminClient(clientinfo) + client, err := helper.GetAdminClient(clientinfo) if err != nil { return diag.FromErr(err) } @@ -113,7 +93,7 @@ func readOrg(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di "orglist": resp.Result, }) - orgID := d.Id() + orgID := helper.GetID(d, orgIDVar) tflog.Debug(ctx, "check if org is existing", map[string]interface{}{ "id": orgID, }) diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go new file mode 100644 index 00000000..18279686 --- /dev/null +++ b/zitadel/v2/org/resource.go @@ -0,0 +1,23 @@ +package org + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", + Schema: map[string]*schema.Schema{ + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the org", + }, + }, + CreateContext: create, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/org_member.go b/zitadel/v2/org_member.go deleted file mode 100644 index e77997d3..00000000 --- a/zitadel/v2/org_member.go +++ /dev/null @@ -1,185 +0,0 @@ -package v2 - -import ( - "context" - "strings" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" -) - -const ( - orgMemberOrgIDVar = "org_id" - orgMemberUserIDVar = "user_id" - orgMemberRolesVar = "roles" -) - -func GetOrgMember() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the membership of a user on an organization, defined with the given role.", - Schema: map[string]*schema.Schema{ - orgMemberOrgIDVar: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "ID of the organization", - }, - orgMemberUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - orgMemberRolesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "List of roles granted", - }, - }, - DeleteContext: deleteOrgMember, - CreateContext: createOrgMember, - UpdateContext: updateOrgMember, - ReadContext: readOrgMember, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveOrgMember(ctx, &management2.RemoveOrgMemberRequest{ - UserId: d.Get(orgMemberUserIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to delete orgmember: %v", err) - } - return nil -} - -func updateOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateOrgMember(ctx, &management2.UpdateOrgMemberRequest{ - UserId: d.Get(orgMemberUserIDVar).(string), - Roles: d.Get(orgMemberRolesVar).([]string), - }) - if err != nil { - return diag.Errorf("failed to update orgmember: %v", err) - } - return nil -} - -func createOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(orgMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(orgMemberUserIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(orgMemberRolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - - _, err = client.AddOrgMember(ctx, &management2.AddOrgMemberRequest{ - UserId: userID, - Roles: roles, - }) - if err != nil { - return diag.Errorf("failed to create orgmember: %v", err) - } - d.SetId(getOrgMemberID(org, userID)) - return nil -} - -func readOrgMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - org := d.Get(orgMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(orgMemberUserIDVar).(string) - resp, err := client.ListOrgMembers(ctx, &management2.ListOrgMembersRequest{ - Queries: []*member.SearchQuery{{ - Query: &member.SearchQuery_UserIdQuery{ - UserIdQuery: &member.UserIDQuery{ - UserId: userID, - }, - }, - }}, - }) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read orgmember: %v", err) - } - - if len(resp.Result) == 1 { - orgMember := resp.Result[0] - set := map[string]interface{}{ - orgMemberUserIDVar: orgMember.GetUserId(), - orgMemberOrgIDVar: orgMember.GetDetails().GetResourceOwner(), - orgMemberRolesVar: orgMember.GetRoles(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of orgmember: %v", k, err) - } - } - d.SetId(getOrgMemberID(org, userID)) - return nil - } - - d.SetId("") - return nil -} - -func getOrgMemberID(org string, userID string) string { - return org + "_" + userID -} - -func splitOrgMemberID(orgMemberID string) (string, string) { - parts := strings.Split(orgMemberID, "_") - return parts[0], parts[1] -} diff --git a/zitadel/v2/org_member/const.go b/zitadel/v2/org_member/const.go new file mode 100644 index 00000000..4ef49dd9 --- /dev/null +++ b/zitadel/v2/org_member/const.go @@ -0,0 +1,7 @@ +package org_member + +const ( + orgIDVar = "org_id" + userIDVar = "user_id" + rolesVar = "roles" +) diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go new file mode 100644 index 00000000..943c52d8 --- /dev/null +++ b/zitadel/v2/org_member/funcs.go @@ -0,0 +1,148 @@ +package org_member + +import ( + "context" + "strings" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrgMember(ctx, &management.RemoveOrgMemberRequest{ + UserId: d.Get(userIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete orgmember: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateOrgMember(ctx, &management.UpdateOrgMemberRequest{ + UserId: d.Get(userIDVar).(string), + Roles: d.Get(rolesVar).([]string), + }) + if err != nil { + return diag.Errorf("failed to update orgmember: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + roles := make([]string, 0) + for _, role := range d.Get(rolesVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + + _, err = client.AddOrgMember(ctx, &management.AddOrgMemberRequest{ + UserId: userID, + Roles: roles, + }) + if err != nil { + return diag.Errorf("failed to create orgmember: %v", err) + } + d.SetId(getOrgMemberID(org, userID)) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + resp, err := client.ListOrgMembers(ctx, &management.ListOrgMembersRequest{ + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read orgmember: %v", err) + } + + if len(resp.Result) == 1 { + orgMember := resp.Result[0] + set := map[string]interface{}{ + userIDVar: orgMember.GetUserId(), + orgIDVar: orgMember.GetDetails().GetResourceOwner(), + rolesVar: orgMember.GetRoles(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of orgmember: %v", k, err) + } + } + d.SetId(getOrgMemberID(org, userID)) + return nil + } + + d.SetId("") + return nil +} + +func getOrgMemberID(org string, userID string) string { + return org + "_" + userID +} + +func splitOrgMemberID(orgMemberID string) (string, string) { + parts := strings.Split(orgMemberID, "_") + return parts[0], parts[1] +} diff --git a/zitadel/v2/org_member/resource.go b/zitadel/v2/org_member/resource.go new file mode 100644 index 00000000..a5ab4c8b --- /dev/null +++ b/zitadel/v2/org_member/resource.go @@ -0,0 +1,38 @@ +package org_member + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the membership of a user on an organization, defined with the given role.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "ID of the organization", + }, + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + rolesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "List of roles granted", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/password_complexity_policy.go b/zitadel/v2/password_complexity_policy.go deleted file mode 100644 index 942fdbbc..00000000 --- a/zitadel/v2/password_complexity_policy.go +++ /dev/null @@ -1,184 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - passwordCompPolicyOrgIdVar = "org_id" - passwordCompPolicyMinLength = "min_length" - passwordCompPolicyHasUppercase = "has_uppercase" - passwordCompPolicyHasLowercase = "has_lowercase" - passwordCompPolicyHasNumber = "has_number" - passwordCompPolicyHasSymbol = "has_symbol" -) - -func GetPasswordComplexityPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom password complexity policy of an organization.", - Schema: map[string]*schema.Schema{ - passwordCompPolicyOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, - passwordCompPolicyMinLength: { - Type: schema.TypeInt, - Required: true, - Description: "Minimal length for the password", - }, - passwordCompPolicyHasUppercase: { - Type: schema.TypeBool, - Required: true, - Description: "defines if the password MUST contain an upper case letter", - }, - passwordCompPolicyHasLowercase: { - Type: schema.TypeBool, - Required: true, - Description: "defines if the password MUST contain a lower case letter", - }, - passwordCompPolicyHasNumber: { - Type: schema.TypeBool, - Required: true, - Description: "defines if the password MUST contain a number", - }, - passwordCompPolicyHasSymbol: { - Type: schema.TypeBool, - Required: true, - Description: "defines if the password MUST contain a symbol. E.g. \"$\"", - }, - }, - DeleteContext: deletePasswordComplexityPolicy, - ReadContext: readPasswordComplexityPolicy, - CreateContext: createPasswordComplexityPolicy, - UpdateContext: updatePasswordComplexityPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deletePasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(passwordCompPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.ResetPasswordComplexityPolicyToDefault(ctx, &management2.ResetPasswordComplexityPolicyToDefaultRequest{}) - if err != nil { - return diag.Errorf("failed to reset password complexity policy: %v", err) - } - return nil -} - -func updatePasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(passwordCompPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateCustomPasswordComplexityPolicy(ctx, &management2.UpdateCustomPasswordComplexityPolicyRequest{ - MinLength: uint64(d.Get(passwordCompPolicyMinLength).(int)), - HasUppercase: d.Get(passwordCompPolicyHasUppercase).(bool), - HasLowercase: d.Get(passwordCompPolicyHasLowercase).(bool), - HasNumber: d.Get(passwordCompPolicyHasNumber).(bool), - HasSymbol: d.Get(passwordCompPolicyHasSymbol).(bool), - }) - if err != nil { - return diag.Errorf("failed to update password complexity policy: %v", err) - } - d.SetId(org) - return nil -} - -func createPasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(passwordCompPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.AddCustomPasswordComplexityPolicy(ctx, &management2.AddCustomPasswordComplexityPolicyRequest{ - MinLength: uint64(d.Get(passwordCompPolicyMinLength).(int)), - HasUppercase: d.Get(passwordCompPolicyHasUppercase).(bool), - HasLowercase: d.Get(passwordCompPolicyHasLowercase).(bool), - HasNumber: d.Get(passwordCompPolicyHasNumber).(bool), - HasSymbol: d.Get(passwordCompPolicyHasSymbol).(bool), - }) - if err != nil { - return diag.Errorf("failed to create password complexity policy: %v", err) - } - d.SetId(org) - return nil -} - -func readPasswordComplexityPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(domainPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetPasswordComplexityPolicy(ctx, &management2.GetPasswordComplexityPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get password complexity policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - passwordCompPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - passwordCompPolicyMinLength: policy.GetMinLength(), - passwordCompPolicyHasUppercase: policy.GetHasUppercase(), - passwordCompPolicyHasLowercase: policy.GetHasLowercase(), - passwordCompPolicyHasNumber: policy.GetHasNumber(), - passwordCompPolicyHasSymbol: policy.GetHasSymbol(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of password complexity policy: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/password_complexity_policy/const.go b/zitadel/v2/password_complexity_policy/const.go new file mode 100644 index 00000000..6b1a38ec --- /dev/null +++ b/zitadel/v2/password_complexity_policy/const.go @@ -0,0 +1,10 @@ +package password_complexity_policy + +const ( + orgIDVar = "org_id" + minLengthVar = "min_length" + hasUppercaseVar = "has_uppercase" + hasLowercaseVar = "has_lowercase" + hasNumberVar = "has_number" + hasSymbolVar = "has_symbol" +) diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go new file mode 100644 index 00000000..d67cc0bc --- /dev/null +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -0,0 +1,133 @@ +package password_complexity_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetPasswordComplexityPolicyToDefault(ctx, &management.ResetPasswordComplexityPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset password complexity policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateCustomPasswordComplexityPolicy(ctx, &management.UpdateCustomPasswordComplexityPolicyRequest{ + MinLength: uint64(d.Get(minLengthVar).(int)), + HasUppercase: d.Get(hasUppercaseVar).(bool), + HasLowercase: d.Get(hasLowercaseVar).(bool), + HasNumber: d.Get(hasNumberVar).(bool), + HasSymbol: d.Get(hasSymbolVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update password complexity policy: %v", err) + } + d.SetId(org) + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.AddCustomPasswordComplexityPolicy(ctx, &management.AddCustomPasswordComplexityPolicyRequest{ + MinLength: uint64(d.Get(minLengthVar).(int)), + HasUppercase: d.Get(hasUppercaseVar).(bool), + HasLowercase: d.Get(hasLowercaseVar).(bool), + HasNumber: d.Get(hasNumberVar).(bool), + HasSymbol: d.Get(hasSymbolVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create password complexity policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetPasswordComplexityPolicy(ctx, &management.GetPasswordComplexityPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get password complexity policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + minLengthVar: policy.GetMinLength(), + hasUppercaseVar: policy.GetHasUppercase(), + hasLowercaseVar: policy.GetHasLowercase(), + hasNumberVar: policy.GetHasNumber(), + hasSymbolVar: policy.GetHasSymbol(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of password complexity policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/password_complexity_policy/resource.go b/zitadel/v2/password_complexity_policy/resource.go new file mode 100644 index 00000000..e9152277 --- /dev/null +++ b/zitadel/v2/password_complexity_policy/resource.go @@ -0,0 +1,49 @@ +package password_complexity_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom password complexity policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + minLengthVar: { + Type: schema.TypeInt, + Required: true, + Description: "Minimal length for the password", + }, + hasUppercaseVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain an upper case letter", + }, + hasLowercaseVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a lower case letter", + }, + hasNumberVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a number", + }, + hasSymbolVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a symbol. E.g. \"$\"", + }, + }, + DeleteContext: delete, + ReadContext: read, + CreateContext: create, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/pat.go b/zitadel/v2/pat.go deleted file mode 100644 index 568d5f6d..00000000 --- a/zitadel/v2/pat.go +++ /dev/null @@ -1,146 +0,0 @@ -package v2 - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/timestamppb" -) - -const ( - patOrgIDVar = "org_id" - patUserIDVar = "user_id" - patTokenVar = "token" - patExpirationDateVar = "expiration_date" -) - -func GetPAT() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a personal access token of a user", - Schema: map[string]*schema.Schema{ - patOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - patUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - patTokenVar: { - Type: schema.TypeString, - Computed: true, - Description: "Value of the token", - Sensitive: true, - }, - patExpirationDateVar: { - Type: schema.TypeString, - Required: true, - Description: "Expiration date of the token", - ForceNew: true, - }, - }, - DeleteContext: deletePAT, - CreateContext: createPAT, - ReadContext: readPAT, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deletePAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(patOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemovePersonalAccessToken(ctx, &management2.RemovePersonalAccessTokenRequest{ - UserId: d.Get(patUserIDVar).(string), - TokenId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete PAT: %v", err) - } - return nil -} - -func createPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(patOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - t, err := time.Parse(time.RFC3339, d.Get(patExpirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) - } - - resp, err := client.AddPersonalAccessToken(ctx, &management2.AddPersonalAccessTokenRequest{ - UserId: d.Get(patUserIDVar).(string), - ExpirationDate: timestamppb.New(t), - }) - - if err := d.Set(patTokenVar, resp.GetToken()); err != nil { - return diag.FromErr(err) - } - d.SetId(resp.GetTokenId()) - return nil -} - -func readPAT(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(patOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(patUserIDVar).(string) - resp, err := client.GetPersonalAccessTokenByIDs(ctx, &management2.GetPersonalAccessTokenByIDsRequest{ - UserId: userID, - TokenId: d.Id(), - }) - if err != nil { - d.SetId("") - return nil - } - - set := map[string]interface{}{ - patExpirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), - patUserIDVar: userID, - patOrgIDVar: orgID, - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of project: %v", k, err) - } - } - d.SetId(resp.GetToken().GetId()) - return nil -} diff --git a/zitadel/v2/pat/const.go b/zitadel/v2/pat/const.go new file mode 100644 index 00000000..ba910db3 --- /dev/null +++ b/zitadel/v2/pat/const.go @@ -0,0 +1,8 @@ +package pat + +const ( + orgIDVar = "org_id" + userIDVar = "user_id" + tokenVar = "token" + expirationDateVar = "expiration_date" +) diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go new file mode 100644 index 00000000..635eaadf --- /dev/null +++ b/zitadel/v2/pat/funcs.go @@ -0,0 +1,105 @@ +package pat + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemovePersonalAccessToken(ctx, &management.RemovePersonalAccessTokenRequest{ + UserId: d.Get(userIDVar).(string), + TokenId: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete PAT: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + + resp, err := client.AddPersonalAccessToken(ctx, &management.AddPersonalAccessTokenRequest{ + UserId: d.Get(userIDVar).(string), + ExpirationDate: timestamppb.New(t), + }) + + if err := d.Set(tokenVar, resp.GetToken()); err != nil { + return diag.FromErr(err) + } + d.SetId(resp.GetTokenId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + resp, err := client.GetPersonalAccessTokenByIDs(ctx, &management.GetPersonalAccessTokenByIDsRequest{ + UserId: userID, + TokenId: d.Id(), + }) + if err != nil { + d.SetId("") + return nil + } + + set := map[string]interface{}{ + expirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), + userIDVar: userID, + orgIDVar: orgID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of project: %v", k, err) + } + } + d.SetId(resp.GetToken().GetId()) + return nil +} diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go new file mode 100644 index 00000000..8b22d8cd --- /dev/null +++ b/zitadel/v2/pat/resource.go @@ -0,0 +1,41 @@ +package pat + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a personal access token of a user", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + tokenVar: { + Type: schema.TypeString, + Computed: true, + Description: "Value of the token", + Sensitive: true, + }, + expirationDateVar: { + Type: schema.TypeString, + Required: true, + Description: "Expiration date of the token", + ForceNew: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/privacy_policy.go b/zitadel/v2/privacy_policy.go deleted file mode 100644 index edbe6107..00000000 --- a/zitadel/v2/privacy_policy.go +++ /dev/null @@ -1,166 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - privacyPolicyOrgIdVar = "org_id" - privacyPolicyTOSLink = "tos_link" - privacyPolicyPrivacyLink = "privacy_link" - privacyPolicyHelpLink = "help_link" -) - -func GetPrivacyPolicy() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the custom privacy policy of an organization.", - Schema: map[string]*schema.Schema{ - privacyPolicyOrgIdVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, - privacyPolicyTOSLink: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - privacyPolicyPrivacyLink: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - privacyPolicyHelpLink: { - Type: schema.TypeString, - Required: true, - Description: "", - }, - }, - CreateContext: createPrivacyPolicy, - DeleteContext: deletePrivacyPolicy, - ReadContext: readPrivacyPolicy, - UpdateContext: updatePrivacyPolicy, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deletePrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(privacyPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.ResetPrivacyPolicyToDefault(ctx, &management2.ResetPrivacyPolicyToDefaultRequest{}) - if err != nil { - return diag.Errorf("failed to reset privacy policy: %v", err) - } - return nil -} - -func updatePrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(privacyPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateCustomPrivacyPolicy(ctx, &management2.UpdateCustomPrivacyPolicyRequest{ - TosLink: d.Get(privacyPolicyTOSLink).(string), - PrivacyLink: d.Get(privacyPolicyPrivacyLink).(string), - HelpLink: d.Get(privacyPolicyHelpLink).(string), - }) - if err != nil { - return diag.Errorf("failed to update privacy policy: %v", err) - } - d.SetId(org) - return nil -} - -func createPrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(privacyPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.AddCustomPrivacyPolicy(ctx, &management2.AddCustomPrivacyPolicyRequest{ - TosLink: d.Get(privacyPolicyTOSLink).(string), - PrivacyLink: d.Get(privacyPolicyPrivacyLink).(string), - HelpLink: d.Get(privacyPolicyHelpLink).(string), - }) - if err != nil { - return diag.Errorf("failed to create privacy policy: %v", err) - } - d.SetId(org) - return nil -} - -func readPrivacyPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(privacyPolicyOrgIdVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetPrivacyPolicy(ctx, &management2.GetPrivacyPolicyRequest{}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get privacy policy: %v", err) - } - - policy := resp.Policy - if policy.GetIsDefault() == true { - d.SetId("") - return nil - } - set := map[string]interface{}{ - privacyPolicyOrgIdVar: policy.GetDetails().GetResourceOwner(), - privacyPolicyTOSLink: policy.GetTosLink(), - privacyPolicyPrivacyLink: policy.GetPrivacyLink(), - privacyPolicyHelpLink: policy.GetHelpLink(), - } - - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of privacy policy: %v", k, err) - } - } - d.SetId(policy.GetDetails().GetResourceOwner()) - return nil -} diff --git a/zitadel/v2/privacy_policy/const.go b/zitadel/v2/privacy_policy/const.go new file mode 100644 index 00000000..712d5110 --- /dev/null +++ b/zitadel/v2/privacy_policy/const.go @@ -0,0 +1,8 @@ +package privacy_policy + +const ( + orgIDVar = "org_id" + tosLinkVar = "tos_link" + privacyLinkVar = "privacy_link" + helpLinkVar = "help_link" +) diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go new file mode 100644 index 00000000..ec539a5e --- /dev/null +++ b/zitadel/v2/privacy_policy/funcs.go @@ -0,0 +1,127 @@ +package privacy_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetPrivacyPolicyToDefault(ctx, &management.ResetPrivacyPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset privacy policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateCustomPrivacyPolicy(ctx, &management.UpdateCustomPrivacyPolicyRequest{ + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update privacy policy: %v", err) + } + d.SetId(org) + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.AddCustomPrivacyPolicy(ctx, &management.AddCustomPrivacyPolicyRequest{ + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + }) + if err != nil { + return diag.Errorf("failed to create privacy policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetPrivacyPolicy(ctx, &management.GetPrivacyPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get privacy policy: %v", err) + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + tosLinkVar: policy.GetTosLink(), + privacyLinkVar: policy.GetPrivacyLink(), + helpLinkVar: policy.GetHelpLink(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of privacy policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go new file mode 100644 index 00000000..bdf75e34 --- /dev/null +++ b/zitadel/v2/privacy_policy/resource.go @@ -0,0 +1,39 @@ +package privacy_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom privacy policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + tosLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + privacyLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + helpLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + }, + CreateContext: create, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project.go b/zitadel/v2/project.go deleted file mode 100644 index c9d291c5..00000000 --- a/zitadel/v2/project.go +++ /dev/null @@ -1,196 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" -) - -const ( - projectIdVar = "id" - projectNameVar = "name" - projectStateVar = "state" - projectOrgIDVar = "org_id" - projectRoleAssertionVar = "project_role_assertion" - projectRoleCheckVar = "project_role_check" - projectHasProjectCheckVar = "has_project_check" - projectPrivateLabelingSettingVar = "private_labeling_setting" -) - -func GetProject() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the project, which can then be granted to different organizations or users directly, containing different applications.", - Schema: map[string]*schema.Schema{ - projectIdVar: { - Type: schema.TypeString, - Computed: true, - Description: "ID of the project", - ForceNew: true, - }, - projectNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the project", - }, - projectOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Organization in which the project is located", - }, - projectStateVar: { - Type: schema.TypeString, - Computed: true, - Description: "State of the project", - }, - projectRoleAssertionVar: { - Type: schema.TypeBool, - Optional: true, - Description: "describes if roles of user should be added in token", - }, - projectRoleCheckVar: { - Type: schema.TypeBool, - Optional: true, - Description: "ZITADEL checks if the user has at least one on this project", - }, - projectHasProjectCheckVar: { - Type: schema.TypeBool, - Optional: true, - Description: "ZITADEL checks if the org of the user has permission to this project", - }, - projectPrivateLabelingSettingVar: { - Type: schema.TypeString, - Optional: true, - Description: "Defines from where the private labeling should be triggered", - }, - }, - DeleteContext: deleteProject, - CreateContext: createProject, - UpdateContext: updateProject, - ReadContext: readProject, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteProject(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveProject(ctx, &management2.RemoveProjectRequest{ - Id: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete project: %v", err) - } - return nil -} - -func updateProject(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - plSetting := d.Get(projectPrivateLabelingSettingVar).(string) - _, err = client.UpdateProject(ctx, &management2.UpdateProjectRequest{ - Id: d.Id(), - Name: d.Get(projectNameVar).(string), - ProjectRoleCheck: d.Get(projectRoleCheckVar).(bool), - ProjectRoleAssertion: d.Get(projectRoleAssertionVar).(bool), - HasProjectCheck: d.Get(projectHasProjectCheckVar).(bool), - PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[plSetting]), - }) - if err != nil { - return diag.Errorf("failed to update project: %v", err) - } - - return nil -} - -func createProject(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - plSetting := d.Get(projectPrivateLabelingSettingVar).(string) - resp, err := client.AddProject(ctx, &management2.AddProjectRequest{ - Name: d.Get(projectNameVar).(string), - ProjectRoleAssertion: d.Get(projectRoleAssertionVar).(bool), - ProjectRoleCheck: d.Get(projectRoleCheckVar).(bool), - HasProjectCheck: d.Get(projectHasProjectCheckVar).(bool), - PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[plSetting]), - }) - if err != nil { - return diag.Errorf("failed to create project: %v", err) - } - d.SetId(resp.GetId()) - return nil -} - -func readProject(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetProjectByID(ctx, &management2.GetProjectByIDRequest{Id: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read project: %v", err) - } - - project := resp.GetProject() - set := map[string]interface{}{ - projectIdVar: project.GetId(), - projectOrgIDVar: project.GetDetails().GetResourceOwner(), - projectStateVar: project.GetState().String(), - projectNameVar: project.GetName(), - projectRoleAssertionVar: project.GetProjectRoleAssertion(), - projectRoleCheckVar: project.GetProjectRoleCheck(), - projectHasProjectCheckVar: project.GetHasProjectCheck(), - projectPrivateLabelingSettingVar: project.PrivateLabelingSetting.String(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of project: %v", k, err) - } - } - d.SetId(project.GetId()) - - return nil -} diff --git a/zitadel/v2/project/const.go b/zitadel/v2/project/const.go new file mode 100644 index 00000000..2c66d4df --- /dev/null +++ b/zitadel/v2/project/const.go @@ -0,0 +1,12 @@ +package project + +const ( + projectIDVar = "project_id" + nameVar = "name" + stateVar = "state" + orgIDVar = "org_id" + roleAssertionVar = "project_role_assertion" + roleCheckVar = "project_role_check" + hasProjectCheckVar = "has_project_check" + privateLabelingSettingVar = "private_labeling_setting" +) diff --git a/zitadel/v2/project/datasource.go b/zitadel/v2/project/datasource.go new file mode 100644 index 00000000..7c6f2d90 --- /dev/null +++ b/zitadel/v2/project/datasource.go @@ -0,0 +1,55 @@ +package project + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing the project, which can then be granted to different organizations or users directly, containing different applications.", + Schema: map[string]*schema.Schema{ + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the project", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Organization in which the project is located", + }, + stateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the project", + }, + roleAssertionVar: { + Type: schema.TypeBool, + Computed: true, + Description: "describes if roles of user should be added in token", + }, + roleCheckVar: { + Type: schema.TypeBool, + Computed: true, + Description: "ZITADEL checks if the user has at least one on this project", + }, + hasProjectCheckVar: { + Type: schema.TypeBool, + Computed: true, + Description: "ZITADEL checks if the org of the user has permission to this project", + }, + privateLabelingSettingVar: { + Type: schema.TypeString, + Computed: true, + Description: "Defines from where the private labeling should be triggered", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go new file mode 100644 index 00000000..4cf43d45 --- /dev/null +++ b/zitadel/v2/project/funcs.go @@ -0,0 +1,132 @@ +package project + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveProject(ctx, &management.RemoveProjectRequest{ + Id: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete project: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + plSetting := d.Get(privateLabelingSettingVar).(string) + _, err = client.UpdateProject(ctx, &management.UpdateProjectRequest{ + Id: d.Id(), + Name: d.Get(nameVar).(string), + ProjectRoleCheck: d.Get(roleCheckVar).(bool), + ProjectRoleAssertion: d.Get(roleAssertionVar).(bool), + HasProjectCheck: d.Get(hasProjectCheckVar).(bool), + PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[plSetting]), + }) + if err != nil { + return diag.Errorf("failed to update project: %v", err) + } + + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + plSetting := d.Get(privateLabelingSettingVar).(string) + resp, err := client.AddProject(ctx, &management.AddProjectRequest{ + Name: d.Get(nameVar).(string), + ProjectRoleAssertion: d.Get(roleAssertionVar).(bool), + ProjectRoleCheck: d.Get(roleCheckVar).(bool), + HasProjectCheck: d.Get(hasProjectCheckVar).(bool), + PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[plSetting]), + }) + if err != nil { + return diag.Errorf("failed to create project: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetProjectByID(ctx, &management.GetProjectByIDRequest{Id: helper.GetID(d, projectIDVar)}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read project: %v", err) + } + + project := resp.GetProject() + set := map[string]interface{}{ + orgIDVar: project.GetDetails().GetResourceOwner(), + stateVar: project.GetState().String(), + nameVar: project.GetName(), + roleAssertionVar: project.GetProjectRoleAssertion(), + roleCheckVar: project.GetProjectRoleCheck(), + hasProjectCheckVar: project.GetHasProjectCheck(), + privateLabelingSettingVar: project.PrivateLabelingSetting.String(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of project: %v", k, err) + } + } + d.SetId(project.GetId()) + + return nil +} diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go new file mode 100644 index 00000000..53062fa8 --- /dev/null +++ b/zitadel/v2/project/resource.go @@ -0,0 +1,65 @@ +package project + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the project, which can then be granted to different organizations or users directly, containing different applications.", + Schema: map[string]*schema.Schema{ + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the project", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Organization in which the project is located", + }, + stateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the project", + /* Not necessary as long as only active projects are created + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return EnumValueValidation(projectStateVar, value, project.ProjectState_value) + },*/ + }, + roleAssertionVar: { + Type: schema.TypeBool, + Optional: true, + Description: "describes if roles of user should be added in token", + }, + roleCheckVar: { + Type: schema.TypeBool, + Optional: true, + Description: "ZITADEL checks if the user has at least one on this project", + }, + hasProjectCheckVar: { + Type: schema.TypeBool, + Optional: true, + Description: "ZITADEL checks if the org of the user has permission to this project", + }, + privateLabelingSettingVar: { + Type: schema.TypeString, + Optional: true, + Description: "Defines from where the private labeling should be triggered", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(privateLabelingSettingVar, value, project.PrivateLabelingSetting_value) + }, + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project_grant.go b/zitadel/v2/project_grant.go deleted file mode 100644 index b20b3331..00000000 --- a/zitadel/v2/project_grant.go +++ /dev/null @@ -1,168 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - projectGrantOrgIDVar = "org_id" - projectGrantProjectIDVar = "project_id" - projectGrantGrantedOrgIDVar = "granted_org_id" - projectGrantRoleKeysVar = "role_keys" -) - -func GetProjectGrant() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant.", - Schema: map[string]*schema.Schema{ - projectGrantProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - projectGrantGrantedOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization granted the project", - ForceNew: true, - }, - projectGrantRoleKeysVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - Description: "List of roles granted", - }, - projectGrantOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - }, - }, - DeleteContext: deleteProjectGrant, - CreateContext: createProjectGrant, - UpdateContext: updateProjectGrant, - ReadContext: readProjectGrant, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteProjectGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveProjectGrant(ctx, &management2.RemoveProjectGrantRequest{ - GrantId: d.Id(), - ProjectId: d.Get(projectGrantProjectIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to delete projectgrant: %v", err) - } - return nil -} - -func updateProjectGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateProjectGrant(ctx, &management2.UpdateProjectGrantRequest{ - GrantId: d.Id(), - ProjectId: d.Get(projectGrantProjectIDVar).(string), - RoleKeys: d.Get(projectGrantRoleKeysVar).([]string), - }) - if err != nil { - return diag.Errorf("failed to update projectgrant: %v", err) - } - return nil -} - -func createProjectGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - roles := make([]string, 0) - for _, role := range d.Get(projectGrantRoleKeysVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - - resp, err := client.AddProjectGrant(ctx, &management2.AddProjectGrantRequest{ - GrantedOrgId: d.Get(projectGrantGrantedOrgIDVar).(string), - ProjectId: d.Get(projectGrantProjectIDVar).(string), - RoleKeys: roles, - }) - if err != nil { - return diag.Errorf("failed to create projectgrant: %v", err) - } - d.SetId(resp.GetGrantId()) - return nil -} - -func readProjectGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - resp, err := client.GetProjectGrantByID(ctx, &management2.GetProjectGrantByIDRequest{ProjectId: d.Get(projectGrantProjectIDVar).(string), GrantId: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read projectgrant: %v", err) - } - - projectGrant := resp.GetProjectGrant() - set := map[string]interface{}{ - projectGrantProjectIDVar: projectGrant.GetProjectId(), - projectGrantGrantedOrgIDVar: projectGrant.GetGrantedOrgId(), - projectGrantRoleKeysVar: projectGrant.GetGrantedRoleKeys(), - projectGrantOrgIDVar: projectGrant.GetDetails().GetResourceOwner(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectgrant: %v", k, err) - } - } - d.SetId(projectGrant.GetGrantId()) - return nil -} diff --git a/zitadel/v2/project_grant/const.go b/zitadel/v2/project_grant/const.go new file mode 100644 index 00000000..cf2c9bd0 --- /dev/null +++ b/zitadel/v2/project_grant/const.go @@ -0,0 +1,8 @@ +package project_grant + +const ( + orgIDVar = "org_id" + projectIDVar = "project_id" + grantedOrgIDVar = "granted_org_id" + roleKeysVar = "role_keys" +) diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go new file mode 100644 index 00000000..d77aabc5 --- /dev/null +++ b/zitadel/v2/project_grant/funcs.go @@ -0,0 +1,125 @@ +package project_grant + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveProjectGrant(ctx, &management.RemoveProjectGrantRequest{ + GrantId: d.Id(), + ProjectId: d.Get(projectIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete projectgrant: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateProjectGrant(ctx, &management.UpdateProjectGrantRequest{ + GrantId: d.Id(), + ProjectId: d.Get(projectIDVar).(string), + RoleKeys: d.Get(roleKeysVar).([]string), + }) + if err != nil { + return diag.Errorf("failed to update projectgrant: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + roles := make([]string, 0) + for _, role := range d.Get(roleKeysVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + + resp, err := client.AddProjectGrant(ctx, &management.AddProjectGrantRequest{ + GrantedOrgId: d.Get(grantedOrgIDVar).(string), + ProjectId: d.Get(projectIDVar).(string), + RoleKeys: roles, + }) + if err != nil { + return diag.Errorf("failed to create projectgrant: %v", err) + } + d.SetId(resp.GetGrantId()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetProjectGrantByID(ctx, &management.GetProjectGrantByIDRequest{ProjectId: d.Get(projectIDVar).(string), GrantId: d.Id()}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read projectgrant: %v", err) + } + + projectGrant := resp.GetProjectGrant() + set := map[string]interface{}{ + projectIDVar: projectGrant.GetProjectId(), + grantedOrgIDVar: projectGrant.GetGrantedOrgId(), + roleKeysVar: projectGrant.GetGrantedRoleKeys(), + orgIDVar: projectGrant.GetDetails().GetResourceOwner(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of projectgrant: %v", k, err) + } + } + d.SetId(projectGrant.GetGrantId()) + return nil +} diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/v2/project_grant/resource.go new file mode 100644 index 00000000..00a870d5 --- /dev/null +++ b/zitadel/v2/project_grant/resource.go @@ -0,0 +1,43 @@ +package project_grant + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant.", + Schema: map[string]*schema.Schema{ + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + grantedOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization granted the project", + ForceNew: true, + }, + roleKeysVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "List of roles granted", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization which owns the resource", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project_grant_member.go b/zitadel/v2/project_grant_member.go deleted file mode 100644 index 68130516..00000000 --- a/zitadel/v2/project_grant_member.go +++ /dev/null @@ -1,206 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" -) - -const ( - projectGrantMemberOrgIDVar = "org_id" - projectGrantMemberProjectIDVar = "project_id" - projectGrantMemberGrantIDVar = "grant_id" - projectGrantMemberUserIDVar = "user_id" - projectGrantMemberRolesVar = "roles" -) - -func GetProjectGrantMember() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the membership of a user on an granted project, defined with the given role.", - Schema: map[string]*schema.Schema{ - projectGrantMemberOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, - projectGrantMemberProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - projectGrantMemberGrantIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the grant", - ForceNew: true, - }, - projectGrantMemberUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - projectGrantMemberRolesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "List of roles granted", - }, - }, - DeleteContext: deleteProjectGrantMember, - CreateContext: createProjectGrantMember, - UpdateContext: updateProjectGrantMember, - ReadContext: readProjectGrantMember, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteProjectGrantMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveProjectGrantMember(ctx, &management2.RemoveProjectGrantMemberRequest{ - UserId: d.Get(projectGrantMemberUserIDVar).(string), - ProjectId: d.Get(projectGrantMemberProjectIDVar).(string), - GrantId: d.Get(projectGrantMemberGrantIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to delete projectmember: %v", err) - } - return nil -} - -func updateProjectGrantMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectGrantMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateProjectGrantMember(ctx, &management2.UpdateProjectGrantMemberRequest{ - UserId: d.Get(projectGrantMemberUserIDVar).(string), - Roles: d.Get(projectGrantMemberRolesVar).([]string), - ProjectId: d.Get(projectGrantMemberProjectIDVar).(string), - GrantId: d.Get(projectGrantMemberGrantIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update projectmember: %v", err) - } - return nil -} - -func createProjectGrantMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(projectGrantMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(projectGrantMemberUserIDVar).(string) - projectID := d.Get(projectGrantMemberProjectIDVar).(string) - grantID := d.Get(projectGrantMemberGrantIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(projectGrantMemberRolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - _, err = client.AddProjectGrantMember(ctx, &management2.AddProjectGrantMemberRequest{ - UserId: userID, - ProjectId: projectID, - GrantId: grantID, - Roles: roles, - }) - if err != nil { - return diag.Errorf("failed to create projectgrantmember: %v", err) - } - d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) - return nil -} - -func readProjectGrantMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - org := d.Get(projectGrantMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(projectGrantMemberProjectIDVar).(string) - grantID := d.Get(projectGrantMemberGrantIDVar).(string) - userID := d.Get(projectGrantMemberUserIDVar).(string) - resp, err := client.ListProjectGrantMembers(ctx, &management2.ListProjectGrantMembersRequest{ - ProjectId: projectID, - GrantId: grantID, - Queries: []*member.SearchQuery{{ - Query: &member.SearchQuery_UserIdQuery{ - UserIdQuery: &member.UserIDQuery{ - UserId: userID, - }, - }, - }}, - }) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read projectgrantmember: %v", err) - } - - if len(resp.Result) == 1 { - memberRes := resp.Result[0] - set := map[string]interface{}{ - projectGrantMemberUserIDVar: userID, - projectGrantMemberOrgIDVar: memberRes.GetDetails().GetResourceOwner(), - projectGrantMemberProjectIDVar: projectID, - projectGrantMemberRolesVar: memberRes.GetRoles(), - projectGrantMemberGrantIDVar: grantID, - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectgrantmember: %v", k, err) - } - } - d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) - return nil - } - - d.SetId("") - return nil -} - -func getProjectGrantMemberID(org, projectID, grantID, userID string) string { - return org + "_" + projectID + "_" + grantID + "_" + userID -} diff --git a/zitadel/v2/project_grant_member/const.go b/zitadel/v2/project_grant_member/const.go new file mode 100644 index 00000000..7132933c --- /dev/null +++ b/zitadel/v2/project_grant_member/const.go @@ -0,0 +1,9 @@ +package project_grant_member + +const ( + orgIDVar = "org_id" + projectIDVar = "project_id" + grantIDVar = "grant_id" + userIDVar = "user_id" + rolesVar = "roles" +) diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go new file mode 100644 index 00000000..c4875368 --- /dev/null +++ b/zitadel/v2/project_grant_member/funcs.go @@ -0,0 +1,155 @@ +package project_grant_member + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveProjectGrantMember(ctx, &management.RemoveProjectGrantMemberRequest{ + UserId: d.Get(userIDVar).(string), + ProjectId: d.Get(projectIDVar).(string), + GrantId: d.Get(grantIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete projectmember: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateProjectGrantMember(ctx, &management.UpdateProjectGrantMemberRequest{ + UserId: d.Get(userIDVar).(string), + Roles: d.Get(rolesVar).([]string), + ProjectId: d.Get(projectIDVar).(string), + GrantId: d.Get(grantIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update projectmember: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + projectID := d.Get(projectIDVar).(string) + grantID := d.Get(grantIDVar).(string) + roles := make([]string, 0) + for _, role := range d.Get(rolesVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + _, err = client.AddProjectGrantMember(ctx, &management.AddProjectGrantMemberRequest{ + UserId: userID, + ProjectId: projectID, + GrantId: grantID, + Roles: roles, + }) + if err != nil { + return diag.Errorf("failed to create projectgrantmember: %v", err) + } + d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + grantID := d.Get(grantIDVar).(string) + userID := d.Get(userIDVar).(string) + resp, err := client.ListProjectGrantMembers(ctx, &management.ListProjectGrantMembersRequest{ + ProjectId: projectID, + GrantId: grantID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read projectgrantmember: %v", err) + } + + if len(resp.Result) == 1 { + memberRes := resp.Result[0] + set := map[string]interface{}{ + userIDVar: userID, + orgIDVar: memberRes.GetDetails().GetResourceOwner(), + projectIDVar: projectID, + rolesVar: memberRes.GetRoles(), + grantIDVar: grantID, + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of projectgrantmember: %v", k, err) + } + } + d.SetId(getProjectGrantMemberID(org, projectID, grantID, userID)) + return nil + } + + d.SetId("") + return nil +} + +func getProjectGrantMemberID(org, projectID, grantID, userID string) string { + return org + "_" + projectID + "_" + grantID + "_" + userID +} diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/v2/project_grant_member/resource.go new file mode 100644 index 00000000..812681ad --- /dev/null +++ b/zitadel/v2/project_grant_member/resource.go @@ -0,0 +1,50 @@ +package project_grant_member + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the membership of a user on an granted project, defined with the given role.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization which owns the resource", + ForceNew: true, + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + grantIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the grant", + ForceNew: true, + }, + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + rolesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "List of roles granted", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project_member.go b/zitadel/v2/project_member.go deleted file mode 100644 index 6b471782..00000000 --- a/zitadel/v2/project_member.go +++ /dev/null @@ -1,193 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" -) - -const ( - projectMemberOrgIDVar = "org_id" - projectMemberProjectIDVar = "project_id" - projectMemberUserIDVar = "user_id" - projectMemberRolesVar = "roles" -) - -func GetProjectMember() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the membership of a user on an project, defined with the given role.", - Schema: map[string]*schema.Schema{ - projectMemberOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, - projectMemberProjectIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - projectMemberUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - projectMemberRolesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "List of roles granted", - }, - }, - DeleteContext: deleteProjectMember, - CreateContext: createProjectMember, - UpdateContext: updateProjectMember, - ReadContext: readProjectMember, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteProjectMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveProjectMember(ctx, &management2.RemoveProjectMemberRequest{ - UserId: d.Get(projectMemberUserIDVar).(string), - ProjectId: d.Get(projectMemberProjectIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to delete projectmember: %v", err) - } - return nil -} - -func updateProjectMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectMemberOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateProjectMember(ctx, &management2.UpdateProjectMemberRequest{ - UserId: d.Get(projectMemberUserIDVar).(string), - Roles: d.Get(projectMemberRolesVar).([]string), - ProjectId: d.Get(projectMemberProjectIDVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update projectmember: %v", err) - } - return nil -} - -func createProjectMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - org := d.Get(projectMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - userID := d.Get(projectMemberUserIDVar).(string) - projectID := d.Get(projectMemberProjectIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(projectMemberRolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - - _, err = client.AddProjectMember(ctx, &management2.AddProjectMemberRequest{ - UserId: userID, - ProjectId: projectID, - Roles: roles, - }) - if err != nil { - return diag.Errorf("failed to create projectmember: %v", err) - } - d.SetId(getProjectMemberID(org, projectID, userID)) - return nil -} - -func readProjectMember(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - org := d.Get(projectMemberOrgIDVar).(string) - client, err := getManagementClient(clientinfo, org) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(projectMemberProjectIDVar).(string) - userID := d.Get(projectMemberUserIDVar).(string) - resp, err := client.ListProjectMembers(ctx, &management2.ListProjectMembersRequest{ - ProjectId: projectID, - Queries: []*member.SearchQuery{{ - Query: &member.SearchQuery_UserIdQuery{ - UserIdQuery: &member.UserIDQuery{ - UserId: userID, - }, - }, - }}, - }) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to read projectmember: %v", err) - } - - if len(resp.Result) == 1 { - memberRes := resp.Result[0] - set := map[string]interface{}{ - projectMemberUserIDVar: memberRes.GetUserId(), - projectMemberOrgIDVar: memberRes.GetDetails().GetResourceOwner(), - projectMemberProjectIDVar: projectID, - projectMemberRolesVar: memberRes.GetRoles(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of projectmember: %v", k, err) - } - } - d.SetId(getProjectMemberID(org, projectID, userID)) - return nil - } - - d.SetId("") - return nil -} - -func getProjectMemberID(org string, projectID string, userID string) string { - return org + "_" + projectID + "_" + userID -} diff --git a/zitadel/v2/project_member/const.go b/zitadel/v2/project_member/const.go new file mode 100644 index 00000000..b844b48d --- /dev/null +++ b/zitadel/v2/project_member/const.go @@ -0,0 +1,8 @@ +package project_member + +const ( + orgIDVar = "org_id" + projectIDVar = "project_id" + userIDVar = "user_id" + rolesVar = "roles" +) diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go new file mode 100644 index 00000000..901f9de2 --- /dev/null +++ b/zitadel/v2/project_member/funcs.go @@ -0,0 +1,149 @@ +package project_member + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveProjectMember(ctx, &management.RemoveProjectMemberRequest{ + UserId: d.Get(userIDVar).(string), + ProjectId: d.Get(projectIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete projectmember: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateProjectMember(ctx, &management.UpdateProjectMemberRequest{ + UserId: d.Get(userIDVar).(string), + Roles: d.Get(rolesVar).([]string), + ProjectId: d.Get(projectIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update projectmember: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + projectID := d.Get(projectIDVar).(string) + roles := make([]string, 0) + for _, role := range d.Get(rolesVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + + _, err = client.AddProjectMember(ctx, &management.AddProjectMemberRequest{ + UserId: userID, + ProjectId: projectID, + Roles: roles, + }) + if err != nil { + return diag.Errorf("failed to create projectmember: %v", err) + } + d.SetId(getProjectMemberID(org, projectID, userID)) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + userID := d.Get(userIDVar).(string) + resp, err := client.ListProjectMembers(ctx, &management.ListProjectMembersRequest{ + ProjectId: projectID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to read projectmember: %v", err) + } + + if len(resp.Result) == 1 { + memberRes := resp.Result[0] + set := map[string]interface{}{ + userIDVar: memberRes.GetUserId(), + orgIDVar: memberRes.GetDetails().GetResourceOwner(), + projectIDVar: projectID, + rolesVar: memberRes.GetRoles(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of projectmember: %v", k, err) + } + } + d.SetId(getProjectMemberID(org, projectID, userID)) + return nil + } + + d.SetId("") + return nil +} + +func getProjectMemberID(org string, projectID string, userID string) string { + return org + "_" + projectID + "_" + userID +} diff --git a/zitadel/v2/project_member/resource.go b/zitadel/v2/project_member/resource.go new file mode 100644 index 00000000..3968334d --- /dev/null +++ b/zitadel/v2/project_member/resource.go @@ -0,0 +1,44 @@ +package project_member + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the membership of a user on an project, defined with the given role.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization which owns the resource", + ForceNew: true, + }, + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + rolesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "List of roles granted", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project_role.go b/zitadel/v2/project_role.go deleted file mode 100644 index a70feb6a..00000000 --- a/zitadel/v2/project_role.go +++ /dev/null @@ -1,198 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" - project2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" -) - -const ( - projectRoleOrgID = "org_id" - projectRoleProjectID = "project_id" - projectRoleKey = "role_key" - projectRoleDisplayName = "display_name" - projectRoleGroup = "group" -) - -func GetProjectRole() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the project roles, which can be given as authorizations to users.", - Schema: map[string]*schema.Schema{ - projectRoleProjectID: { - Type: schema.TypeString, - Required: true, - Description: "ID of the project", - ForceNew: true, - }, - projectRoleOrgID: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - projectRoleKey: { - Type: schema.TypeString, - Required: true, - Description: "Key used for project role", - }, - projectRoleDisplayName: { - Type: schema.TypeString, - Required: true, - Description: "Name used for project role", - }, - projectRoleGroup: { - Type: schema.TypeString, - Optional: true, - Description: "Group used for project role", - }, - }, - DeleteContext: deleteProjectRole, - CreateContext: createProjectRole, - UpdateContext: updateProjectRole, - ReadContext: readProjectRole, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectRoleOrgID).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveProjectRole(ctx, &management2.RemoveProjectRoleRequest{ - ProjectId: d.Get(projectRoleProjectID).(string), - RoleKey: d.Get(projectRoleKey).(string), - }) - if err != nil { - return diag.Errorf("failed to delete project role: %v", err) - } - return nil -} - -func updateProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(projectRoleOrgID).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.UpdateProjectRole(ctx, &management2.UpdateProjectRoleRequest{ - ProjectId: d.Get(projectRoleProjectID).(string), - RoleKey: d.Get(projectRoleKey).(string), - DisplayName: d.Get(projectRoleDisplayName).(string), - Group: d.Get(projectRoleGroup).(string), - }) - if err != nil { - return diag.Errorf("failed to update project role: %v", err) - } - - return nil -} - -func createProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(projectRoleOrgID).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(projectRoleProjectID).(string) - roleKey := d.Get(projectRoleKey).(string) - _, err = client.AddProjectRole(ctx, &management2.AddProjectRoleRequest{ - ProjectId: projectID, - RoleKey: roleKey, - DisplayName: d.Get(projectRoleDisplayName).(string), - Group: d.Get(projectRoleGroup).(string), - }) - if err != nil { - return diag.Errorf("failed to create project role: %v", err) - } - d.SetId(getProjectRoleID(orgID, projectID, roleKey)) - - return nil -} - -func readProjectRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(projectRoleOrgID).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - projectID := d.Get(projectRoleProjectID).(string) - resp, err := client.ListProjectRoles(ctx, &management2.ListProjectRolesRequest{ - ProjectId: projectID, - Queries: []*project2.RoleQuery{ - {Query: &project2.RoleQuery_KeyQuery{ - KeyQuery: &project2.RoleKeyQuery{ - Key: d.Get(projectRoleKey).(string), - Method: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS, - }, - }}, - }, - }) - if err != nil || resp.Result == nil || len(resp.Result) == 0 { - d.SetId("") - return nil - //return diag.Errorf("failed to read project role: %v", err) - } - - if len(resp.Result) == 1 { - projectRole := resp.GetResult()[0] - roleKey := projectRole.GetKey() - set := map[string]interface{}{ - projectRoleProjectID: projectID, - projectRoleOrgID: orgID, - projectRoleKey: roleKey, - projectRoleDisplayName: projectRole.GetDisplayName(), - projectRoleGroup: projectRole.GetGroup(), - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of project: %v", k, err) - } - } - d.SetId(getProjectRoleID(orgID, projectID, roleKey)) - return nil - } - - d.SetId("") - return nil -} - -func getProjectRoleID(orgID string, projectID string, roleKey string) string { - return orgID + "_" + projectID + "_" + roleKey -} diff --git a/zitadel/v2/project_role/const.go b/zitadel/v2/project_role/const.go new file mode 100644 index 00000000..bd4022f6 --- /dev/null +++ b/zitadel/v2/project_role/const.go @@ -0,0 +1,9 @@ +package project_role + +const ( + orgIDVar = "org_id" + projectIDVar = "project_id" + keyVar = "role_key" + displayNameVar = "display_name" + groupVar = "group" +) diff --git a/zitadel/v2/project_role/datasource.go b/zitadel/v2/project_role/datasource.go new file mode 100644 index 00000000..bbd40b77 --- /dev/null +++ b/zitadel/v2/project_role/datasource.go @@ -0,0 +1,38 @@ +package project_role + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing the project roles, which can be given as authorizations to users.", + Schema: map[string]*schema.Schema{ + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + keyVar: { + Type: schema.TypeString, + Required: true, + Description: "Key used for project role", + }, + displayNameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name used for project role", + }, + groupVar: { + Type: schema.TypeString, + Computed: true, + Description: "Group used for project role", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/v2/project_role/funcs.go new file mode 100644 index 00000000..06e8446d --- /dev/null +++ b/zitadel/v2/project_role/funcs.go @@ -0,0 +1,152 @@ +package project_role + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" + project2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveProjectRole(ctx, &management.RemoveProjectRoleRequest{ + ProjectId: d.Get(projectIDVar).(string), + RoleKey: d.Get(keyVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete project role: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateProjectRole(ctx, &management.UpdateProjectRoleRequest{ + ProjectId: d.Get(projectIDVar).(string), + RoleKey: d.Get(keyVar).(string), + DisplayName: d.Get(displayNameVar).(string), + Group: d.Get(groupVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update project role: %v", err) + } + + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + roleKey := d.Get(keyVar).(string) + _, err = client.AddProjectRole(ctx, &management.AddProjectRoleRequest{ + ProjectId: projectID, + RoleKey: roleKey, + DisplayName: d.Get(displayNameVar).(string), + Group: d.Get(groupVar).(string), + }) + if err != nil { + return diag.Errorf("failed to create project role: %v", err) + } + d.SetId(getProjectRoleID(orgID, projectID, roleKey)) + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + projectID := d.Get(projectIDVar).(string) + resp, err := client.ListProjectRoles(ctx, &management.ListProjectRolesRequest{ + ProjectId: projectID, + Queries: []*project2.RoleQuery{ + {Query: &project2.RoleQuery_KeyQuery{ + KeyQuery: &project2.RoleKeyQuery{ + Key: d.Get(keyVar).(string), + Method: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS, + }, + }}, + }, + }) + if err != nil || resp.Result == nil || len(resp.Result) == 0 { + d.SetId("") + return nil + //return diag.Errorf("failed to read project role: %v", err) + } + + if len(resp.Result) == 1 { + projectRole := resp.GetResult()[0] + roleKey := projectRole.GetKey() + set := map[string]interface{}{ + projectIDVar: projectID, + orgIDVar: orgID, + keyVar: roleKey, + displayNameVar: projectRole.GetDisplayName(), + groupVar: projectRole.GetGroup(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of project: %v", k, err) + } + } + d.SetId(getProjectRoleID(orgID, projectID, roleKey)) + return nil + } + + d.SetId("") + return nil +} + +func getProjectRoleID(orgID string, projectID string, roleKey string) string { + return orgID + "_" + projectID + "_" + roleKey +} diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go new file mode 100644 index 00000000..d5006e2e --- /dev/null +++ b/zitadel/v2/project_role/resource.go @@ -0,0 +1,45 @@ +package project_role + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the project roles, which can be given as authorizations to users.", + Schema: map[string]*schema.Schema{ + projectIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the project", + ForceNew: true, + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + keyVar: { + Type: schema.TypeString, + Required: true, + Description: "Key used for project role", + }, + displayNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name used for project role", + }, + groupVar: { + Type: schema.TypeString, + Optional: true, + Description: "Group used for project role", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/trigger_actions.go b/zitadel/v2/trigger_actions.go deleted file mode 100644 index de71c6d1..00000000 --- a/zitadel/v2/trigger_actions.go +++ /dev/null @@ -1,156 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) - -const ( - triggerActionsOrgIDVar = "org_id" - triggerActionsFlowTypeVar = "flow_type" - triggerActionsTriggerTypeVar = "trigger_type" - triggerActionsActionsVar = "action_ids" -) - -func GetTriggerActions() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing triggers, when actions get started", - Schema: map[string]*schema.Schema{ - triggerActionsOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - triggerActionsFlowTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Type of the flow to which the action triggers belong", - ForceNew: true, - }, - triggerActionsTriggerTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Trigger type on when the actions get triggered", - ForceNew: true, - }, - triggerActionsActionsVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "IDs of the triggered actions", - }, - }, - DeleteContext: deleteTriggerActions, - CreateContext: createTriggerActions, - UpdateContext: updateTriggerActions, - ReadContext: readTriggerActions, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(triggerActionsOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[d.Get(triggerActionsFlowTypeVar).(string)]), - TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerActionsTriggerTypeVar).(string)]), - ActionIds: []string{}, - }) - if err != nil { - return diag.Errorf("failed to delete trigger actions: %v", err) - } - return nil -} - -func updateTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(triggerActionsOrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - actionsSet := d.Get(triggerActionsActionsVar).(*schema.Set) - actions := make([]string, 0) - for _, action := range actionsSet.List() { - actions = append(actions, action.(string)) - } - _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[d.Get(triggerActionsFlowTypeVar).(string)]), - TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerActionsTriggerTypeVar).(string)]), - ActionIds: actions, - }) - if err != nil { - return diag.Errorf("failed to update trigger actions: %v", err) - } - - return nil -} - -func createTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - orgID := d.Get(triggerActionsOrgIDVar).(string) - client, err := getManagementClient(clientinfo, orgID) - if err != nil { - return diag.FromErr(err) - } - - actionsSet := d.Get(triggerActionsActionsVar).(*schema.Set) - actions := make([]string, 0) - for _, action := range actionsSet.List() { - actions = append(actions, action.(string)) - } - flowType := d.Get(triggerActionsFlowTypeVar).(string) - triggerType := d.Get(triggerActionsTriggerTypeVar).(string) - _, err = client.SetTriggerActions(ctx, &management2.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[flowType]), - TriggerType: action.TriggerType(action.TriggerType_value[triggerType]), - ActionIds: actions, - }) - d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) - - return nil -} - -func readTriggerActions(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - orgID := d.Get(triggerActionsOrgIDVar).(string) - flowType := d.Get(triggerActionsFlowTypeVar).(string) - triggerType := d.Get(triggerActionsTriggerTypeVar).(string) - d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) - return nil -} - -func getTriggerActionsID(orgID, flowType string, triggerType string) string { - return orgID + "_" + flowType + "_" + triggerType -} diff --git a/zitadel/v2/trigger_actions/const.go b/zitadel/v2/trigger_actions/const.go new file mode 100644 index 00000000..8c67e37b --- /dev/null +++ b/zitadel/v2/trigger_actions/const.go @@ -0,0 +1,8 @@ +package trigger_actions + +const ( + orgIDVar = "org_id" + flowTypeVar = "flow_type" + triggerTypeVar = "trigger_type" + actionsVar = "action_ids" +) diff --git a/zitadel/v2/trigger_actions/datasource.go b/zitadel/v2/trigger_actions/datasource.go new file mode 100644 index 00000000..a6f9049e --- /dev/null +++ b/zitadel/v2/trigger_actions/datasource.go @@ -0,0 +1,39 @@ +package trigger_actions + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing triggers, when actions get started", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + flowTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the flow to which the action triggers belong", + }, + triggerTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Trigger type on when the actions get triggered", + }, + actionsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "IDs of the triggered actions", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go new file mode 100644 index 00000000..f0f64d16 --- /dev/null +++ b/zitadel/v2/trigger_actions/funcs.go @@ -0,0 +1,112 @@ +package trigger_actions + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[d.Get(flowTypeVar).(string)]), + TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerTypeVar).(string)]), + ActionIds: []string{}, + }) + if err != nil { + return diag.Errorf("failed to delete trigger actions: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + actionsSet := d.Get(actionsVar).(*schema.Set) + actions := make([]string, 0) + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[d.Get(flowTypeVar).(string)]), + TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerTypeVar).(string)]), + ActionIds: actions, + }) + if err != nil { + return diag.Errorf("failed to update trigger actions: %v", err) + } + + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + orgID := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + + actionsSet := d.Get(actionsVar).(*schema.Set) + actions := make([]string, 0) + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + flowType := d.Get(flowTypeVar).(string) + triggerType := d.Get(triggerTypeVar).(string) + _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ + FlowType: action.FlowType(action.FlowType_value[flowType]), + TriggerType: action.TriggerType(action.TriggerType_value[triggerType]), + ActionIds: actions, + }) + d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + orgID := d.Get(orgIDVar).(string) + flowType := d.Get(flowTypeVar).(string) + triggerType := d.Get(triggerTypeVar).(string) + d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) + return nil +} + +func getTriggerActionsID(orgID, flowType string, triggerType string) string { + return orgID + "_" + flowType + "_" + triggerType +} diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go new file mode 100644 index 00000000..e227dbf1 --- /dev/null +++ b/zitadel/v2/trigger_actions/resource.go @@ -0,0 +1,55 @@ +package trigger_actions + +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing triggers, when actions get started", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + flowTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Type of the flow to which the action triggers belong", + ForceNew: true, + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(flowTypeVar, value, action.FlowType_value) + }, + }, + triggerTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "Trigger type on when the actions get triggered", + ForceNew: true, + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(triggerTypeVar, value, action.TriggerType_value) + }, + }, + actionsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "IDs of the triggered actions", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/user.go b/zitadel/v2/user.go deleted file mode 100644 index 57c9aa7a..00000000 --- a/zitadel/v2/user.go +++ /dev/null @@ -1,595 +0,0 @@ -package v2 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" -) - -const ( - orgIDVar = "org_id" - userStateVar = "state" - userNameVar = "user_name" - loginNamesVar = "login_names" - preferredLoginNameVar = "preferred_login_name" - - firstNameVar = "first_name" - lastNameVar = "last_name" - nickNameVar = "nick_name" - displayNameVar = "display_name" - preferredLanguageVar = "preferred_language" - genderVar = "gender" - - isEmailVerifiedVar = "is_email_verified" - emailVar = "email" - - isPhoneVerifiedVar = "is_phone_verified" - phoneVar = "phone" - - machineNameVar = "name" - descriptionVar = "description" - - initialPasswordVar = "initial_password" - - defaultGenderString = "GENDER_UNSPECIFIED" - defaultPreferredLanguage = "und" -) - -func defaultDisplayName(firstName, lastName string) string { - return firstName + " " + lastName -} - -func GetHumanUser() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", - Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - userStateVar: { - Type: schema.TypeString, - Computed: true, - Description: "State of the user", - }, - userNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Username", - }, - loginNamesVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "Loginnames", - ForceNew: true, - }, - preferredLoginNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Preferred login name", - ForceNew: true, - }, - - firstNameVar: { - Type: schema.TypeString, - Required: true, - Description: "First name of the user", - }, - lastNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Last name of the user", - }, - nickNameVar: { - Type: schema.TypeString, - Optional: true, - Description: "Nick name of the user", - }, - displayNameVar: { - Type: schema.TypeString, - Optional: true, - Description: "Display name of the user", - Computed: true, - }, - preferredLanguageVar: { - Type: schema.TypeString, - Optional: true, - Description: "Preferred language of the user", - Computed: true, - }, - genderVar: { - Type: schema.TypeString, - Optional: true, - Description: "Gender of the user", - Computed: true, - }, - emailVar: { - Type: schema.TypeString, - Optional: true, - Description: "Email of the user", - }, - isEmailVerifiedVar: { - Type: schema.TypeBool, - Optional: true, - Description: "Is the email verified of the user, can only be true if password of the user is set", - }, - phoneVar: { - Type: schema.TypeString, - Optional: true, - Description: "Phone of the user", - }, - isPhoneVerifiedVar: { - Type: schema.TypeBool, - Optional: true, - Description: "Is the phone verified of the user", - }, - initialPasswordVar: { - Type: schema.TypeString, - Optional: true, - Description: "Initially set password for the user, not changeable after creation", - Sensitive: true, - }, - }, - ReadContext: readHumanUser, - CreateContext: createHumanUser, - DeleteContext: deleteUser, - UpdateContext: updateHumanUser, - CustomizeDiff: customdiff.All( - customdiff.IfValue(displayNameVar, func(ctx context.Context, value, meta interface{}) bool { - if value == "" { - return true - } - return false - }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { - return diff.SetNew(displayNameVar, defaultDisplayName(diff.Get(firstNameVar).(string), diff.Get(lastNameVar).(string))) - }), - customdiff.IfValue(genderVar, func(ctx context.Context, value, meta interface{}) bool { - if value == "" { - return true - } - return false - }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { - return diff.SetNew(genderVar, defaultGenderString) - }), - customdiff.IfValue(preferredLanguageVar, func(ctx context.Context, value, meta interface{}) bool { - if value == "" { - return true - } - return false - }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { - return diff.SetNew(preferredLanguageVar, defaultPreferredLanguage) - }), - ), - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func GetMachineUser() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", - Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - userStateVar: { - Type: schema.TypeString, - Computed: true, - Description: "State of the user", - }, - userNameVar: { - Type: schema.TypeString, - Required: true, - Description: "Username", - }, - loginNamesVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "Loginnames", - }, - preferredLoginNameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Preferred login name", - }, - - machineNameVar: { - Type: schema.TypeString, - Optional: true, - Description: "Name of the machine user", - }, - descriptionVar: { - Type: schema.TypeString, - Optional: true, - Description: "Description of the user", - }, - }, - ReadContext: readMachineUser, - CreateContext: createMachineUser, - DeleteContext: deleteUser, - UpdateContext: updateMachineUser, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveUser(ctx, &management2.RemoveUserRequest{ - Id: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete user: %v", err) - } - return nil -} - -func createHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - firstName := d.Get(firstNameVar).(string) - lastName := d.Get(lastNameVar).(string) - addUser := &management2.AddHumanUserRequest{ - UserName: d.Get(userNameVar).(string), - Profile: &management2.AddHumanUserRequest_Profile{ - FirstName: firstName, - LastName: lastName, - }, - } - - nickname := d.Get(nickNameVar).(string) - if nickname != "" { - addUser.Profile.NickName = nickname - } - - displayname := d.Get(displayNameVar).(string) - if displayname != "" { - addUser.Profile.DisplayName = displayname - } else { - if err := d.Set(displayNameVar, defaultDisplayName(firstName, lastName)); err != nil { - return diag.Errorf("failed to set default display name for human user: %v", err) - } - } - - prefLang := d.Get(preferredLanguageVar).(string) - if prefLang != "" { - addUser.Profile.PreferredLanguage = prefLang - } else { - if err := d.Set(preferredLanguageVar, defaultPreferredLanguage); err != nil { - return diag.Errorf("failed to set default preferred language for human user: %v", err) - } - } - - gender := d.Get(genderVar).(string) - if gender != "" { - addUser.Profile.Gender = user.Gender(user.Gender_value[gender]) - } else { - if err := d.Set(genderVar, defaultGenderString); err != nil { - return diag.Errorf("failed to set default gender for human user: %v", err) - } - } - - pwd := d.Get(initialPasswordVar).(string) - if pwd != "" { - addUser.InitialPassword = pwd - } - - email := d.Get(emailVar).(string) - if email != "" { - isVerified := d.Get(isEmailVerifiedVar) - addUser.Email = &management2.AddHumanUserRequest_Email{ - Email: email, - IsEmailVerified: false, - } - if isVerified != nil { - addUser.Email.IsEmailVerified = isVerified.(bool) - } - } - - phone := d.Get(phoneVar).(string) - if phone != "" { - isVerified := d.Get(isPhoneVerifiedVar) - addUser.Phone = &management2.AddHumanUserRequest_Phone{ - Phone: phone, - IsPhoneVerified: false, - } - if isVerified != nil { - addUser.Phone.IsPhoneVerified = isVerified.(bool) - } - } - - respUser, err := client.AddHumanUser(ctx, addUser) - if err != nil { - return diag.Errorf("failed to create human user: %v", err) - } - d.SetId(respUser.UserId) - - return nil -} - -func createMachineUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - respUser, err := client.AddMachineUser(ctx, &management2.AddMachineUserRequest{ - UserName: d.Get(userNameVar).(string), - Name: d.Get(machineNameVar).(string), - Description: d.Get(descriptionVar).(string), - }) - if err != nil { - return diag.Errorf("failed to create machine user: %v", err) - } - d.SetId(respUser.UserId) - return nil -} - -func updateHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - currentUser, err := client.GetUserByID(ctx, &management2.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - return diag.FromErr(err) - } - - username := d.Get(userNameVar).(string) - if currentUser.GetUser().GetUserName() != username { - _, err = client.UpdateUserName(ctx, &management2.UpdateUserNameRequest{ - UserId: d.Id(), - UserName: username, - }) - if err != nil { - return diag.Errorf("failed to update username: %v", err) - } - } - - nickname := d.Get(nickNameVar) - displayname := d.Get(displayNameVar) - prefLang := d.Get(preferredLanguageVar) - gender := d.Get(genderVar) - email := d.Get(emailVar) - emailVerfied := d.Get(isEmailVerifiedVar) - phone := d.Get(phoneVar) - phoneVerified := d.Get(isPhoneVerifiedVar) - - currentHuman := currentUser.GetUser().GetHuman() - if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || - currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || - (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || - (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || - (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || - (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { - - _, err := client.UpdateHumanProfile(ctx, &management2.UpdateHumanProfileRequest{ - UserId: d.Id(), - FirstName: d.Get(firstNameVar).(string), - LastName: d.Get(lastNameVar).(string), - NickName: d.Get(nickNameVar).(string), - DisplayName: d.Get(displayNameVar).(string), - PreferredLanguage: d.Get(preferredLanguageVar).(string), - Gender: user.Gender(user.Gender_value[gender.(string)]), - }) - if err != nil { - return diag.Errorf("failed to update human profile: %v", err) - } - } - - if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { - _, err = client.UpdateHumanEmail(ctx, &management2.UpdateHumanEmailRequest{ - UserId: d.Id(), - Email: email.(string), - IsEmailVerified: emailVerfied.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human email: %v", err) - } - } - - if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { - _, err = client.UpdateHumanPhone(ctx, &management2.UpdateHumanPhoneRequest{ - UserId: d.Id(), - Phone: phone.(string), - IsPhoneVerified: phoneVerified.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human phone: %v", err) - } - } - return nil -} - -func updateMachineUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - currentUser, err := client.GetUserByID(ctx, &management2.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - return diag.FromErr(err) - } - - username := d.Get(userNameVar).(string) - if currentUser.GetUser().GetUserName() != username { - _, err = client.UpdateUserName(ctx, &management2.UpdateUserNameRequest{ - UserId: d.Id(), - UserName: username, - }) - if err != nil { - return diag.Errorf("failed to update username: %v", err) - } - } - - currentMachine := currentUser.GetUser().GetMachine() - if currentMachine.GetName() != d.Get(machineNameVar).(string) || currentMachine.GetDescription() != d.Get(descriptionVar).(string) { - _, err := client.UpdateMachine(ctx, &management2.UpdateMachineRequest{ - UserId: d.Id(), - Name: d.Get(machineNameVar).(string), - Description: d.Get(descriptionVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update machine user: %v", err) - } - } - - return nil -} - -func readHumanUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - respUser, err := client.GetUserByID(ctx, &management2.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get list of users: %v", err) - } - - user := respUser.GetUser() - set := map[string]interface{}{ - orgIDVar: user.GetDetails().GetResourceOwner(), - userStateVar: user.GetState().String(), - userNameVar: user.GetUserName(), - loginNamesVar: user.GetLoginNames(), - preferredLoginNameVar: user.GetPreferredLoginName(), - } - - if human := user.GetHuman(); human != nil { - if profile := human.GetProfile(); profile != nil { - set[firstNameVar] = profile.GetFirstName() - set[lastNameVar] = profile.GetLastName() - set[displayNameVar] = profile.GetDisplayName() - set[nickNameVar] = profile.GetNickName() - set[preferredLanguageVar] = profile.GetPreferredLanguage() - if gender := profile.GetGender().String(); gender != "" { - set[genderVar] = gender - } - } - if email := human.GetEmail(); email != nil { - set[emailVar] = email.GetEmail() - set[isEmailVerifiedVar] = email.GetIsEmailVerified() - } - if phone := human.GetPhone(); phone != nil { - set[phoneVar] = phone.GetPhone() - set[isPhoneVerifiedVar] = phone.GetIsPhoneVerified() - } - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of user: %v", k, err) - } - } - d.SetId(user.GetId()) - return nil -} - -func readMachineUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - - clientinfo, ok := m.(*ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := getManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - respUser, err := client.GetUserByID(ctx, &management2.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - d.SetId("") - return nil - //return diag.Errorf("failed to get list of users: %v", err) - } - - user := respUser.GetUser() - set := map[string]interface{}{ - orgIDVar: user.GetDetails().GetResourceOwner(), - userStateVar: user.GetState().String(), - userNameVar: user.GetUserName(), - loginNamesVar: user.GetLoginNames(), - preferredLoginNameVar: user.GetPreferredLoginName(), - } - if machine := user.GetMachine(); machine != nil { - set[machineNameVar] = machine.GetName() - set[descriptionVar] = machine.GetDescription() - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of user: %v", k, err) - } - } - d.SetId(user.GetId()) - return nil -} diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go new file mode 100644 index 00000000..cf665e40 --- /dev/null +++ b/zitadel/v2/user_grant/const.go @@ -0,0 +1,9 @@ +package user_grant + +const ( + userGrantProjectIDVar = "project_id" + userGrantProjectGrantIDVar = "project_grant_id" + userGrantUserIDVar = "user_id" + userGrantRoleKeysVar = "role_keys" + userGrantOrgIDVar = "org_id" +) diff --git a/zitadel/v2/user_grant.go b/zitadel/v2/user_grant/funcs.go similarity index 54% rename from zitadel/v2/user_grant.go rename to zitadel/v2/user_grant/funcs.go index b6ec4d6a..11ea7af9 100644 --- a/zitadel/v2/user_grant.go +++ b/zitadel/v2/user_grant/funcs.go @@ -1,4 +1,4 @@ -package v2 +package user_grant import ( "context" @@ -6,77 +6,26 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" -) -const ( - userGrantProjectIDVar = "project_id" - userGrantProjectGrantIDVar = "project_grant_id" - userGrantUserIDVar = "user_id" - userGrantRoleKeysVar = "role_keys" - userGrantOrgIDVar = "org_id" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) -func GetUserGrant() *schema.Resource { - return &schema.Resource{ - Description: "Resource representing the authorization given to a user directly, including the given roles.", - Schema: map[string]*schema.Schema{ - userGrantProjectIDVar: { - Type: schema.TypeString, - Optional: true, - Description: "ID of the project", - ForceNew: true, - }, - userGrantProjectGrantIDVar: { - Type: schema.TypeString, - Optional: true, - Description: "ID of the granted project", - ForceNew: true, - }, - userGrantUserIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the user", - ForceNew: true, - }, - userGrantRoleKeysVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - Description: "List of roles granted", - }, - userGrantOrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, - }, - DeleteContext: deleteUserGrant, - CreateContext: createUserGrant, - UpdateContext: updateUserGrant, - ReadContext: readUserGrant, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, - } -} - -func deleteUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started delete") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - _, err = client.RemoveUserGrant(ctx, &management2.RemoveUserGrantRequest{ + _, err = client.RemoveUserGrant(ctx, &management.RemoveUserGrantRequest{ GrantId: d.Id(), UserId: d.Get(userGrantUserIDVar).(string), }) @@ -86,15 +35,15 @@ func deleteUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return nil } -func updateUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -103,7 +52,7 @@ func updateUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) for _, role := range d.Get(userGrantRoleKeysVar).(*schema.Set).List() { roles = append(roles, role.(string)) } - _, err = client.UpdateUserGrant(ctx, &management2.UpdateUserGrantRequest{ + _, err = client.UpdateUserGrant(ctx, &management.UpdateUserGrantRequest{ GrantId: d.Id(), UserId: d.Get(userGrantUserIDVar).(string), RoleKeys: roles, @@ -114,15 +63,15 @@ func updateUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return nil } -func createUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -132,7 +81,7 @@ func createUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) roles = append(roles, role.(string)) } - resp, err := client.AddUserGrant(ctx, &management2.AddUserGrantRequest{ + resp, err := client.AddUserGrant(ctx, &management.AddUserGrantRequest{ UserId: d.Get(userGrantUserIDVar).(string), ProjectGrantId: d.Get(userGrantProjectGrantIDVar).(string), ProjectId: d.Get(userGrantProjectIDVar).(string), @@ -145,15 +94,15 @@ func createUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) return nil } -func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*ClientInfo) + clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := getManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -183,7 +132,7 @@ func readUserGrant(ctx context.Context, d *schema.ResourceData, m interface{}) d }}, ) } - grants, err := client.ListUserGrants(ctx, &management2.ListUserGrantRequest{ + grants, err := client.ListUserGrants(ctx, &management.ListUserGrantRequest{ Queries: queries, }) if err != nil { diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go new file mode 100644 index 00000000..3124e9aa --- /dev/null +++ b/zitadel/v2/user_grant/resource.go @@ -0,0 +1,50 @@ +package user_grant + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the authorization given to a user directly, including the given roles.", + Schema: map[string]*schema.Schema{ + userGrantProjectIDVar: { + Type: schema.TypeString, + Optional: true, + Description: "ID of the project", + ForceNew: true, + }, + userGrantProjectGrantIDVar: { + Type: schema.TypeString, + Optional: true, + Description: "ID of the granted project", + ForceNew: true, + }, + userGrantUserIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + userGrantRoleKeysVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "List of roles granted", + }, + userGrantOrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization which owns the resource", + ForceNew: true, + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From dba94e895e6facd6976ebc96f5767e5447713eb4 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 2 Sep 2022 09:30:27 +0200 Subject: [PATCH 013/260] fix: correction of boolean attributes in examples for the documentation --- docs/index.md | 2 +- docs/resources/action.md | 2 +- docs/resources/application_oidc.md | 8 ++++---- docs/resources/domain_policy.md | 6 +++--- docs/resources/human_user.md | 4 ++-- docs/resources/label_policy.md | 6 +++--- docs/resources/login_policy.md | 10 +++++----- docs/resources/password_complexity_policy.md | 8 ++++---- docs/resources/project.md | 6 +++--- docs/resources/user_grant.md | 8 ++++---- examples/provider/resources/action.tf | 2 +- examples/provider/resources/application_oidc.tf | 8 ++++---- examples/provider/resources/domain_policy.tf | 6 +++--- examples/provider/resources/granted_human_user.tf | 4 ++-- examples/provider/resources/human_user.tf | 4 ++-- examples/provider/resources/label_policy.tf | 6 +++--- examples/provider/resources/login_policy.tf | 10 +++++----- .../provider/resources/password_complexity_policy.tf | 8 ++++---- examples/provider/resources/project.tf | 6 +++--- examples/provider/resources/user_grant.tf | 9 ++++----- 20 files changed, 61 insertions(+), 62 deletions(-) diff --git a/docs/index.md b/docs/index.md index e506d3ad..6300fe95 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,7 +31,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.8" + version = "1.0.0-alpha.7" } } } diff --git a/docs/resources/action.md b/docs/resources/action.md index 2ab568b8..d5ca878d 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -19,7 +19,7 @@ resource zitadel_action action { name = "actionname" script = "testscript" timeout = "10s" - allowed_to_fail = "true" + allowed_to_fail = true } ``` diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index b94ec968..711b239f 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -27,11 +27,11 @@ resource zitadel_application_oidc application_oidc { auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" version = "OIDC_VERSION_1_0" clock_skew = "0s" - dev_mode = "true" + dev_mode = true access_token_type = "OIDC_TOKEN_TYPE_BEARER" - access_token_role_assertion = "false" - id_token_role_assertion = "false" - id_token_userinfo_assertion = "false" + access_token_role_assertion = false + id_token_role_assertion = false + id_token_userinfo_assertion = false additional_origins = [] } ``` diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index c2cc389e..8db6323f 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -16,9 +16,9 @@ resource zitadel_domain_policy domain_policy { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_login_must_be_domain = "false" - validate_org_domains = "false" - smtp_sender_address_matches_instance_domain = "false" + user_login_must_be_domain = false + validate_org_domains = false + smtp_sender_address_matches_instance_domain = false } ``` diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 1b4abebe..bde57b7e 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -26,9 +26,9 @@ resource zitadel_human_user human_user { preferred_language = "de" gender = "GENDER_MALE" phone = "+41799999999" - is_phone_verified = "true" + is_phone_verified = true email = "test@zitadel.com" - is_email_verified = "true" + is_email_verified = true initial_password = "Password1!" } ``` diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index a389b65c..5c9368ff 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -17,7 +17,7 @@ resource zitadel_label_policy label_policy { org_id = zitadel_org.org.id primary_color = "#5469d4" - hide_login_name_suffix = "true" + hide_login_name_suffix = true warn_color = "#cd3d56" background_color = "#fafafa" font_color = "#000000" @@ -25,8 +25,8 @@ resource zitadel_label_policy label_policy { background_color_dark = "#111827" warn_color_dark = "#ff3b5b" font_color_dark = "#ffffff" - disable_watermark = "false" - set_active = "true" + disable_watermark = false + set_active = true } ``` diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index be271979..7f0b798a 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -16,10 +16,10 @@ resource zitadel_login_policy login_policy { depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] org_id = zitadel_org.org.id - user_login = "true" - allow_register = "true" - allow_external_idp = "true" - force_mfa = "false" + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" @@ -27,7 +27,7 @@ resource zitadel_login_policy login_policy { multi_factor_check_lifetime = "720h0m0s" mfa_init_skip_lifetime = "24h0m0s" second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = "true" + ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index 0afb943d..51ada4ce 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -17,10 +17,10 @@ resource zitadel_password_complexity_policy password_complexity_policy { org_id = zitadel_org.org.id min_length = "8" - has_uppercase = "true" - has_lowercase = "true" - has_number = "true" - has_symbol = "true" + has_uppercase = true + has_lowercase = true + has_number = true + has_symbol = true } ``` diff --git a/docs/resources/project.md b/docs/resources/project.md index 73e4b3f3..ccc2028e 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -17,9 +17,9 @@ resource zitadel_project project { name = "projectname" org_id = zitadel_org.org.id - project_role_assertion = "true" - project_role_check = "true" - has_project_check = "true" + project_role_assertion = true + project_role_check = true + has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } ``` diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 00019b89..92a603da 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -12,13 +12,13 @@ Resource representing the authorization given to a user directly, including the ## Example Usage ```terraform -resource zitadel_user_grant user_grant{ +resource zitadel_user_grant user_grant { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - role_keys = ["key"] - user_id = zitadel_human_user.granted_human_user.id + org_id = zitadel_org.org.id + role_keys = ["key"] + user_id = zitadel_human_user.granted_human_user.id } ``` diff --git a/examples/provider/resources/action.tf b/examples/provider/resources/action.tf index d3e01fd4..2636e24b 100644 --- a/examples/provider/resources/action.tf +++ b/examples/provider/resources/action.tf @@ -6,5 +6,5 @@ resource zitadel_action action { name = "actionname" script = "testscript" timeout = "10s" - allowed_to_fail = "true" + allowed_to_fail = true } \ No newline at end of file diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index 33bcbe58..12cd663e 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -14,10 +14,10 @@ resource zitadel_application_oidc application_oidc { auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" version = "OIDC_VERSION_1_0" clock_skew = "0s" - dev_mode = "true" + dev_mode = true access_token_type = "OIDC_TOKEN_TYPE_BEARER" - access_token_role_assertion = "false" - id_token_role_assertion = "false" - id_token_userinfo_assertion = "false" + access_token_role_assertion = false + id_token_role_assertion = false + id_token_userinfo_assertion = false additional_origins = [] } \ No newline at end of file diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index 56df20d9..d74a7929 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -3,7 +3,7 @@ resource zitadel_domain_policy domain_policy { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_login_must_be_domain = "false" - validate_org_domains = "false" - smtp_sender_address_matches_instance_domain = "false" + user_login_must_be_domain = false + validate_org_domains = false + smtp_sender_address_matches_instance_domain = false } \ No newline at end of file diff --git a/examples/provider/resources/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf index 1496bd6a..5ade8858 100644 --- a/examples/provider/resources/granted_human_user.tf +++ b/examples/provider/resources/granted_human_user.tf @@ -11,7 +11,7 @@ resource zitadel_human_user granted_human_user { preferred_language = "de" gender = "GENDER_MALE" phone = "+41799999999" - is_phone_verified = "true" + is_phone_verified = true email = "test@zitadel.com" - is_email_verified = "false" + is_email_verified = false } diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 048d5864..29c3e9c0 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -10,8 +10,8 @@ resource zitadel_human_user human_user { preferred_language = "de" gender = "GENDER_MALE" phone = "+41799999999" - is_phone_verified = "true" + is_phone_verified = true email = "test@zitadel.com" - is_email_verified = "true" + is_email_verified = true initial_password = "Password1!" } diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index 93d7c598..a14facc3 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -3,7 +3,7 @@ resource zitadel_label_policy label_policy { org_id = zitadel_org.org.id primary_color = "#5469d4" - hide_login_name_suffix = "true" + hide_login_name_suffix = true warn_color = "#cd3d56" background_color = "#fafafa" font_color = "#000000" @@ -11,6 +11,6 @@ resource zitadel_label_policy label_policy { background_color_dark = "#111827" warn_color_dark = "#ff3b5b" font_color_dark = "#ffffff" - disable_watermark = "false" - set_active = "true" + disable_watermark = false + set_active = true } \ No newline at end of file diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index 5e30cfff..dfbb0f0a 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -2,10 +2,10 @@ resource zitadel_login_policy login_policy { depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] org_id = zitadel_org.org.id - user_login = "true" - allow_register = "true" - allow_external_idp = "true" - force_mfa = "false" + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" @@ -13,7 +13,7 @@ resource zitadel_login_policy login_policy { multi_factor_check_lifetime = "720h0m0s" mfa_init_skip_lifetime = "24h0m0s" second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = "true" + ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] diff --git a/examples/provider/resources/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf index b9d273b6..a2665964 100644 --- a/examples/provider/resources/password_complexity_policy.tf +++ b/examples/provider/resources/password_complexity_policy.tf @@ -4,8 +4,8 @@ resource zitadel_password_complexity_policy password_complexity_policy { org_id = zitadel_org.org.id min_length = "8" - has_uppercase = "true" - has_lowercase = "true" - has_number = "true" - has_symbol = "true" + has_uppercase = true + has_lowercase = true + has_number = true + has_symbol = true } \ No newline at end of file diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index e433930d..2124a299 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -4,8 +4,8 @@ resource zitadel_project project { name = "projectname" org_id = zitadel_org.org.id - project_role_assertion = "true" - project_role_check = "true" - has_project_check = "true" + project_role_assertion = true + project_role_check = true + has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } \ No newline at end of file diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 7479cf5f..ed5a21f8 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,9 +1,8 @@ - -resource zitadel_user_grant user_grant{ +resource zitadel_user_grant user_grant { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - role_keys = ["key"] - user_id = zitadel_human_user.granted_human_user.id + org_id = zitadel_org.org.id + role_keys = ["key"] + user_id = zitadel_human_user.granted_human_user.id } \ No newline at end of file From baea38b6fa24ed58581e2bd736d2103c50d88dc8 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 21 Sep 2022 14:36:49 +0200 Subject: [PATCH 014/260] fix: correction for machine user and org member --- zitadel/v2/machine_user/resource.go | 2 +- zitadel/v2/org_member/funcs.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 03a6ffcb..1ffd3ab9 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -44,7 +44,7 @@ func GetResource() *schema.Resource { nameVar: { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Name of the machine user", }, descriptionVar: { diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index 943c52d8..4803a0f2 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -48,9 +48,14 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } + roles := make([]string, 0) + for _, role := range d.Get(rolesVar).(*schema.Set).List() { + roles = append(roles, role.(string)) + } + _, err = client.UpdateOrgMember(ctx, &management.UpdateOrgMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: d.Get(rolesVar).([]string), + Roles: roles, }) if err != nil { return diag.Errorf("failed to update orgmember: %v", err) From 3212931268ac68f961395292a2dadd850917427a Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 2 Nov 2022 19:25:35 +0100 Subject: [PATCH 015/260] fix: default values for applications --- zitadel/v2/application_api/resource.go | 3 ++- zitadel/v2/application_oidc/resource.go | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index 909d1adb..91b5159d 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -32,11 +32,12 @@ func GetResource() *schema.Resource { }, authMethodTypeVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Auth method type", ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.APIAuthMethodType_value) }, + Default: app.APIAuthMethodType_name[0], }, clientID: { Type: schema.TypeString, diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index e6ca4825..d5968630 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -64,19 +64,21 @@ func GetResource() *schema.Resource { }, appTypeVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "App type", ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(appTypeVar, value, app.OIDCAppType_value) }, + Default: app.OIDCAppType_name[0], }, authMethodTypeVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Auth method type", ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.OIDCAuthMethodType_value) }, + Default: app.OIDCAuthMethodType_name[0], }, postLogoutRedirectURIsVar: { Type: schema.TypeList, @@ -103,6 +105,7 @@ func GetResource() *schema.Resource { ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(accessTokenTypeVar, value, app.OIDCTokenType_value) }, + Default: app.OIDCTokenType_name[0], }, accessTokenRoleAssertionVar: { Type: schema.TypeBool, From ddda91a2df49aab8292cc77094178d1cd2fa6258 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 2 Nov 2022 20:09:29 +0100 Subject: [PATCH 016/260] fix: add smtp --- zitadel/provider.go | 2 + zitadel/v2/smtp_config/const.go | 10 +++ zitadel/v2/smtp_config/funcs.go | 135 +++++++++++++++++++++++++++++ zitadel/v2/smtp_config/resource.go | 49 +++++++++++ 4 files changed, 196 insertions(+) create mode 100644 zitadel/v2/smtp_config/const.go create mode 100644 zitadel/v2/smtp_config/funcs.go create mode 100644 zitadel/v2/smtp_config/resource.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 858c3097..5cbd6905 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -31,6 +31,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" ) @@ -99,6 +100,7 @@ func Provider() *schema.Provider { "zitadel_machine_key": machine_key.GetResource(), "zitadel_org_jwt_idp": idp_jwt.GetResource(), "zitadel_org_oidc_idp": idp_oidc.GetResource(), + "zitadel_smtp_config": smtp_config.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/smtp_config/const.go b/zitadel/v2/smtp_config/const.go new file mode 100644 index 00000000..289d1a6a --- /dev/null +++ b/zitadel/v2/smtp_config/const.go @@ -0,0 +1,10 @@ +package smtp_config + +const ( + senderAddressVar = "sender_address" + senderNameVar = "sender_name" + tlsVar = "tls" + hostVar = "host" + userVar = "user" + passwordVar = "password" +) diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go new file mode 100644 index 00000000..08aa6d65 --- /dev/null +++ b/zitadel/v2/smtp_config/funcs.go @@ -0,0 +1,135 @@ +package smtp_config + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveSMTPConfig(ctx, &admin.RemoveSMTPConfigRequest{}) + if err != nil { + return diag.Errorf("failed to delete smtp config: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.AddSMTPConfig(ctx, &admin.AddSMTPConfigRequest{ + SenderAddress: d.Get(senderAddressVar).(string), + SenderName: d.Get(senderNameVar).(string), + Tls: d.Get(tlsVar).(bool), + Host: d.Get(hostVar).(string), + User: d.Get(userVar).(string), + Password: d.Get(passwordVar).(string), + }) + if err != nil { + return diag.Errorf("failed to create smtp config: %v", err) + } + d.SetId(resp.Details.ResourceOwner) + + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + smtp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) + if err != nil { + return diag.FromErr(err) + } + + senderAddress := d.Get(senderAddressVar).(string) + senderName := d.Get(senderNameVar).(string) + tls := d.Get(tlsVar).(bool) + host := d.Get(hostVar).(string) + user := d.Get(userVar).(string) + if smtp.SmtpConfig.SenderName != senderName || + smtp.SmtpConfig.SenderAddress != senderAddress || + smtp.SmtpConfig.Tls != tls || + smtp.SmtpConfig.Host != host || + smtp.SmtpConfig.User != user { + + _, err = client.UpdateSMTPConfig(ctx, &admin.UpdateSMTPConfigRequest{ + SenderAddress: senderAddress, + SenderName: senderName, + Tls: tls, + Host: host, + User: user, + }) + if err != nil { + return diag.Errorf("failed to update smtp config: %v", err) + } + } else { + _, err = client.UpdateSMTPConfigPassword(ctx, &admin.UpdateSMTPConfigPasswordRequest{ + Password: d.Get(passwordVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update smtp config: %v", err) + } + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("error while reading smtp config: %v", err) + } + d.SetId(resp.SmtpConfig.Details.ResourceOwner) + return nil +} diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go new file mode 100644 index 00000000..e8318121 --- /dev/null +++ b/zitadel/v2/smtp_config/resource.go @@ -0,0 +1,49 @@ +package smtp_config + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the SMTP configuration of an instance.", + Schema: map[string]*schema.Schema{ + senderAddressVar: { + Type: schema.TypeString, + Required: true, + Description: "Address used to send emails.", + }, + senderNameVar: { + Type: schema.TypeString, + Required: true, + Description: "Sender name used to send emails.", + }, + tlsVar: { + Type: schema.TypeBool, + Required: true, + Description: "TLS used to communicate with your SMTP server.", + }, + hostVar: { + Type: schema.TypeString, + Required: true, + Description: "Host address to your SMTP server.", + }, + userVar: { + Type: schema.TypeString, + Required: true, + Description: "User used to communicate with your SMTP server.", + }, + passwordVar: { + Type: schema.TypeString, + Required: true, + Description: "Password used to communicate with your SMTP server.", + Sensitive: true, + }, + }, + CreateContext: create, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From 19f962865c9710299ebecb66f5aae230f0559aab Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 2 Nov 2022 20:17:56 +0100 Subject: [PATCH 017/260] docs: add smtp config to docs --- docs/resources/machine_user.md | 2 +- docs/resources/smtp_config.md | 39 ++++++++++++++++++++++ examples/provider/resources/smtp_config.tf | 8 +++++ templates/resources/smtp_config.md.tmpl | 16 +++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 docs/resources/smtp_config.md create mode 100644 examples/provider/resources/smtp_config.tf create mode 100644 templates/resources/smtp_config.md.tmpl diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index 3cd40d57..6527bd8a 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -27,13 +27,13 @@ resource zitadel_machine_user machine_user { ### Required +- `name` (String) Name of the machine user - `org_id` (String) ID of the organization - `user_name` (String) Username ### Optional - `description` (String) Description of the user -- `name` (String) Name of the machine user ### Read-Only diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md new file mode 100644 index 00000000..e0be00af --- /dev/null +++ b/docs/resources/smtp_config.md @@ -0,0 +1,39 @@ +--- +page_title: "zitadel_smtp_config Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the SMTP configuration of an instance. +--- + +# zitadel_smtp_config (Resource) + +Resource representing the SMTP configuration of an instance. + +## Example Usage + +```terraform +resource zitadel_smtp_config smtp { + sender_address = "address" + sender_name = "no-reply" + tls = true + host = "localhost:25" + user = "user" + password = "password" +} +``` + + +## Schema + +### Required + +- `host` (String) Host address to your SMTP server. +- `password` (String, Sensitive) Password used to communicate with your SMTP server. +- `sender_address` (String) Address used to send emails. +- `sender_name` (String) Sender name used to send emails. +- `tls` (Boolean) TLS used to communicate with your SMTP server. +- `user` (String) User used to communicate with your SMTP server. + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf new file mode 100644 index 00000000..6033928e --- /dev/null +++ b/examples/provider/resources/smtp_config.tf @@ -0,0 +1,8 @@ +resource zitadel_smtp_config smtp { + sender_address = "address" + sender_name = "no-reply" + tls = true + host = "localhost:25" + user = "user" + password = "password" +} \ No newline at end of file diff --git a/templates/resources/smtp_config.md.tmpl b/templates/resources/smtp_config.md.tmpl new file mode 100644 index 00000000..2e068e72 --- /dev/null +++ b/templates/resources/smtp_config.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/smtp_config.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file From 8e4a08150b134969059fc6cbc9d2bf0d67bb9b1c Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 2 Nov 2022 21:36:32 +0100 Subject: [PATCH 018/260] fix: add sms provider twilio --- docs/resources/machine_user.md | 2 +- docs/resources/sms_provider_twilio.md | 33 +++++ .../provider/resources/sms_provider_twilio.tf | 5 + .../resources/sms_provider_twilio.md.tmpl | 16 +++ zitadel/provider.go | 2 + zitadel/v2/sms_provider_twilio/const.go | 7 + zitadel/v2/sms_provider_twilio/funcs.go | 127 ++++++++++++++++++ zitadel/v2/sms_provider_twilio/resource.go | 34 +++++ 8 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 docs/resources/sms_provider_twilio.md create mode 100644 examples/provider/resources/sms_provider_twilio.tf create mode 100644 templates/resources/sms_provider_twilio.md.tmpl create mode 100644 zitadel/v2/sms_provider_twilio/const.go create mode 100644 zitadel/v2/sms_provider_twilio/funcs.go create mode 100644 zitadel/v2/sms_provider_twilio/resource.go diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index 3cd40d57..6527bd8a 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -27,13 +27,13 @@ resource zitadel_machine_user machine_user { ### Required +- `name` (String) Name of the machine user - `org_id` (String) ID of the organization - `user_name` (String) Username ### Optional - `description` (String) Description of the user -- `name` (String) Name of the machine user ### Read-Only diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md new file mode 100644 index 00000000..c702599d --- /dev/null +++ b/docs/resources/sms_provider_twilio.md @@ -0,0 +1,33 @@ +--- +page_title: "zitadel_sms_provider_twilio Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the SMTP configuration of an instance. +--- + +# zitadel_sms_provider_twilio (Resource) + +Resource representing the SMTP configuration of an instance. + +## Example Usage + +```terraform +resource zitadel_sms_provider_twilio twilio { + sid = "sid" + sender_number = "019920892" + token = "token" +} +``` + + +## Schema + +### Required + +- `sender_number` (String) Sender number which is used to send the SMS. +- `sid` (String) SID used to communicate with Twilio. +- `token` (String, Sensitive) Token used to communicate with Twilio. + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/resources/sms_provider_twilio.tf b/examples/provider/resources/sms_provider_twilio.tf new file mode 100644 index 00000000..0a4334fc --- /dev/null +++ b/examples/provider/resources/sms_provider_twilio.tf @@ -0,0 +1,5 @@ +resource zitadel_sms_provider_twilio twilio { + sid = "sid" + sender_number = "019920892" + token = "token" +} \ No newline at end of file diff --git a/templates/resources/sms_provider_twilio.md.tmpl b/templates/resources/sms_provider_twilio.md.tmpl new file mode 100644 index 00000000..a5f01360 --- /dev/null +++ b/templates/resources/sms_provider_twilio.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/sms_provider_twilio.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 858c3097..e286f2a9 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -31,6 +31,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" ) @@ -99,6 +100,7 @@ func Provider() *schema.Provider { "zitadel_machine_key": machine_key.GetResource(), "zitadel_org_jwt_idp": idp_jwt.GetResource(), "zitadel_org_oidc_idp": idp_oidc.GetResource(), + "zitadel_sms_provider_twilio": sms_provider_twilio.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/sms_provider_twilio/const.go b/zitadel/v2/sms_provider_twilio/const.go new file mode 100644 index 00000000..f17c362f --- /dev/null +++ b/zitadel/v2/sms_provider_twilio/const.go @@ -0,0 +1,7 @@ +package sms_provider_twilio + +const ( + sidVar = "sid" + tokenVar = "token" + senderNumberVar = "sender_number" +) diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go new file mode 100644 index 00000000..5af708e6 --- /dev/null +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -0,0 +1,127 @@ +package sms_provider_twilio + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveSMSProvider(ctx, &admin.RemoveSMSProviderRequest{Id: d.Id()}) + if err != nil { + return diag.Errorf("failed to delete sms provider twilio: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.AddSMSProviderTwilio(ctx, &admin.AddSMSProviderTwilioRequest{ + Sid: d.Get(sidVar).(string), + Token: d.Get(tokenVar).(string), + SenderNumber: d.Get(senderNumberVar).(string), + }) + if err != nil { + return diag.Errorf("failed to create sms provider twilio: %v", err) + } + d.SetId(resp.Id) + + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + sms, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{}) + if err != nil { + return diag.FromErr(err) + } + + sid := d.Get(sidVar).(string) + senderNumber := d.Get(senderNumberVar).(string) + twilio := sms.Config.GetTwilio() + if twilio.Sid != sid || + twilio.SenderNumber != senderNumber { + _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ + Id: d.Id(), + Sid: sid, + SenderNumber: senderNumber, + }) + if err != nil { + return diag.Errorf("failed to update sms provider twilio: %v", err) + } + } else { + _, err = client.UpdateSMSProviderTwilioToken(ctx, &admin.UpdateSMSProviderTwilioTokenRequest{ + Id: d.Id(), + Token: d.Get(tokenVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update sms provider twilio: %v", err) + } + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{ + Id: d.Id(), + }) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("error while reading sms provider twilio: %v", err) + } + d.SetId(resp.Config.Id) + return nil +} diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go new file mode 100644 index 00000000..39916fe6 --- /dev/null +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -0,0 +1,34 @@ +package sms_provider_twilio + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the SMTP configuration of an instance.", + Schema: map[string]*schema.Schema{ + sidVar: { + Type: schema.TypeString, + Required: true, + Description: "SID used to communicate with Twilio.", + }, + tokenVar: { + Type: schema.TypeString, + Required: true, + Description: "Token used to communicate with Twilio.", + Sensitive: true, + }, + senderNumberVar: { + Type: schema.TypeString, + Required: true, + Description: "Sender number which is used to send the SMS.", + }, + }, + CreateContext: create, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From c4f113d96142c38d8f9485c9274e3905bb0b2c5f Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 9 Nov 2022 20:23:24 +0100 Subject: [PATCH 019/260] fix: add default policies --- docs/resources/default_domain_policy.md | 33 +++ docs/resources/default_label_policy.md | 57 +++++ docs/resources/default_lockout_policy.md | 29 +++ docs/resources/default_login_policy.md | 58 +++++ .../default_password_complexity_policy.md | 37 ++++ docs/resources/default_privacy_policy.md | 33 +++ docs/resources/machine_user.md | 2 +- .../resources/default_domain_policy.tf | 6 + .../resources/default_label_policy.tf | 13 ++ .../resources/default_lockout_policy.tf | 4 + .../resources/default_login_policy.tf | 17 ++ .../default_password_complexity_policy.tf | 8 + .../resources/default_privacy_policy.tf | 6 + .../resources/default_domain_policy.md.tmpl | 16 ++ .../resources/default_label_policy.md.tmpl | 16 ++ .../resources/default_lockout_policy.md.tmpl | 16 ++ .../resources/default_login_policy.md.tmpl | 16 ++ ...default_password_complexity_policy.md.tmpl | 16 ++ .../resources/default_privacy_policy.md.tmpl | 16 ++ zitadel/provider.go | 64 +++--- zitadel/v2/default_domain_policy/const.go | 7 + zitadel/v2/default_domain_policy/funcs.go | 76 +++++++ zitadel/v2/default_domain_policy/resource.go | 33 +++ zitadel/v2/default_label_policy/const.go | 20 ++ zitadel/v2/default_label_policy/funcs.go | 106 +++++++++ zitadel/v2/default_label_policy/resource.go | 98 +++++++++ zitadel/v2/default_lockout_policy/const.go | 5 + zitadel/v2/default_lockout_policy/funcs.go | 73 +++++++ zitadel/v2/default_lockout_policy/resource.go | 23 ++ zitadel/v2/default_login_policy/const.go | 20 ++ zitadel/v2/default_login_policy/funcs.go | 206 ++++++++++++++++++ zitadel/v2/default_login_policy/resource.go | 107 +++++++++ .../const.go | 9 + .../funcs.go | 81 +++++++ .../resource.go | 43 ++++ zitadel/v2/default_privacy_policy/const.go | 7 + zitadel/v2/default_privacy_policy/funcs.go | 77 +++++++ zitadel/v2/default_privacy_policy/resource.go | 33 +++ 38 files changed, 1460 insertions(+), 27 deletions(-) create mode 100644 docs/resources/default_domain_policy.md create mode 100644 docs/resources/default_label_policy.md create mode 100644 docs/resources/default_lockout_policy.md create mode 100644 docs/resources/default_login_policy.md create mode 100644 docs/resources/default_password_complexity_policy.md create mode 100644 docs/resources/default_privacy_policy.md create mode 100644 examples/provider/resources/default_domain_policy.tf create mode 100644 examples/provider/resources/default_label_policy.tf create mode 100644 examples/provider/resources/default_lockout_policy.tf create mode 100644 examples/provider/resources/default_login_policy.tf create mode 100644 examples/provider/resources/default_password_complexity_policy.tf create mode 100644 examples/provider/resources/default_privacy_policy.tf create mode 100644 templates/resources/default_domain_policy.md.tmpl create mode 100644 templates/resources/default_label_policy.md.tmpl create mode 100644 templates/resources/default_lockout_policy.md.tmpl create mode 100644 templates/resources/default_login_policy.md.tmpl create mode 100644 templates/resources/default_password_complexity_policy.md.tmpl create mode 100644 templates/resources/default_privacy_policy.md.tmpl create mode 100644 zitadel/v2/default_domain_policy/const.go create mode 100644 zitadel/v2/default_domain_policy/funcs.go create mode 100644 zitadel/v2/default_domain_policy/resource.go create mode 100644 zitadel/v2/default_label_policy/const.go create mode 100644 zitadel/v2/default_label_policy/funcs.go create mode 100644 zitadel/v2/default_label_policy/resource.go create mode 100644 zitadel/v2/default_lockout_policy/const.go create mode 100644 zitadel/v2/default_lockout_policy/funcs.go create mode 100644 zitadel/v2/default_lockout_policy/resource.go create mode 100644 zitadel/v2/default_login_policy/const.go create mode 100644 zitadel/v2/default_login_policy/funcs.go create mode 100644 zitadel/v2/default_login_policy/resource.go create mode 100644 zitadel/v2/default_password_complexity_policy/const.go create mode 100644 zitadel/v2/default_password_complexity_policy/funcs.go create mode 100644 zitadel/v2/default_password_complexity_policy/resource.go create mode 100644 zitadel/v2/default_privacy_policy/const.go create mode 100644 zitadel/v2/default_privacy_policy/funcs.go create mode 100644 zitadel/v2/default_privacy_policy/resource.go diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md new file mode 100644 index 00000000..80da8ed6 --- /dev/null +++ b/docs/resources/default_domain_policy.md @@ -0,0 +1,33 @@ +--- +page_title: "zitadel_default_domain_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default domain policy. +--- + +# zitadel_default_domain_policy (Resource) + +Resource representing the default domain policy. + +## Example Usage + +```terraform +resource zitadel_default_domain_policy domain_policy { + user_login_must_be_domain = false + validate_org_domains = false + smtp_sender_address_matches_instance_domain = false +} +``` + + +## Schema + +### Required + +- `smtp_sender_address_matches_instance_domain` (Boolean) +- `user_login_must_be_domain` (Boolean) User login must be domain +- `validate_org_domains` (Boolean) Validate organization domains + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md new file mode 100644 index 00000000..a0db9aba --- /dev/null +++ b/docs/resources/default_label_policy.md @@ -0,0 +1,57 @@ +--- +page_title: "zitadel_default_label_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default label policy. +--- + +# zitadel_default_label_policy (Resource) + +Resource representing the default label policy. + +## Example Usage + +```terraform +resource zitadel_default_label_policy label_policy { + primary_color = "#5469d4" + hide_login_name_suffix = true + warn_color = "#cd3d56" + background_color = "#fafafa" + font_color = "#000000" + primary_color_dark = "#a5b4fc" + background_color_dark = "#111827" + warn_color_dark = "#ff3b5b" + font_color_dark = "#ffffff" + disable_watermark = false + set_active = true +} +``` + + +## Schema + +### Required + +- `background_color` (String) hex value for background color +- `background_color_dark` (String) hex value for background color dark theme +- `disable_watermark` (Boolean) disable watermark +- `font_color` (String) hex value for font color +- `font_color_dark` (String) hex value for font color dark theme +- `hide_login_name_suffix` (Boolean) hides the org suffix on the login form if the scope "urn:zitadel:iam:org:domain:primary:{domainname}" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes +- `primary_color` (String) hex value for primary color +- `primary_color_dark` (String) hex value for primary color dark theme +- `warn_color` (String) hex value for warn color +- `warn_color_dark` (String) hex value for warn color dark theme + +### Optional + +- `set_active` (Boolean) set the label policy active after creating/updating + +### Read-Only + +- `font_url` (String) +- `icon_url` (String) +- `icon_url_dark` (String) +- `id` (String) The ID of this resource. +- `logo_url` (String) +- `logo_url_dark` (String) \ No newline at end of file diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md new file mode 100644 index 00000000..9b6b3678 --- /dev/null +++ b/docs/resources/default_lockout_policy.md @@ -0,0 +1,29 @@ +--- +page_title: "zitadel_default_lockout_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default lockout policy. +--- + +# zitadel_default_lockout_policy (Resource) + +Resource representing the default lockout policy. + +## Example Usage + +```terraform +resource zitadel_default_lockout_policy lockout_policy { + max_password_attempts = "5" +} +``` + + +## Schema + +### Required + +- `max_password_attempts` (Number) Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset. + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md new file mode 100644 index 00000000..13635112 --- /dev/null +++ b/docs/resources/default_login_policy.md @@ -0,0 +1,58 @@ +--- +page_title: "zitadel_default_login_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default login policy. +--- + +# zitadel_default_login_policy (Resource) + +Resource representing the default login policy. + +## Example Usage + +```terraform +resource zitadel_default_login_policy login_policy { + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" + ignore_unknown_usernames = true + default_redirect_uri = "localhost:8080" + second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] + multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] +} +``` + + +## Schema + +### Required + +- `allow_external_idp` (Boolean) defines if a user is allowed to add a defined identity provider. E.g. Google auth +- `allow_register` (Boolean) defines if a person is allowed to register a user on this organisation +- `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) +- `external_login_check_lifetime` (String) +- `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in +- `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen +- `idps` (Set of String) allowed idps to login or register +- `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen +- `mfa_init_skip_lifetime` (String) +- `multi_factor_check_lifetime` (String) +- `multi_factors` (Set of String) allowed multi factors +- `password_check_lifetime` (String) +- `passwordless_type` (String) defines if passwordless is allowed for users +- `second_factor_check_lifetime` (String) +- `second_factors` (Set of String) allowed second factors +- `user_login` (Boolean) defines if a user is allowed to login with his username and password + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_password_complexity_policy.md b/docs/resources/default_password_complexity_policy.md new file mode 100644 index 00000000..4d87410b --- /dev/null +++ b/docs/resources/default_password_complexity_policy.md @@ -0,0 +1,37 @@ +--- +page_title: "zitadel_default_password_complexity_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default password complexity policy. +--- + +# zitadel_default_password_complexity_policy (Resource) + +Resource representing the default password complexity policy. + +## Example Usage + +```terraform +resource zitadel_default_password_complexity_policy password_complexity_policy { + min_length = "8" + has_uppercase = true + has_lowercase = true + has_number = true + has_symbol = true +} +``` + + +## Schema + +### Required + +- `has_lowercase` (Boolean) defines if the password MUST contain a lower case letter +- `has_number` (Boolean) defines if the password MUST contain a number +- `has_symbol` (Boolean) defines if the password MUST contain a symbol. E.g. "$" +- `has_uppercase` (Boolean) defines if the password MUST contain an upper case letter +- `min_length` (Number) Minimal length for the password + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md new file mode 100644 index 00000000..dc7e920a --- /dev/null +++ b/docs/resources/default_privacy_policy.md @@ -0,0 +1,33 @@ +--- +page_title: "zitadel_default_privacy_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default privacy policy. +--- + +# zitadel_default_privacy_policy (Resource) + +Resource representing the default privacy policy. + +## Example Usage + +```terraform +resource zitadel_default_privacy_policy privacy_policy { + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" +} +``` + + +## Schema + +### Required + +- `help_link` (String) +- `privacy_link` (String) +- `tos_link` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index 3cd40d57..6527bd8a 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -27,13 +27,13 @@ resource zitadel_machine_user machine_user { ### Required +- `name` (String) Name of the machine user - `org_id` (String) ID of the organization - `user_name` (String) Username ### Optional - `description` (String) Description of the user -- `name` (String) Name of the machine user ### Read-Only diff --git a/examples/provider/resources/default_domain_policy.tf b/examples/provider/resources/default_domain_policy.tf new file mode 100644 index 00000000..bb12d167 --- /dev/null +++ b/examples/provider/resources/default_domain_policy.tf @@ -0,0 +1,6 @@ + +resource zitadel_default_domain_policy domain_policy { + user_login_must_be_domain = false + validate_org_domains = false + smtp_sender_address_matches_instance_domain = false +} \ No newline at end of file diff --git a/examples/provider/resources/default_label_policy.tf b/examples/provider/resources/default_label_policy.tf new file mode 100644 index 00000000..241fff35 --- /dev/null +++ b/examples/provider/resources/default_label_policy.tf @@ -0,0 +1,13 @@ +resource zitadel_default_label_policy label_policy { + primary_color = "#5469d4" + hide_login_name_suffix = true + warn_color = "#cd3d56" + background_color = "#fafafa" + font_color = "#000000" + primary_color_dark = "#a5b4fc" + background_color_dark = "#111827" + warn_color_dark = "#ff3b5b" + font_color_dark = "#ffffff" + disable_watermark = false + set_active = true +} \ No newline at end of file diff --git a/examples/provider/resources/default_lockout_policy.tf b/examples/provider/resources/default_lockout_policy.tf new file mode 100644 index 00000000..5f7f0731 --- /dev/null +++ b/examples/provider/resources/default_lockout_policy.tf @@ -0,0 +1,4 @@ + +resource zitadel_default_lockout_policy lockout_policy { + max_password_attempts = "5" +} \ No newline at end of file diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf new file mode 100644 index 00000000..b3963547 --- /dev/null +++ b/examples/provider/resources/default_login_policy.tf @@ -0,0 +1,17 @@ +resource zitadel_default_login_policy login_policy { + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" + ignore_unknown_usernames = true + default_redirect_uri = "localhost:8080" + second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] + multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] +} \ No newline at end of file diff --git a/examples/provider/resources/default_password_complexity_policy.tf b/examples/provider/resources/default_password_complexity_policy.tf new file mode 100644 index 00000000..cfa844a9 --- /dev/null +++ b/examples/provider/resources/default_password_complexity_policy.tf @@ -0,0 +1,8 @@ + +resource zitadel_default_password_complexity_policy password_complexity_policy { + min_length = "8" + has_uppercase = true + has_lowercase = true + has_number = true + has_symbol = true +} \ No newline at end of file diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf new file mode 100644 index 00000000..0fc0e179 --- /dev/null +++ b/examples/provider/resources/default_privacy_policy.tf @@ -0,0 +1,6 @@ + +resource zitadel_default_privacy_policy privacy_policy { + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" +} \ No newline at end of file diff --git a/templates/resources/default_domain_policy.md.tmpl b/templates/resources/default_domain_policy.md.tmpl new file mode 100644 index 00000000..d8ad471c --- /dev/null +++ b/templates/resources/default_domain_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_domain_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_label_policy.md.tmpl b/templates/resources/default_label_policy.md.tmpl new file mode 100644 index 00000000..d832b0ec --- /dev/null +++ b/templates/resources/default_label_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_label_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_lockout_policy.md.tmpl b/templates/resources/default_lockout_policy.md.tmpl new file mode 100644 index 00000000..e04a9d63 --- /dev/null +++ b/templates/resources/default_lockout_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_lockout_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_login_policy.md.tmpl b/templates/resources/default_login_policy.md.tmpl new file mode 100644 index 00000000..70f68c57 --- /dev/null +++ b/templates/resources/default_login_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_login_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_password_complexity_policy.md.tmpl b/templates/resources/default_password_complexity_policy.md.tmpl new file mode 100644 index 00000000..94483dd0 --- /dev/null +++ b/templates/resources/default_password_complexity_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_password_complexity_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_privacy_policy.md.tmpl b/templates/resources/default_privacy_policy.md.tmpl new file mode 100644 index 00000000..1159b409 --- /dev/null +++ b/templates/resources/default_privacy_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_privacy_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 858c3097..0b7284f4 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -10,6 +10,12 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_privacy_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -73,32 +79,38 @@ func Provider() *schema.Provider { }, }, ResourcesMap: map[string]*schema.Resource{ - "zitadel_org": org.GetResource(), - "zitadel_human_user": human_user.GetResource(), - "zitadel_machine_user": machine_user.GetResource(), - "zitadel_project": project.GetResource(), - "zitadel_project_role": project_role.GetResource(), - "zitadel_domain": domain.GetResource(), - "zitadel_action": action.GetResource(), - "zitadel_application_oidc": application_oidc.GetResource(), - "zitadel_application_api": application_api.GetResource(), - "zitadel_application_key": app_key.GetResource(), - "zitadel_project_grant": project_grant.GetResource(), - "zitadel_user_grant": user_grant.GetResource(), - "zitadel_org_member": org_member.GetResource(), - "zitadel_project_member": project_member.GetResource(), - "zitadel_project_grant_member": project_grant_member.GetResource(), - "zitadel_domain_policy": domain_policy.GetResource(), - "zitadel_label_policy": label_policy.GetResource(), - "zitadel_lockout_policy": lockout_policy.GetResource(), - "zitadel_login_policy": login_policy.GetResource(), - "zitadel_password_complexity_policy": password_complexity_policy.GetResource(), - "zitadel_privacy_policy": privacy_policy.GetResource(), - "zitadel_trigger_actions": trigger_actions.GetResource(), - "zitadel_personal_access_token": pat.GetResource(), - "zitadel_machine_key": machine_key.GetResource(), - "zitadel_org_jwt_idp": idp_jwt.GetResource(), - "zitadel_org_oidc_idp": idp_oidc.GetResource(), + "zitadel_org": org.GetResource(), + "zitadel_human_user": human_user.GetResource(), + "zitadel_machine_user": machine_user.GetResource(), + "zitadel_project": project.GetResource(), + "zitadel_project_role": project_role.GetResource(), + "zitadel_domain": domain.GetResource(), + "zitadel_action": action.GetResource(), + "zitadel_application_oidc": application_oidc.GetResource(), + "zitadel_application_api": application_api.GetResource(), + "zitadel_application_key": app_key.GetResource(), + "zitadel_project_grant": project_grant.GetResource(), + "zitadel_user_grant": user_grant.GetResource(), + "zitadel_org_member": org_member.GetResource(), + "zitadel_project_member": project_member.GetResource(), + "zitadel_project_grant_member": project_grant_member.GetResource(), + "zitadel_domain_policy": domain_policy.GetResource(), + "zitadel_label_policy": label_policy.GetResource(), + "zitadel_lockout_policy": lockout_policy.GetResource(), + "zitadel_login_policy": login_policy.GetResource(), + "zitadel_password_complexity_policy": password_complexity_policy.GetResource(), + "zitadel_privacy_policy": privacy_policy.GetResource(), + "zitadel_trigger_actions": trigger_actions.GetResource(), + "zitadel_personal_access_token": pat.GetResource(), + "zitadel_machine_key": machine_key.GetResource(), + "zitadel_org_jwt_idp": idp_jwt.GetResource(), + "zitadel_org_oidc_idp": idp_oidc.GetResource(), + "zitadel_default_label_policy": default_label_policy.GetResource(), + "zitadel_default_login_policy": default_login_policy.GetResource(), + "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), + "zitadel_default_domain_policy": default_domain_policy.GetResource(), + "zitadel_default_privacy_policy": default_privacy_policy.GetResource(), + "zitadel_default_password_complexity_policy": default_password_complexity_policy.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/default_domain_policy/const.go b/zitadel/v2/default_domain_policy/const.go new file mode 100644 index 00000000..fb90b2c9 --- /dev/null +++ b/zitadel/v2/default_domain_policy/const.go @@ -0,0 +1,7 @@ +package default_domain_policy + +const ( + userLoginMustBeDomainVar = "user_login_must_be_domain" + validateOrgDomainVar = "validate_org_domains" + smtpSenderVar = "smtp_sender_address_matches_instance_domain" +) diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go new file mode 100644 index 00000000..d5e7c985 --- /dev/null +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -0,0 +1,76 @@ +package default_domain_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default domain policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdateDomainPolicy(ctx, &admin.UpdateDomainPolicyRequest{ + UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), + SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update default domain policy: %v", err) + } + d.SetId(resp.GetDetails().GetResourceOwner()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetDomainPolicy(ctx, &admin.GetDomainPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + } + + policy := resp.Policy + set := map[string]interface{}{ + userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), + validateOrgDomainVar: policy.GetValidateOrgDomains(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default domain policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_domain_policy/resource.go b/zitadel/v2/default_domain_policy/resource.go new file mode 100644 index 00000000..700a927e --- /dev/null +++ b/zitadel/v2/default_domain_policy/resource.go @@ -0,0 +1,33 @@ +package default_domain_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default domain policy.", + Schema: map[string]*schema.Schema{ + userLoginMustBeDomainVar: { + Type: schema.TypeBool, + Required: true, + Description: "User login must be domain", + }, + validateOrgDomainVar: { + Type: schema.TypeBool, + Required: true, + Description: "Validate organization domains", + }, + smtpSenderVar: { + Type: schema.TypeBool, + Required: true, + Description: "", + }, + }, + ReadContext: read, + CreateContext: update, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/default_label_policy/const.go b/zitadel/v2/default_label_policy/const.go new file mode 100644 index 00000000..15144cfb --- /dev/null +++ b/zitadel/v2/default_label_policy/const.go @@ -0,0 +1,20 @@ +package default_label_policy + +const ( + primaryColorVar = "primary_color" + hideLoginNameSuffixVar = "hide_login_name_suffix" + warnColorVar = "warn_color" + backgroundColorVar = "background_color" + fontColorVar = "font_color" + primaryColorDarkVar = "primary_color_dark" + backgroundColorDarkVar = "background_color_dark" + warnColorDarkVar = "warn_color_dark" + fontColorDarkVar = "font_color_dark" + disableWatermarkVar = "disable_watermark" + logoURLVar = "logo_url" + iconURLVar = "icon_url" + logoURLDarkVar = "logo_url_dark" + iconURLDarkVar = "icon_url_dark" + fontURLVar = "font_url" + setActiveVar = "set_active" +) diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go new file mode 100644 index 00000000..0bffc3a3 --- /dev/null +++ b/zitadel/v2/default_label_policy/funcs.go @@ -0,0 +1,106 @@ +package default_label_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default label policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdateLabelPolicy(ctx, &admin.UpdateLabelPolicyRequest{ + PrimaryColor: d.Get(primaryColorVar).(string), + HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), + WarnColor: d.Get(warnColorVar).(string), + BackgroundColor: d.Get(backgroundColorVar).(string), + FontColor: d.Get(fontColorVar).(string), + PrimaryColorDark: d.Get(primaryColorDarkVar).(string), + BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), + WarnColorDark: d.Get(warnColorDarkVar).(string), + FontColorDark: d.Get(fontColorDarkVar).(string), + DisableWatermark: d.Get(disableWatermarkVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update default label policy: %v", err) + } + d.SetId(resp.Details.ResourceOwner) + + active := d.Get(setActiveVar) + if active != nil { + activeBool := active.(bool) + if activeBool { + if _, err := client.ActivateLabelPolicy(ctx, &admin.ActivateLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate default label policy: %v", err) + } + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetLabelPolicy(ctx, &admin.GetLabelPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + } + + policy := resp.Policy + set := map[string]interface{}{ + primaryColorVar: policy.GetPrimaryColor(), + hideLoginNameSuffixVar: policy.GetHideLoginNameSuffix(), + warnColorVar: policy.GetWarnColor(), + backgroundColorVar: policy.GetBackgroundColor(), + fontColorVar: policy.GetFontColor(), + primaryColorDarkVar: policy.GetPrimaryColorDark(), + backgroundColorDarkVar: policy.GetBackgroundColorDark(), + warnColorDarkVar: policy.GetWarnColorDark(), + fontColorDarkVar: policy.GetFontColorDark(), + disableWatermarkVar: policy.GetDisableWatermark(), + logoURLVar: policy.GetLogoUrl(), + iconURLVar: policy.GetIconUrl(), + logoURLDarkVar: policy.GetLogoUrlDark(), + iconURLDarkVar: policy.GetIconUrlDark(), + fontURLVar: policy.GetFontUrl(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default label policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/v2/default_label_policy/resource.go new file mode 100644 index 00000000..78b07506 --- /dev/null +++ b/zitadel/v2/default_label_policy/resource.go @@ -0,0 +1,98 @@ +package default_label_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default label policy.", + Schema: map[string]*schema.Schema{ + primaryColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for primary color", + }, + hideLoginNameSuffixVar: { + Type: schema.TypeBool, + Required: true, + Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes", + }, + warnColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for warn color", + }, + backgroundColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for background color", + }, + fontColorVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for font color", + }, + primaryColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for primary color dark theme", + }, + backgroundColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for background color dark theme", + }, + warnColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for warn color dark theme", + }, + fontColorDarkVar: { + Type: schema.TypeString, + Required: true, + Description: "hex value for font color dark theme", + }, + disableWatermarkVar: { + Type: schema.TypeBool, + Required: true, + Description: "disable watermark", + }, + logoURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + iconURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + logoURLDarkVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + iconURLDarkVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + fontURLVar: { + Type: schema.TypeString, + Computed: true, + Description: "", + }, + setActiveVar: { + Type: schema.TypeBool, + Optional: true, + Description: "set the label policy active after creating/updating", + }, + }, + ReadContext: read, + CreateContext: update, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/default_lockout_policy/const.go b/zitadel/v2/default_lockout_policy/const.go new file mode 100644 index 00000000..ff032c6a --- /dev/null +++ b/zitadel/v2/default_lockout_policy/const.go @@ -0,0 +1,5 @@ +package default_lockout_policy + +const ( + maxPasswordAttemptsVar = "max_password_attempts" +) diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go new file mode 100644 index 00000000..a63637f7 --- /dev/null +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -0,0 +1,73 @@ +package default_lockout_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default lockout policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ + MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + }) + if err != nil { + return diag.Errorf("failed to update default lockout policy: %v", err) + } + d.SetId(resp.GetDetails().GetResourceOwner()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetLockoutPolicy(ctx, &admin.GetLockoutPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + } + + policy := resp.Policy + set := map[string]interface{}{ + maxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default lockout policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/v2/default_lockout_policy/resource.go new file mode 100644 index 00000000..aa6ead9a --- /dev/null +++ b/zitadel/v2/default_lockout_policy/resource.go @@ -0,0 +1,23 @@ +package default_lockout_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default lockout policy.", + Schema: map[string]*schema.Schema{ + maxPasswordAttemptsVar: { + Type: schema.TypeInt, + Required: true, + Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", + }, + }, + DeleteContext: delete, + CreateContext: update, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/default_login_policy/const.go b/zitadel/v2/default_login_policy/const.go new file mode 100644 index 00000000..96e5e0cc --- /dev/null +++ b/zitadel/v2/default_login_policy/const.go @@ -0,0 +1,20 @@ +package default_login_policy + +const ( + allowUsernamePasswordVar = "user_login" + allowRegisterVar = "allow_register" + allowExternalIDPVar = "allow_external_idp" + forceMFAVar = "force_mfa" + passwordlessTypeVar = "passwordless_type" + hidePasswordResetVar = "hide_password_reset" + passwordCheckLifetimeVar = "password_check_lifetime" + externalLoginCheckLifetimeVar = "external_login_check_lifetime" + mfaInitSkipLifetimeVar = "mfa_init_skip_lifetime" + secondFactorCheckLifetimeVar = "second_factor_check_lifetime" + multiFactorCheckLifetimeVar = "multi_factor_check_lifetime" + ignoreUnknownUsernamesVar = "ignore_unknown_usernames" + defaultRedirectURIVar = "default_redirect_uri" + secondFactorsVar = "second_factors" + multiFactorsVar = "multi_factors" + idpsVar = "idps" +) diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go new file mode 100644 index 00000000..00ab57d0 --- /dev/null +++ b/zitadel/v2/default_login_policy/funcs.go @@ -0,0 +1,206 @@ +package default_login_policy + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default login policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + current, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) + if err != nil { + return diag.FromErr(err) + } + + passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) + allowRegister := d.Get(allowRegisterVar).(bool) + allowExternalIdp := d.Get(allowExternalIDPVar).(bool) + forceMfa := d.Get(forceMFAVar).(bool) + passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) + hidePasswordReset := d.Get(hidePasswordResetVar).(bool) + ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) + defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) + currentPolicy := current.GetPolicy() + if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || + currentPolicy.GetAllowRegister() != allowRegister || + currentPolicy.GetAllowExternalIdp() != allowExternalIdp || + currentPolicy.GetForceMfa() != forceMfa || + currentPolicy.GetPasswordlessType() != passwordlessType || + currentPolicy.GetHidePasswordReset() != hidePasswordReset || + currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || + currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { + + resp, err := client.UpdateLoginPolicy(ctx, &admin.UpdateLoginPolicyRequest{ + AllowUsernamePassword: allowUsernamePassword, + AllowRegister: allowRegister, + AllowExternalIdp: allowExternalIdp, + ForceMfa: forceMfa, + PasswordlessType: passwordlessType, + HidePasswordReset: hidePasswordReset, + IgnoreUnknownUsernames: ignoreUnkownUsernames, + DefaultRedirectUri: defaultRedirectUri, + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + }) + if err != nil { + return diag.Errorf("failed to update login policy: %v", err) + } + d.SetId(resp.GetDetails().GetResourceOwner()) + } + + secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) + currentSecondFactors := make([]helper.Stringify, 0) + for _, secondFactor := range current.GetPolicy().GetSecondFactors() { + currentSecondFactors = append(currentSecondFactors, secondFactor) + } + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + + for _, factor := range addSecondFactor { + if _, err := client.AddSecondFactorToLoginPolicy(ctx, &admin.AddSecondFactorToLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteSecondFactors { + if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &admin.RemoveSecondFactorFromLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) + currentMultiFactors := make([]helper.Stringify, 0) + for _, multiFactor := range current.GetPolicy().GetMultiFactors() { + currentMultiFactors = append(currentMultiFactors, multiFactor) + } + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) + for _, factor := range addMultiFactor { + if _, err := client.AddMultiFactorToLoginPolicy(ctx, &admin.AddMultiFactorToLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteMultiFactors { + if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &admin.RemoveMultiFactorFromLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + + idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) + currentIdps := make([]helper.Stringify, 0) + for _, currentIdp := range current.GetPolicy().GetIdps() { + currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) + } + addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) + for _, addIdp := range addIdps { + if _, err := client.AddIDPToLoginPolicy(ctx, &admin.AddIDPToLoginPolicyRequest{IdpId: addIdp}); err != nil { + return diag.FromErr(err) + } + } + for _, deleteIdp := range deleteIdps { + if _, err := client.RemoveIDPFromLoginPolicy(ctx, &admin.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { + return diag.FromErr(err) + } + } + + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + //return diag.Errorf("failed to get login policy: %v", err) + } + + policy := resp.Policy + set := map[string]interface{}{ + allowUsernamePasswordVar: policy.GetAllowUsernamePassword(), + allowRegisterVar: policy.GetAllowRegister(), + allowExternalIDPVar: policy.GetAllowExternalIdp(), + forceMFAVar: policy.GetForceMfa(), + passwordlessTypeVar: policy.GetPasswordlessType().String(), + hidePasswordResetVar: policy.GetHidePasswordReset(), + passwordCheckLifetimeVar: policy.GetPasswordCheckLifetime().AsDuration().String(), + externalLoginCheckLifetimeVar: policy.GetExternalLoginCheckLifetime().AsDuration().String(), + mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), + secondFactorCheckLifetimeVar: policy.GetSecondFactorCheckLifetime().AsDuration().String(), + multiFactorCheckLifetimeVar: policy.GetMultiFactorCheckLifetime().AsDuration().String(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of login policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go new file mode 100644 index 00000000..84c8f535 --- /dev/null +++ b/zitadel/v2/default_login_policy/resource.go @@ -0,0 +1,107 @@ +package default_login_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default login policy.", + Schema: map[string]*schema.Schema{ + allowUsernamePasswordVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user is allowed to login with his username and password", + }, + allowRegisterVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a person is allowed to register a user on this organisation", + }, + allowExternalIDPVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user is allowed to add a defined identity provider. E.g. Google auth", + }, + forceMFAVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if a user MUST use a multi factor to log in", + }, + passwordlessTypeVar: { + Type: schema.TypeString, + Required: true, + Description: "defines if passwordless is allowed for users", + }, + hidePasswordResetVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if password reset link should be shown in the login screen", + }, + ignoreUnknownUsernamesVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if unknown username on login screen directly return an error or always display the password screen", + }, + defaultRedirectURIVar: { + Type: schema.TypeString, + Required: true, + Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", + }, + passwordCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + externalLoginCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + mfaInitSkipLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + secondFactorCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + multiFactorCheckLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + secondFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed second factors", + }, + multiFactorsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed multi factors", + }, + idpsVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "allowed idps to login or register", + }, + }, + CreateContext: update, + UpdateContext: update, + DeleteContext: delete, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/default_password_complexity_policy/const.go b/zitadel/v2/default_password_complexity_policy/const.go new file mode 100644 index 00000000..5e830e3a --- /dev/null +++ b/zitadel/v2/default_password_complexity_policy/const.go @@ -0,0 +1,9 @@ +package default_password_complexity_policy + +const ( + minLengthVar = "min_length" + hasUppercaseVar = "has_uppercase" + hasLowercaseVar = "has_lowercase" + hasNumberVar = "has_number" + hasSymbolVar = "has_symbol" +) diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go new file mode 100644 index 00000000..4afd1581 --- /dev/null +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -0,0 +1,81 @@ +package default_password_complexity_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default password complexity policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdatePasswordComplexityPolicy(ctx, &admin.UpdatePasswordComplexityPolicyRequest{ + MinLength: uint32(d.Get(minLengthVar).(int)), + HasUppercase: d.Get(hasUppercaseVar).(bool), + HasLowercase: d.Get(hasLowercaseVar).(bool), + HasNumber: d.Get(hasNumberVar).(bool), + HasSymbol: d.Get(hasSymbolVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update default password complexity policy: %v", err) + } + d.SetId(resp.GetDetails().GetResourceOwner()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetPasswordComplexityPolicy(ctx, &admin.GetPasswordComplexityPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + } + + policy := resp.Policy + set := map[string]interface{}{ + minLengthVar: policy.GetMinLength(), + hasUppercaseVar: policy.GetHasUppercase(), + hasLowercaseVar: policy.GetHasLowercase(), + hasNumberVar: policy.GetHasNumber(), + hasSymbolVar: policy.GetHasSymbol(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default password complexity policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_password_complexity_policy/resource.go b/zitadel/v2/default_password_complexity_policy/resource.go new file mode 100644 index 00000000..ac2c3d26 --- /dev/null +++ b/zitadel/v2/default_password_complexity_policy/resource.go @@ -0,0 +1,43 @@ +package default_password_complexity_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default password complexity policy.", + Schema: map[string]*schema.Schema{ + minLengthVar: { + Type: schema.TypeInt, + Required: true, + Description: "Minimal length for the password", + }, + hasUppercaseVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain an upper case letter", + }, + hasLowercaseVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a lower case letter", + }, + hasNumberVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a number", + }, + hasSymbolVar: { + Type: schema.TypeBool, + Required: true, + Description: "defines if the password MUST contain a symbol. E.g. \"$\"", + }, + }, + DeleteContext: delete, + ReadContext: read, + CreateContext: update, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/default_privacy_policy/const.go b/zitadel/v2/default_privacy_policy/const.go new file mode 100644 index 00000000..ec5939b4 --- /dev/null +++ b/zitadel/v2/default_privacy_policy/const.go @@ -0,0 +1,7 @@ +package default_privacy_policy + +const ( + tosLinkVar = "tos_link" + privacyLinkVar = "privacy_link" + helpLinkVar = "help_link" +) diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go new file mode 100644 index 00000000..b8c4fe75 --- /dev/null +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -0,0 +1,77 @@ +package default_privacy_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default privacy policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdatePrivacyPolicy(ctx, &admin.UpdatePrivacyPolicyRequest{ + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update default privacy policy: %v", err) + } + d.SetId(resp.GetDetails().GetResourceOwner()) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetPrivacyPolicy(ctx, &admin.GetPrivacyPolicyRequest{}) + if err != nil { + d.SetId("") + return nil + } + + policy := resp.Policy + set := map[string]interface{}{ + tosLinkVar: policy.GetTosLink(), + privacyLinkVar: policy.GetPrivacyLink(), + helpLinkVar: policy.GetHelpLink(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default privacy policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/v2/default_privacy_policy/resource.go new file mode 100644 index 00000000..e03dbf92 --- /dev/null +++ b/zitadel/v2/default_privacy_policy/resource.go @@ -0,0 +1,33 @@ +package default_privacy_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default privacy policy.", + Schema: map[string]*schema.Schema{ + tosLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + privacyLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + helpLinkVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, + }, + CreateContext: update, + DeleteContext: delete, + ReadContext: read, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From 7934f994dea38f2f541ec9344239bdd111c6bde3 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 10 Nov 2022 12:50:01 +0100 Subject: [PATCH 020/260] fix: add review changes with HasChanged check --- docs/resources/smtp_config.md | 5 +- zitadel/v2/smtp_config/funcs.go | 108 ++++++++++++++++++++--------- zitadel/v2/smtp_config/resource.go | 6 +- 3 files changed, 81 insertions(+), 38 deletions(-) diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index e0be00af..30d8df99 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -28,9 +28,12 @@ resource zitadel_smtp_config smtp { ### Required - `host` (String) Host address to your SMTP server. -- `password` (String, Sensitive) Password used to communicate with your SMTP server. - `sender_address` (String) Address used to send emails. - `sender_name` (String) Sender name used to send emails. + +### Optional + +- `password` (String, Sensitive) Password used to communicate with your SMTP server. - `tls` (Boolean) TLS used to communicate with your SMTP server. - `user` (String) User used to communicate with your SMTP server. diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index 08aa6d65..3178401f 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -44,14 +44,25 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.AddSMTPConfig(ctx, &admin.AddSMTPConfigRequest{ + tls, tlsOk := d.GetOk(tlsVar) + user, userOk := d.GetOk(userVar) + password, pwOk := d.GetOk(passwordVar) + req := &admin.AddSMTPConfigRequest{ SenderAddress: d.Get(senderAddressVar).(string), SenderName: d.Get(senderNameVar).(string), - Tls: d.Get(tlsVar).(bool), Host: d.Get(hostVar).(string), - User: d.Get(userVar).(string), - Password: d.Get(passwordVar).(string), - }) + } + if tlsOk { + req.Tls = tls.(bool) + } + if userOk { + req.User = user.(string) + } + if pwOk { + req.Password = password.(string) + } + + resp, err := client.AddSMTPConfig(ctx, req) if err != nil { return diag.Errorf("failed to create smtp config: %v", err) } @@ -73,38 +84,52 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - smtp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) - if err != nil { - return diag.FromErr(err) + if d.HasChanges(senderAddressVar, senderNameVar, tlsVar, hostVar, userVar) { + smtp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) + if err != nil { + return diag.FromErr(err) + } + + senderAddress := d.Get(senderAddressVar).(string) + senderName := d.Get(senderNameVar).(string) + tls, tlsOk := d.GetOk(tlsVar) + host := d.Get(hostVar).(string) + user, userOk := d.GetOk(userVar) + + if smtp.SmtpConfig.SenderName != senderName || + smtp.SmtpConfig.SenderAddress != senderAddress || + smtp.SmtpConfig.Tls != tls || + smtp.SmtpConfig.Host != host || + smtp.SmtpConfig.User != user { + + req := &admin.UpdateSMTPConfigRequest{ + SenderAddress: senderAddress, + SenderName: senderName, + Host: host, + } + if tlsOk { + req.Tls = tls.(bool) + } + if userOk { + req.User = user.(string) + } + + _, err = client.UpdateSMTPConfig(ctx, req) + if err != nil { + return diag.Errorf("failed to update smtp config: %v", err) + } + } } - senderAddress := d.Get(senderAddressVar).(string) - senderName := d.Get(senderNameVar).(string) - tls := d.Get(tlsVar).(bool) - host := d.Get(hostVar).(string) - user := d.Get(userVar).(string) - if smtp.SmtpConfig.SenderName != senderName || - smtp.SmtpConfig.SenderAddress != senderAddress || - smtp.SmtpConfig.Tls != tls || - smtp.SmtpConfig.Host != host || - smtp.SmtpConfig.User != user { - - _, err = client.UpdateSMTPConfig(ctx, &admin.UpdateSMTPConfigRequest{ - SenderAddress: senderAddress, - SenderName: senderName, - Tls: tls, - Host: host, - User: user, - }) - if err != nil { - return diag.Errorf("failed to update smtp config: %v", err) + if d.HasChange(passwordVar) { + password, pwOk := d.GetOk(passwordVar) + req := &admin.UpdateSMTPConfigPasswordRequest{} + if pwOk { + req.Password = password.(string) } - } else { - _, err = client.UpdateSMTPConfigPassword(ctx, &admin.UpdateSMTPConfigPasswordRequest{ - Password: d.Get(passwordVar).(string), - }) + _, err = client.UpdateSMTPConfigPassword(ctx, req) if err != nil { - return diag.Errorf("failed to update smtp config: %v", err) + return diag.Errorf("failed to update smtp config password: %v", err) } } @@ -128,7 +153,22 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("error while reading smtp config: %v", err) + } + password, pwOk := d.GetOk(passwordVar) + set := map[string]interface{}{ + senderAddressVar: resp.GetSmtpConfig().GetSenderAddress(), + senderNameVar: resp.GetSmtpConfig().GetSenderName(), + tlsVar: resp.GetSmtpConfig().GetTls(), + hostVar: resp.GetSmtpConfig().GetHost(), + userVar: resp.GetSmtpConfig().GetUser(), + } + if pwOk { + set[passwordVar] = password.(string) + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of smtp config: %v", k, err) + } } d.SetId(resp.SmtpConfig.Details.ResourceOwner) return nil diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index e8318121..15438f42 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { }, tlsVar: { Type: schema.TypeBool, - Required: true, + Optional: true, Description: "TLS used to communicate with your SMTP server.", }, hostVar: { @@ -30,12 +30,12 @@ func GetResource() *schema.Resource { }, userVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "User used to communicate with your SMTP server.", }, passwordVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Password used to communicate with your SMTP server.", Sensitive: true, }, From a5effdf4dc044cae37eabb01580a7a44634b97eb Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 10 Nov 2022 12:58:36 +0100 Subject: [PATCH 021/260] fix: add review changes with HasChanged check --- docs/resources/sms_provider_twilio.md | 4 +- zitadel/v2/sms_provider_twilio/funcs.go | 51 ++++++++++++++-------- zitadel/v2/sms_provider_twilio/resource.go | 2 +- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index c702599d..1c30dcc9 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -2,12 +2,12 @@ page_title: "zitadel_sms_provider_twilio Resource - terraform-provider-zitadel" subcategory: "" description: |- - Resource representing the SMTP configuration of an instance. + Resource representing the SMS provider Twilio configuration of an instance. --- # zitadel_sms_provider_twilio (Resource) -Resource representing the SMTP configuration of an instance. +Resource representing the SMS provider Twilio configuration of an instance. ## Example Usage diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go index 5af708e6..de57aef3 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -70,25 +70,29 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - sms, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{}) - if err != nil { - return diag.FromErr(err) - } - - sid := d.Get(sidVar).(string) - senderNumber := d.Get(senderNumberVar).(string) - twilio := sms.Config.GetTwilio() - if twilio.Sid != sid || - twilio.SenderNumber != senderNumber { - _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ - Id: d.Id(), - Sid: sid, - SenderNumber: senderNumber, - }) + if d.HasChanges(senderNumberVar, sidVar) { + sms, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{}) if err != nil { - return diag.Errorf("failed to update sms provider twilio: %v", err) + return diag.FromErr(err) + } + + sid := d.Get(sidVar).(string) + senderNumber := d.Get(senderNumberVar).(string) + twilio := sms.Config.GetTwilio() + if twilio.Sid != sid || + twilio.SenderNumber != senderNumber { + _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ + Id: d.Id(), + Sid: sid, + SenderNumber: senderNumber, + }) + if err != nil { + return diag.Errorf("failed to update sms provider twilio: %v", err) + } } - } else { + } + + if d.HasChange(tokenVar) { _, err = client.UpdateSMSProviderTwilioToken(ctx, &admin.UpdateSMSProviderTwilioTokenRequest{ Id: d.Id(), Token: d.Get(tokenVar).(string), @@ -120,7 +124,18 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("error while reading sms provider twilio: %v", err) + } + set := map[string]interface{}{ + sidVar: resp.GetConfig().GetTwilio().GetSid(), + senderNumberVar: resp.GetConfig().GetTwilio().GetSenderNumber(), + } + if token, ok := d.GetOk(tokenVar); ok { + set[tokenVar] = token + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of sms provider twilio: %v", k, err) + } } d.SetId(resp.Config.Id) return nil diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go index 39916fe6..43e61cf3 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -6,7 +6,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing the SMTP configuration of an instance.", + Description: "Resource representing the SMS provider Twilio configuration of an instance.", Schema: map[string]*schema.Schema{ sidVar: { Type: schema.TypeString, From 4481167984e4c9de232b01c0c7a5734455bc7fae Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 11 Nov 2022 16:07:20 +0100 Subject: [PATCH 022/260] fix: add review changes with HasChanged checks, optional and default values --- docs/resources/application_api.md | 17 +- docs/resources/application_key.md | 2 +- docs/resources/application_oidc.md | 30 +- docs/resources/human_user.md | 17 +- docs/resources/login_policy.md | 28 +- docs/resources/machine_key.md | 17 +- .../{org_jwt_idp.md => org_idp_jwt.md} | 8 +- .../{org_oidc_idp.md => org_idp_oidc.md} | 8 +- docs/resources/personal_access_token.md | 5 +- docs/resources/project.md | 12 +- docs/resources/project_grant.md | 11 +- docs/resources/smtp_config.md | 8 +- docs/resources/trigger_actions.md | 4 +- docs/resources/user_grant.md | 10 +- .../provider/resources/application_api.tf | 13 +- .../provider/resources/application_oidc.tf | 17 +- examples/provider/resources/human_user.tf | 15 +- examples/provider/resources/login_policy.tf | 19 ++ examples/provider/resources/machine_key.tf | 10 +- .../{org_jwt_idp.tf => org_idp_jwt.tf} | 2 +- .../{org_oidc_idp.tf => org_idp_oidc.tf} | 2 +- examples/provider/resources/org_member.tf | 1 - examples/provider/resources/project.tf | 10 +- examples/provider/resources/project_grant.tf | 10 +- examples/provider/resources/smtp_config.tf | 8 +- examples/provider/resources/user_grant.tf | 10 +- ...rg_jwt_idp.md.tmpl => org_idp_jwt.md.tmpl} | 2 +- ..._oidc_idp.md.tmpl => org_idp_oidc.md.tmpl} | 2 +- zitadel/provider.go | 12 +- zitadel/v2/action/funcs.go | 1 - zitadel/v2/app_key/funcs.go | 27 +- zitadel/v2/app_key/resource.go | 2 +- zitadel/v2/application_api/funcs.go | 48 +-- zitadel/v2/application_api/resource.go | 2 +- zitadel/v2/application_oidc/funcs.go | 148 +++++---- zitadel/v2/application_oidc/resource.go | 16 +- zitadel/v2/domain/funcs.go | 1 - zitadel/v2/domain_policy/funcs.go | 1 - zitadel/v2/helper/helper.go | 24 ++ zitadel/v2/human_user/funcs.go | 170 +++++----- zitadel/v2/human_user/resource.go | 7 +- zitadel/v2/label_policy/funcs.go | 1 - zitadel/v2/lockout_policy/funcs.go | 1 - zitadel/v2/login_policy/funcs.go | 309 +++++++++++------- zitadel/v2/login_policy/resource.go | 6 +- zitadel/v2/machine_key/funcs.go | 27 +- zitadel/v2/machine_key/resource.go | 5 +- zitadel/v2/machine_user/funcs.go | 1 - zitadel/v2/machine_user/resource.go | 1 - zitadel/v2/{idp_jwt => org_idp_jwt}/const.go | 2 +- .../v2/{idp_jwt => org_idp_jwt}/datasource.go | 2 +- zitadel/v2/{idp_jwt => org_idp_jwt}/funcs.go | 80 ++--- .../v2/{idp_jwt => org_idp_jwt}/resource.go | 4 +- .../v2/{idp_oidc => org_idp_oidc}/const.go | 2 +- .../{idp_oidc => org_idp_oidc}/datasource.go | 2 +- .../v2/{idp_oidc => org_idp_oidc}/funcs.go | 106 +++--- .../v2/{idp_oidc => org_idp_oidc}/resource.go | 4 +- zitadel/v2/org_member/funcs.go | 15 +- .../v2/password_complexity_policy/funcs.go | 1 - zitadel/v2/pat/funcs.go | 20 +- zitadel/v2/pat/resource.go | 2 +- zitadel/v2/privacy_policy/funcs.go | 1 - zitadel/v2/project/funcs.go | 1 - zitadel/v2/project/resource.go | 2 +- zitadel/v2/project_grant/funcs.go | 10 +- zitadel/v2/project_grant_member/funcs.go | 9 +- zitadel/v2/project_member/funcs.go | 10 +- zitadel/v2/project_role/funcs.go | 1 - zitadel/v2/smtp_config/funcs.go | 42 +-- zitadel/v2/trigger_actions/funcs.go | 14 +- zitadel/v2/trigger_actions/resource.go | 4 +- zitadel/v2/user_grant/const.go | 10 +- zitadel/v2/user_grant/funcs.go | 48 ++- zitadel/v2/user_grant/resource.go | 10 +- 74 files changed, 859 insertions(+), 651 deletions(-) rename docs/resources/{org_jwt_idp.md => org_idp_jwt.md} (83%) rename docs/resources/{org_oidc_idp.md => org_idp_oidc.md} (86%) rename examples/provider/resources/{org_jwt_idp.tf => org_idp_jwt.tf} (89%) rename examples/provider/resources/{org_oidc_idp.tf => org_idp_oidc.tf} (92%) rename templates/resources/{org_jwt_idp.md.tmpl => org_idp_jwt.md.tmpl} (82%) rename templates/resources/{org_oidc_idp.md.tmpl => org_idp_oidc.md.tmpl} (82%) rename zitadel/v2/{idp_jwt => org_idp_jwt}/const.go (93%) rename zitadel/v2/{idp_jwt => org_idp_jwt}/datasource.go (98%) rename zitadel/v2/{idp_jwt => org_idp_jwt}/funcs.go (70%) rename zitadel/v2/{idp_jwt => org_idp_jwt}/resource.go (94%) rename zitadel/v2/{idp_oidc => org_idp_oidc}/const.go (95%) rename zitadel/v2/{idp_oidc => org_idp_oidc}/datasource.go (99%) rename zitadel/v2/{idp_oidc => org_idp_oidc}/funcs.go (64%) rename zitadel/v2/{idp_oidc => org_idp_oidc}/resource.go (95%) diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index f80889d7..54b2df36 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -12,14 +12,22 @@ Resource representing an API application belonging to a project, with all config ## Example Usage ```terraform -resource zitadel_application_api application_api { +resource zitadel_application_api application_api_full { depends_on = [zitadel_org.org, zitadel_project.project] org_id = zitadel_org.org.id project_id = zitadel_project.project.id - name = "applicationapi" + name = "applicationapifull" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } + +resource zitadel_application_api application_api_min { + depends_on = [zitadel_org.org, zitadel_project.project] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + name = "applicationapimin" +} ``` @@ -27,11 +35,14 @@ resource zitadel_application_api application_api { ### Required -- `auth_method_type` (String) Auth method type - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project +### Optional + +- `auth_method_type` (String) Auth method type, supported values: API_AUTH_METHOD_TYPE_BASIC, API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT + ### Read-Only - `client_id` (String, Sensitive) generated ID for this config diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 6618a6c6..9f1c8e39 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -30,7 +30,7 @@ resource zitadel_application_key app_key { - `app_id` (String) ID of the application - `expiration_date` (String) Expiration date of the app key -- `key_type` (String) Type of the app key +- `key_type` (String) Type of the app key, supported values: KEY_TYPE_UNSPECIFIED, KEY_TYPE_JSON - `org_id` (String) ID of the organization - `project_id` (String) ID of the project diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 711b239f..98d905c3 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -12,13 +12,13 @@ Resource representing an OIDC application belonging to a project, with all confi ## Example Usage ```terraform -resource zitadel_application_oidc application_oidc { +resource zitadel_application_oidc application_oidc_full { depends_on = [zitadel_org.org, zitadel_project.project] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - name = "applicationoidc" + name = "applicationoidcfull" redirect_uris = ["https://localhost.com"] response_types = ["OIDC_RESPONSE_TYPE_CODE"] grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] @@ -34,6 +34,18 @@ resource zitadel_application_oidc application_oidc { id_token_userinfo_assertion = false additional_origins = [] } + +resource zitadel_application_oidc application_oidc_min { + depends_on = [zitadel_org.org, zitadel_project.project] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + + name = "applicationoidcmin" + redirect_uris = ["https://localhost.com"] + response_types = ["OIDC_RESPONSE_TYPE_CODE"] + grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] +} ``` @@ -41,26 +53,26 @@ resource zitadel_application_oidc application_oidc { ### Required -- `app_type` (String) App type -- `auth_method_type` (String) Auth method type -- `clock_skew` (String) Clockskew -- `grant_types` (List of String) Grant types +- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project - `redirect_uris` (List of String) RedirectURIs -- `response_types` (List of String) Response type +- `response_types` (List of String) Response type, supported values: OIDC_APP_TYPE_NATIVE, OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT ### Optional - `access_token_role_assertion` (Boolean) Access token role assertion -- `access_token_type` (String) Access token type +- `access_token_type` (String) Access token type, supported values: OIDC_TOKEN_TYPE_BEARER, OIDC_TOKEN_TYPE_JWT - `additional_origins` (List of String) Additional origins +- `app_type` (String) App type, supported values: OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT, OIDC_APP_TYPE_NATIVE +- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_BASIC, OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE, OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT +- `clock_skew` (String) Clockskew - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion - `id_token_userinfo_assertion` (Boolean) Token userinfo assertion - `post_logout_redirect_uris` (List of String) Post logout redirect URIs -- `version` (String) Version +- `version` (String) Version, supported values: OIDC_VERSION_1_0 ### Read-Only diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index bde57b7e..2ef6c5ea 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -14,11 +14,11 @@ Resource representing a human user situated under an organization, which then ca ## Example Usage ```terraform -resource zitadel_human_user human_user { +resource zitadel_human_user human_user_full { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "human@localhost.com" + user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" nick_name = "nickname" @@ -29,7 +29,16 @@ resource zitadel_human_user human_user { is_phone_verified = true email = "test@zitadel.com" is_email_verified = true - initial_password = "Password1!" + initial_password = "Password1!" +} + +resource zitadel_human_user human_user_min { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_name = "humanmin@localhost.com" + first_name = "firstname" + last_name = "lastname" } ``` @@ -47,7 +56,7 @@ resource zitadel_human_user human_user { ### Optional - `display_name` (String) Display name of the user -- `gender` (String) Gender of the user +- `gender` (String) Gender of the user, supported values: GENDER_DIVERSE, GENDER_UNSPECIFIED, GENDER_FEMALE, GENDER_MALE - `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 7f0b798a..518073ec 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -33,6 +33,25 @@ resource zitadel_login_policy login_policy { multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] } + +resource zitadel_login_policy login_policy_min { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" + ignore_unknown_usernames = true + default_redirect_uri = "localhost:8080" +} ``` @@ -46,18 +65,21 @@ resource zitadel_login_policy login_policy { - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen -- `idps` (Set of String) allowed idps to login or register - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) - `multi_factor_check_lifetime` (String) -- `multi_factors` (Set of String) allowed multi factors - `org_id` (String) Id for the organization - `password_check_lifetime` (String) - `passwordless_type` (String) defines if passwordless is allowed for users - `second_factor_check_lifetime` (String) -- `second_factors` (Set of String) allowed second factors - `user_login` (Boolean) defines if a user is allowed to login with his username and password +### Optional + +- `idps` (Set of String) allowed idps to login or register +- `multi_factors` (Set of String) allowed multi factors +- `second_factors` (Set of String) allowed second factors + ### Read-Only - `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index 16251de4..46cfd230 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -12,7 +12,7 @@ Resource representing a machine key ## Example Usage ```terraform -resource zitadel_machine_key machine_key { +resource zitadel_machine_key machine_key_full { depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id @@ -20,6 +20,14 @@ resource zitadel_machine_key machine_key { key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } + +resource zitadel_machine_key machine_key_min { + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_machine_user.machine_user.id + key_type = "KEY_TYPE_JSON" +} ``` @@ -27,11 +35,14 @@ resource zitadel_machine_key machine_key { ### Required -- `expiration_date` (String) Expiration date of the machine key -- `key_type` (String) Type of the machine key +- `key_type` (String) Type of the machine key, supported values: KEY_TYPE_UNSPECIFIED, KEY_TYPE_JSON - `org_id` (String) ID of the organization - `user_id` (String) ID of the user +### Optional + +- `expiration_date` (String) Expiration date of the machine key + ### Read-Only - `id` (String) The ID of this resource. diff --git a/docs/resources/org_jwt_idp.md b/docs/resources/org_idp_jwt.md similarity index 83% rename from docs/resources/org_jwt_idp.md rename to docs/resources/org_idp_jwt.md index 5b9e2fe6..011eca9d 100644 --- a/docs/resources/org_jwt_idp.md +++ b/docs/resources/org_idp_jwt.md @@ -1,18 +1,18 @@ --- -page_title: "zitadel_org_jwt_idp Resource - terraform-provider-zitadel" +page_title: "zitadel_org_idp_jwt Resource - terraform-provider-zitadel" subcategory: "" description: |- Resource representing a domain of the organization. --- -# zitadel_org_jwt_idp (Resource) +# zitadel_org_idp_jwt (Resource) Resource representing a domain of the organization. ## Example Usage ```terraform -resource zitadel_org_jwt_idp jwt_idp { +resource zitadel_org_idp_jwt jwt_idp { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id @@ -38,7 +38,7 @@ resource zitadel_org_jwt_idp jwt_idp { - `keys_endpoint` (String) the endpoint to the key (JWK) which are used to sign the JWT with - `name` (String) Name of the IDP - `org_id` (String) ID of the organization -- `styling_type` (String) Some identity providers specify the styling of the button to their login +- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_GOOGLE, STYLING_TYPE_UNSPECIFIED ### Read-Only diff --git a/docs/resources/org_oidc_idp.md b/docs/resources/org_idp_oidc.md similarity index 86% rename from docs/resources/org_oidc_idp.md rename to docs/resources/org_idp_oidc.md index 249636c9..f9e88949 100644 --- a/docs/resources/org_oidc_idp.md +++ b/docs/resources/org_idp_oidc.md @@ -1,18 +1,18 @@ --- -page_title: "zitadel_org_oidc_idp Resource - terraform-provider-zitadel" +page_title: "zitadel_org_idp_oidc Resource - terraform-provider-zitadel" subcategory: "" description: |- Resource representing a OIDC IDP of the organization. --- -# zitadel_org_oidc_idp (Resource) +# zitadel_org_idp_oidc (Resource) Resource representing a OIDC IDP of the organization. ## Example Usage ```terraform -resource zitadel_org_oidc_idp oidc_idp { +resource zitadel_org_idp_oidc oidc_idp { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id @@ -41,7 +41,7 @@ resource zitadel_org_oidc_idp oidc_idp { - `name` (String) Name of the IDP - `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `styling_type` (String) Some identity providers specify the styling of the button to their login +- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE - `username_mapping` (String) definition which field is mapped to the email of the user ### Read-Only diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 941f98d1..046e1a8e 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -26,10 +26,13 @@ resource zitadel_personal_access_token pat { ### Required -- `expiration_date` (String) Expiration date of the token - `org_id` (String) ID of the organization - `user_id` (String) ID of the user +### Optional + +- `expiration_date` (String) Expiration date of the token + ### Read-Only - `id` (String) The ID of this resource. diff --git a/docs/resources/project.md b/docs/resources/project.md index ccc2028e..773c7ac8 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -12,7 +12,7 @@ Resource representing the project, which can then be granted to different organi ## Example Usage ```terraform -resource zitadel_project project { +resource zitadel_project project_full { depends_on = [zitadel_org.org] name = "projectname" @@ -22,6 +22,14 @@ resource zitadel_project project { has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } + +resource zitadel_project project_min { + depends_on = [zitadel_org.org] + + name = "projectname" + org_id = zitadel_org.org.id + private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" +} ``` @@ -35,7 +43,7 @@ resource zitadel_project project { ### Optional - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project -- `private_labeling_setting` (String) Defines from where the private labeling should be triggered +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY - `project_role_assertion` (Boolean) describes if roles of user should be added in token - `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 31181952..85b7d471 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -12,7 +12,16 @@ Resource representing the grant of a project to a different organization, also c ## Example Usage ```terraform -resource zitadel_project_grant project_grant { +resource zitadel_project_grant project_grant_full { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + granted_org_id = zitadel_org.grantedorg.id + role_keys = [zitadel_project_role.project_role.role_key] +} + +resource zitadel_project_grant project_grant_min { depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] org_id = zitadel_org.org.id diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index 30d8df99..e10f45be 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -12,7 +12,7 @@ Resource representing the SMTP configuration of an instance. ## Example Usage ```terraform -resource zitadel_smtp_config smtp { +resource zitadel_smtp_config smtp_full { sender_address = "address" sender_name = "no-reply" tls = true @@ -20,6 +20,12 @@ resource zitadel_smtp_config smtp { user = "user" password = "password" } + +resource zitadel_smtp_config smtp_min { + sender_address = "address" + sender_name = "no-reply" + host = "localhost:25" +} ``` diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index ffed563f..3f39e004 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -28,9 +28,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_UNSPECIFIED, FLOW_TYPE_EXTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION ### Read-Only diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 92a603da..9b63514a 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -12,7 +12,7 @@ Resource representing the authorization given to a user directly, including the ## Example Usage ```terraform -resource zitadel_user_grant user_grant { +resource zitadel_user_grant user_grant_full { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id @@ -20,6 +20,14 @@ resource zitadel_user_grant user_grant { role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id } + +resource zitadel_user_grant user_grant_min { + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + user_id = zitadel_human_user.granted_human_user.id +} ``` diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index b58c2229..36c5b14f 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -1,9 +1,16 @@ - -resource zitadel_application_api application_api { +resource zitadel_application_api application_api_full { depends_on = [zitadel_org.org, zitadel_project.project] org_id = zitadel_org.org.id project_id = zitadel_project.project.id - name = "applicationapi" + name = "applicationapifull" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" +} + +resource zitadel_application_api application_api_min { + depends_on = [zitadel_org.org, zitadel_project.project] + + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + name = "applicationapimin" } \ No newline at end of file diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index 12cd663e..7314b792 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,11 +1,10 @@ - -resource zitadel_application_oidc application_oidc { +resource zitadel_application_oidc application_oidc_full { depends_on = [zitadel_org.org, zitadel_project.project] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - name = "applicationoidc" + name = "applicationoidcfull" redirect_uris = ["https://localhost.com"] response_types = ["OIDC_RESPONSE_TYPE_CODE"] grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] @@ -20,4 +19,16 @@ resource zitadel_application_oidc application_oidc { id_token_role_assertion = false id_token_userinfo_assertion = false additional_origins = [] +} + +resource zitadel_application_oidc application_oidc_min { + depends_on = [zitadel_org.org, zitadel_project.project] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + + name = "applicationoidcmin" + redirect_uris = ["https://localhost.com"] + response_types = ["OIDC_RESPONSE_TYPE_CODE"] + grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] } \ No newline at end of file diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 29c3e9c0..980c575b 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,8 +1,8 @@ -resource zitadel_human_user human_user { +resource zitadel_human_user human_user_full { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - user_name = "human@localhost.com" + user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" nick_name = "nickname" @@ -13,5 +13,14 @@ resource zitadel_human_user human_user { is_phone_verified = true email = "test@zitadel.com" is_email_verified = true - initial_password = "Password1!" + initial_password = "Password1!" } + +resource zitadel_human_user human_user_min { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_name = "humanmin@localhost.com" + first_name = "firstname" + last_name = "lastname" +} \ No newline at end of file diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index dfbb0f0a..252f1f2f 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -18,4 +18,23 @@ resource zitadel_login_policy login_policy { second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] +} + +resource zitadel_login_policy login_policy_min { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + user_login = true + allow_register = true + allow_external_idp = true + force_mfa = false + passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" + hide_password_reset = "false" + password_check_lifetime = "240h0m0s" + external_login_check_lifetime = "240h0m0s" + multi_factor_check_lifetime = "720h0m0s" + mfa_init_skip_lifetime = "24h0m0s" + second_factor_check_lifetime = "24h0m0s" + ignore_unknown_usernames = true + default_redirect_uri = "localhost:8080" } \ No newline at end of file diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 94212129..3da3e684 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,8 +1,16 @@ -resource zitadel_machine_key machine_key { +resource zitadel_machine_key machine_key_full { depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" +} + +resource zitadel_machine_key machine_key_min { + depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] + + org_id = zitadel_org.org.id + user_id = zitadel_machine_user.machine_user.id + key_type = "KEY_TYPE_JSON" } \ No newline at end of file diff --git a/examples/provider/resources/org_jwt_idp.tf b/examples/provider/resources/org_idp_jwt.tf similarity index 89% rename from examples/provider/resources/org_jwt_idp.tf rename to examples/provider/resources/org_idp_jwt.tf index 52ee4edc..d68d4df3 100644 --- a/examples/provider/resources/org_jwt_idp.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -1,4 +1,4 @@ -resource zitadel_org_jwt_idp jwt_idp { +resource zitadel_org_idp_jwt jwt_idp { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id diff --git a/examples/provider/resources/org_oidc_idp.tf b/examples/provider/resources/org_idp_oidc.tf similarity index 92% rename from examples/provider/resources/org_oidc_idp.tf rename to examples/provider/resources/org_idp_oidc.tf index cd05c612..af57d67b 100644 --- a/examples/provider/resources/org_oidc_idp.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,4 +1,4 @@ -resource zitadel_org_oidc_idp oidc_idp { +resource zitadel_org_idp_oidc oidc_idp { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id diff --git a/examples/provider/resources/org_member.tf b/examples/provider/resources/org_member.tf index f0d1bd5e..3044c7a6 100644 --- a/examples/provider/resources/org_member.tf +++ b/examples/provider/resources/org_member.tf @@ -1,4 +1,3 @@ - resource zitadel_org_member org_member { depends_on = [zitadel_org.org, zitadel_human_user.human_user] diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 2124a299..160e79cb 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,5 +1,5 @@ -resource zitadel_project project { +resource zitadel_project project_full { depends_on = [zitadel_org.org] name = "projectname" @@ -8,4 +8,12 @@ resource zitadel_project project { project_role_check = true has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" +} + +resource zitadel_project project_min { + depends_on = [zitadel_org.org] + + name = "projectname" + org_id = zitadel_org.org.id + private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } \ No newline at end of file diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 33ace401..2ee2a887 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,5 +1,13 @@ +resource zitadel_project_grant project_grant_full { + depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] -resource zitadel_project_grant project_grant { + org_id = zitadel_org.org.id + project_id = zitadel_project.project.id + granted_org_id = zitadel_org.grantedorg.id + role_keys = [zitadel_project_role.project_role.role_key] +} + +resource zitadel_project_grant project_grant_min { depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] org_id = zitadel_org.org.id diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf index 6033928e..9a37c614 100644 --- a/examples/provider/resources/smtp_config.tf +++ b/examples/provider/resources/smtp_config.tf @@ -1,8 +1,14 @@ -resource zitadel_smtp_config smtp { +resource zitadel_smtp_config smtp_full { sender_address = "address" sender_name = "no-reply" tls = true host = "localhost:25" user = "user" password = "password" +} + +resource zitadel_smtp_config smtp_min { + sender_address = "address" + sender_name = "no-reply" + host = "localhost:25" } \ No newline at end of file diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index ed5a21f8..8d2d0a24 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,8 +1,16 @@ -resource zitadel_user_grant user_grant { +resource zitadel_user_grant user_grant_full { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id +} + +resource zitadel_user_grant user_grant_min { + depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] + + project_id = zitadel_project.project.id + org_id = zitadel_org.org.id + user_id = zitadel_human_user.granted_human_user.id } \ No newline at end of file diff --git a/templates/resources/org_jwt_idp.md.tmpl b/templates/resources/org_idp_jwt.md.tmpl similarity index 82% rename from templates/resources/org_jwt_idp.md.tmpl rename to templates/resources/org_idp_jwt.md.tmpl index 944e1b63..aa06ec8c 100644 --- a/templates/resources/org_jwt_idp.md.tmpl +++ b/templates/resources/org_idp_jwt.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/resources/org_jwt_idp.tf" }} +{{ tffile "examples/provider/resources/org_idp_jwt.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/org_oidc_idp.md.tmpl b/templates/resources/org_idp_oidc.md.tmpl similarity index 82% rename from templates/resources/org_oidc_idp.md.tmpl rename to templates/resources/org_idp_oidc.md.tmpl index f5ef5f38..ac2b1616 100644 --- a/templates/resources/org_oidc_idp.md.tmpl +++ b/templates/resources/org_idp_oidc.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/resources/org_oidc_idp.tf" }} +{{ tffile "examples/provider/resources/org_idp_oidc.tf" }} {{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 2b945bd9..06b5cc53 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -14,14 +14,14 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_jwt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" @@ -49,8 +49,8 @@ func Provider() *schema.Provider { "zitadel_application_oidc": application_oidc.GetDatasource(), "zitadel_application_api": application_api.GetDatasource(), "zitadel_trigger_actions": trigger_actions.GetDatasource(), - "zitadel_org_jwt_idp": idp_jwt.GetDatasource(), - "zitadel_org_oidc_idp": idp_oidc.GetDatasource(), + "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -99,8 +99,8 @@ func Provider() *schema.Provider { "zitadel_trigger_actions": trigger_actions.GetResource(), "zitadel_personal_access_token": pat.GetResource(), "zitadel_machine_key": machine_key.GetResource(), - "zitadel_org_jwt_idp": idp_jwt.GetResource(), - "zitadel_org_oidc_idp": idp_oidc.GetResource(), + "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), + "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_sms_provider_twilio": sms_provider_twilio.GetResource(), "zitadel_smtp_config": smtp_config.GetResource(), }, diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go index 9ab2ac6b..0b2e4af8 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/v2/action/funcs.go @@ -123,7 +123,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read action: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/app_key/funcs.go index 89214062..4015b135 100644 --- a/zitadel/v2/app_key/funcs.go +++ b/zitadel/v2/app_key/funcs.go @@ -52,24 +52,29 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) + keyType := d.Get(keyTypeVar).(string) + req := &management.AddAppKeyRequest{ + ProjectId: d.Get(projectIDVar).(string), + AppId: d.Get(appIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), } - keyType := d.Get(keyTypeVar).(string) - resp, err := client.AddAppKey(ctx, &management.AddAppKeyRequest{ - ProjectId: d.Get(projectIDVar).(string), - AppId: d.Get(appIDVar).(string), - Type: authn.KeyType(authn.KeyType_value[keyType]), - ExpirationDate: timestamppb.New(t), - }) + if expiration, ok := d.GetOk(expirationDateVar); ok { + t, err := time.Parse(time.RFC3339, expiration.(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + req.ExpirationDate = timestamppb.New(t) + } + resp, err := client.AddAppKey(ctx, req) + if err != nil { + return diag.FromErr(err) + } d.SetId(resp.GetId()) if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { return diag.FromErr(err) } - return nil } diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index a840e04b..b497d489 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -34,7 +34,7 @@ func GetResource() *schema.Resource { keyTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the app key", + Description: "Type of the app key" + helper.DescriptionEnumValuesList(authn.KeyType_value), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index ea8a6326..ea2c7b3c 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -51,31 +51,34 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } projectID := d.Get(projectIDVar).(string) - appID := d.Id() - apiApp, err := getApp(ctx, client, projectID, appID) - - appName := d.Get(nameVar).(string) - if apiApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ - ProjectId: projectID, - AppId: d.Id(), - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) + apiApp, err := getApp(ctx, client, projectID, d.Id()) + + if d.HasChange(nameVar) { + appName := d.Get(nameVar).(string) + if apiApp.GetName() != appName { + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: d.Id(), + Name: appName, + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) + } } } - apiConfig := apiApp.GetApiConfig() - authMethod := d.Get(authMethodTypeVar).(string) - if apiConfig.GetAuthMethodType().String() != authMethod { - _, err = client.UpdateAPIAppConfig(ctx, &management.UpdateAPIAppConfigRequest{ - ProjectId: d.Get(projectIDVar).(string), - AppId: d.Id(), - AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[authMethod]), - }) - if err != nil { - return diag.Errorf("failed to update applicationAPI: %v", err) + if d.HasChanges(authMethodTypeVar) { + apiConfig := apiApp.GetApiConfig() + authMethod := d.Get(authMethodTypeVar).(string) + if apiConfig.GetAuthMethodType().String() != authMethod { + _, err = client.UpdateAPIAppConfig(ctx, &management.UpdateAPIAppConfigRequest{ + ProjectId: projectID, + AppId: d.Id(), + AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[authMethod]), + }) + if err != nil { + return diag.Errorf("failed to update applicationAPI: %v", err) + } } } return nil @@ -133,7 +136,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read api applicationAPI: %v", err) } api := app.GetApiConfig() diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index 91b5159d..bed39031 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -33,7 +33,7 @@ func GetResource() *schema.Resource { authMethodTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Auth method type", + Description: "Auth method type" + helper.DescriptionEnumValuesList(app.APIAuthMethodType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.APIAuthMethodType_value) }, diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index 968a1455..598ee1d9 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -53,81 +53,95 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - respTypes := make([]app.OIDCResponseType, 0) - for _, respType := range d.Get(responseTypesVar).([]interface{}) { - respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) - } - grantTypes := make([]app.OIDCGrantType, 0) - for _, grantType := range d.Get(grantTypesVar).([]interface{}) { - grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) - } - - dur, err := time.ParseDuration(d.Get(clockSkewVar).(string)) - if err != nil { - return diag.FromErr(err) - } - projectID := d.Get(projectIDVar).(string) - appID := d.Id() - oidcApp, err := getApp(ctx, client, projectID, appID) + oidcApp, err := getApp(ctx, client, projectID, d.Id()) if err != nil { return diag.FromErr(err) } - appName := d.Get(nameVar).(string) - if oidcApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ - ProjectId: projectID, - AppId: appID, - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) + if d.HasChange(nameVar) { + appName := d.Get(nameVar).(string) + if oidcApp.GetName() != appName { + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: d.Id(), + Name: appName, + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) + } } } - oidcConfig := oidcApp.GetOidcConfig() - redirecURIs := interfaceToStringSlice(d.Get(redirectURIsVar)) - appType := d.Get(appTypeVar).(string) - authMethodType := d.Get(authMethodTypeVar).(string) - postLogoutRedirectURIs := interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)) - devMode := d.Get(devModeVar).(bool) - accessTokenType := d.Get(accessTokenTypeVar).(string) - accessTokenRoleAssertion := d.Get(accessTokenRoleAssertionVar).(bool) - idTokenRoleAssertion := d.Get(idTokenRoleAssertionVar).(bool) - idTokenUserinfoAssertion := d.Get(idTokenUserinfoAssertionVar).(bool) - clockSkew := durationpb.New(dur) - additionalOrigins := interfaceToStringSlice(d.Get(additionalOriginsVar)) - if !reflect.DeepEqual(redirecURIs, oidcConfig.GetRedirectUris()) || - !reflect.DeepEqual(respTypes, oidcConfig.GetResponseTypes()) || - !reflect.DeepEqual(grantTypes, oidcConfig.GetGrantTypes()) || - appType != oidcConfig.AppType.String() || - authMethodType != oidcConfig.AuthMethodType.String() || - !reflect.DeepEqual(postLogoutRedirectURIs, oidcConfig.GetPostLogoutRedirectUris()) || - devMode != oidcConfig.DevMode || - accessTokenType != oidcConfig.AccessTokenType.String() || - accessTokenRoleAssertion != oidcConfig.AccessTokenRoleAssertion || - clockSkew.String() != oidcConfig.ClockSkew.String() || - !reflect.DeepEqual(additionalOrigins, oidcConfig.GetAdditionalOrigins()) { - _, err = client.UpdateOIDCAppConfig(ctx, &management.UpdateOIDCAppConfigRequest{ - ProjectId: projectID, - AppId: appID, - RedirectUris: redirecURIs, - ResponseTypes: respTypes, - GrantTypes: grantTypes, - AppType: app.OIDCAppType(app.OIDCAppType_value[appType]), - AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[authMethodType]), - PostLogoutRedirectUris: postLogoutRedirectURIs, - DevMode: devMode, - AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[accessTokenType]), - AccessTokenRoleAssertion: accessTokenRoleAssertion, - IdTokenRoleAssertion: idTokenRoleAssertion, - IdTokenUserinfoAssertion: idTokenUserinfoAssertion, - ClockSkew: clockSkew, - AdditionalOrigins: additionalOrigins, - }) + if d.HasChanges(redirectURIsVar, + appTypeVar, + authMethodTypeVar, + postLogoutRedirectURIsVar, + devModeVar, + accessTokenTypeVar, + accessTokenRoleAssertionVar, + idTokenRoleAssertionVar, + idTokenUserinfoAssertionVar, + clockSkewVar, + additionalOriginsVar, + ) { + respTypes := make([]app.OIDCResponseType, 0) + for _, respType := range d.Get(responseTypesVar).([]interface{}) { + respTypes = append(respTypes, app.OIDCResponseType(app.OIDCResponseType_value[respType.(string)])) + } + grantTypes := make([]app.OIDCGrantType, 0) + for _, grantType := range d.Get(grantTypesVar).([]interface{}) { + grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[grantType.(string)])) + } + dur, err := time.ParseDuration(d.Get(clockSkewVar).(string)) if err != nil { - return diag.Errorf("failed to update applicationOIDC: %v", err) + return diag.FromErr(err) + } + + oidcConfig := oidcApp.GetOidcConfig() + redirecURIs := interfaceToStringSlice(d.Get(redirectURIsVar)) + appType := d.Get(appTypeVar).(string) + authMethodType := d.Get(authMethodTypeVar).(string) + postLogoutRedirectURIs := interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)) + devMode := d.Get(devModeVar).(bool) + accessTokenType := d.Get(accessTokenTypeVar).(string) + accessTokenRoleAssertion := d.Get(accessTokenRoleAssertionVar).(bool) + idTokenRoleAssertion := d.Get(idTokenRoleAssertionVar).(bool) + idTokenUserinfoAssertion := d.Get(idTokenUserinfoAssertionVar).(bool) + clockSkew := durationpb.New(dur) + additionalOrigins := interfaceToStringSlice(d.Get(additionalOriginsVar)) + + if !reflect.DeepEqual(redirecURIs, oidcConfig.GetRedirectUris()) || + !reflect.DeepEqual(respTypes, oidcConfig.GetResponseTypes()) || + !reflect.DeepEqual(grantTypes, oidcConfig.GetGrantTypes()) || + appType != oidcConfig.AppType.String() || + authMethodType != oidcConfig.AuthMethodType.String() || + !reflect.DeepEqual(postLogoutRedirectURIs, oidcConfig.GetPostLogoutRedirectUris()) || + devMode != oidcConfig.DevMode || + accessTokenType != oidcConfig.AccessTokenType.String() || + accessTokenRoleAssertion != oidcConfig.AccessTokenRoleAssertion || + clockSkew.String() != oidcConfig.ClockSkew.String() || + !reflect.DeepEqual(additionalOrigins, oidcConfig.GetAdditionalOrigins()) { + + _, err = client.UpdateOIDCAppConfig(ctx, &management.UpdateOIDCAppConfigRequest{ + ProjectId: projectID, + AppId: d.Id(), + RedirectUris: redirecURIs, + ResponseTypes: respTypes, + GrantTypes: grantTypes, + AppType: app.OIDCAppType(app.OIDCAppType_value[appType]), + AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[authMethodType]), + PostLogoutRedirectUris: postLogoutRedirectURIs, + DevMode: devMode, + AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[accessTokenType]), + AccessTokenRoleAssertion: accessTokenRoleAssertion, + IdTokenRoleAssertion: idTokenRoleAssertion, + IdTokenUserinfoAssertion: idTokenUserinfoAssertion, + AdditionalOrigins: additionalOrigins, + }) + if err != nil { + return diag.Errorf("failed to update applicationOIDC: %v", err) + } } } return nil @@ -176,6 +190,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia IdTokenUserinfoAssertion: d.Get(idTokenUserinfoAssertionVar).(bool), ClockSkew: durationpb.New(dur), AdditionalOrigins: interfaceToStringSlice(d.Get(additionalOriginsVar)), + Version: app.OIDCVersion(app.OIDCVersion_value[d.Get(versionVar).(string)]), }) set := map[string]interface{}{ @@ -213,7 +228,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read application: %v", err) } oidc := oidcApp.GetOidcConfig() diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index d5968630..db3b1f92 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -44,7 +44,7 @@ func GetResource() *schema.Resource { Type: schema.TypeString, }, Required: true, - Description: "Response type", + Description: "Response type" + helper.DescriptionEnumValuesList(app.OIDCAppType_value), /* Not yet supported ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return enumValuesValidation(applicationAuthMethodTypeVar, value, app.OIDCResponseType_value) @@ -56,7 +56,7 @@ func GetResource() *schema.Resource { Type: schema.TypeString, }, Required: true, - Description: "Grant types", + Description: "Grant types" + helper.DescriptionEnumValuesList(app.OIDCGrantType_value), /* Not yet supported ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return enumValuesValidation(applicationGrantTypesVar, value, app.OIDCGrantType_value) @@ -65,7 +65,7 @@ func GetResource() *schema.Resource { appTypeVar: { Type: schema.TypeString, Optional: true, - Description: "App type", + Description: "App type" + helper.DescriptionEnumValuesList(app.OIDCAppType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(appTypeVar, value, app.OIDCAppType_value) }, @@ -74,7 +74,7 @@ func GetResource() *schema.Resource { authMethodTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Auth method type", + Description: "Auth method type" + helper.DescriptionEnumValuesList(app.OIDCAuthMethodType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.OIDCAuthMethodType_value) }, @@ -91,7 +91,8 @@ func GetResource() *schema.Resource { versionVar: { Type: schema.TypeString, Optional: true, - Description: "Version", + Description: "Version" + helper.DescriptionEnumValuesList(app.OIDCVersion_value), + Default: app.OIDCVersion_name[0], }, devModeVar: { Type: schema.TypeBool, @@ -101,7 +102,7 @@ func GetResource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Access token type", + Description: "Access token type" + helper.DescriptionEnumValuesList(app.OIDCTokenType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(accessTokenTypeVar, value, app.OIDCTokenType_value) }, @@ -124,8 +125,9 @@ func GetResource() *schema.Resource { }, clockSkewVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Clockskew", + Default: "0s", }, additionalOriginsVar: { Type: schema.TypeList, diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index 0d8e72a5..f030bb81 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -86,7 +86,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read domain: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 3d411a7d..9f3a730b 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -107,7 +107,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get domain policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index a389519b..c5fc3506 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -1,6 +1,8 @@ package helper import ( + "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -17,6 +19,16 @@ type Stringify interface { String() string } +func GetOkSetToStringSlice(d *schema.ResourceData, value string) []string { + var slice []string + if set, ok := d.GetOk(value); ok { + slice = SetToStringSlice(set.(*schema.Set)) + } else { + slice = make([]string, 0) + } + return slice +} + func SetToStringSlice(set *schema.Set) []string { slice := make([]string, 0) for _, secondFactor := range set.List() { @@ -94,3 +106,15 @@ func GetID(d *schema.ResourceData, idVar string) string { } return idStr } + +func DescriptionEnumValuesList(enum map[string]int32) string { + str := ", supported values: " + values := make([]string, len(enum)) + i := 0 + for k := range enum { + values[i] = k + i++ + } + str += strings.Join(values, ", ") + return str +} diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index b9e215e4..e9f7832a 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -52,68 +52,41 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia addUser := &management.AddHumanUserRequest{ UserName: d.Get(userNameVar).(string), Profile: &management.AddHumanUserRequest_Profile{ - FirstName: firstName, - LastName: lastName, + FirstName: firstName, + LastName: lastName, + Gender: user.Gender(user.Gender_value[d.Get(genderVar).(string)]), + PreferredLanguage: d.Get(preferredLanguageVar).(string), + NickName: d.Get(nickNameVar).(string), }, + InitialPassword: d.Get(initialPasswordVar).(string), } - nickname := d.Get(nickNameVar).(string) - if nickname != "" { - addUser.Profile.NickName = nickname - } - - displayname := d.Get(displayNameVar).(string) - if displayname != "" { - addUser.Profile.DisplayName = displayname + if displayname, ok := d.GetOk(displayNameVar); ok { + addUser.Profile.DisplayName = displayname.(string) } else { if err := d.Set(displayNameVar, defaultDisplayName(firstName, lastName)); err != nil { return diag.Errorf("failed to set default display name for human user: %v", err) } } - prefLang := d.Get(preferredLanguageVar).(string) - if prefLang != "" { - addUser.Profile.PreferredLanguage = prefLang - } else { - if err := d.Set(preferredLanguageVar, defaultPreferredLanguage); err != nil { - return diag.Errorf("failed to set default preferred language for human user: %v", err) - } - } - - gender := d.Get(genderVar).(string) - if gender != "" { - addUser.Profile.Gender = user.Gender(user.Gender_value[gender]) - } else { - if err := d.Set(genderVar, defaultGenderString); err != nil { - return diag.Errorf("failed to set default gender for human user: %v", err) - } - } - - pwd := d.Get(initialPasswordVar).(string) - if pwd != "" { - addUser.InitialPassword = pwd - } - - email := d.Get(emailVar).(string) - if email != "" { - isVerified := d.Get(isEmailVerifiedVar) + if email, ok := d.GetOk(emailVar); ok { + isVerified, isVerifiedOk := d.GetOk(isEmailVerifiedVar) addUser.Email = &management.AddHumanUserRequest_Email{ - Email: email, + Email: email.(string), IsEmailVerified: false, } - if isVerified != nil { + if isVerifiedOk { addUser.Email.IsEmailVerified = isVerified.(bool) } } - phone := d.Get(phoneVar).(string) - if phone != "" { - isVerified := d.Get(isPhoneVerifiedVar) + if phone, ok := d.GetOk(phoneVar); ok { + isVerified, isVerifiedOk := d.GetOk(isPhoneVerifiedVar) addUser.Phone = &management.AddHumanUserRequest_Phone{ - Phone: phone, + Phone: phone.(string), IsPhoneVerified: false, } - if isVerified != nil { + if isVerifiedOk { addUser.Phone.IsPhoneVerified = isVerified.(bool) } } @@ -145,67 +118,75 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - username := d.Get(userNameVar).(string) - if currentUser.GetUser().GetUserName() != username { - _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ - UserId: d.Id(), - UserName: username, - }) - if err != nil { - return diag.Errorf("failed to update username: %v", err) + if d.HasChange(userNameVar) { + username := d.Get(userNameVar).(string) + if currentUser.GetUser().GetUserName() != username { + _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ + UserId: d.Id(), + UserName: username, + }) + if err != nil { + return diag.Errorf("failed to update username: %v", err) + } } } - nickname := d.Get(nickNameVar) - displayname := d.Get(displayNameVar) - prefLang := d.Get(preferredLanguageVar) - gender := d.Get(genderVar) - email := d.Get(emailVar) - emailVerfied := d.Get(isEmailVerifiedVar) - phone := d.Get(phoneVar) - phoneVerified := d.Get(isPhoneVerifiedVar) - currentHuman := currentUser.GetUser().GetHuman() - if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || - currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || - (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || - (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || - (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || - (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { - - _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ - UserId: d.Id(), - FirstName: d.Get(firstNameVar).(string), - LastName: d.Get(lastNameVar).(string), - NickName: d.Get(nickNameVar).(string), - DisplayName: d.Get(displayNameVar).(string), - PreferredLanguage: d.Get(preferredLanguageVar).(string), - Gender: user.Gender(user.Gender_value[gender.(string)]), - }) - if err != nil { - return diag.Errorf("failed to update human profile: %v", err) + if d.HasChanges(firstNameVar, lastNameVar, nickNameVar, displayNameVar, preferredLanguageVar, genderVar) { + nickname := d.Get(nickNameVar) + displayname := d.Get(displayNameVar) + prefLang := d.Get(preferredLanguageVar) + gender := d.Get(genderVar) + + if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || + currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || + (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || + (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || + (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || + (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { + + _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ + UserId: d.Id(), + FirstName: d.Get(firstNameVar).(string), + LastName: d.Get(lastNameVar).(string), + NickName: d.Get(nickNameVar).(string), + DisplayName: d.Get(displayNameVar).(string), + PreferredLanguage: d.Get(preferredLanguageVar).(string), + Gender: user.Gender(user.Gender_value[gender.(string)]), + }) + if err != nil { + return diag.Errorf("failed to update human profile: %v", err) + } } } - if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { - _, err = client.UpdateHumanEmail(ctx, &management.UpdateHumanEmailRequest{ - UserId: d.Id(), - Email: email.(string), - IsEmailVerified: emailVerfied.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human email: %v", err) + if d.HasChanges(emailVar, isEmailVerifiedVar) { + email := d.Get(emailVar) + emailVerfied := d.Get(isEmailVerifiedVar) + if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { + _, err = client.UpdateHumanEmail(ctx, &management.UpdateHumanEmailRequest{ + UserId: d.Id(), + Email: email.(string), + IsEmailVerified: emailVerfied.(bool), + }) + if err != nil { + return diag.Errorf("failed to update human email: %v", err) + } } } - if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { - _, err = client.UpdateHumanPhone(ctx, &management.UpdateHumanPhoneRequest{ - UserId: d.Id(), - Phone: phone.(string), - IsPhoneVerified: phoneVerified.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human phone: %v", err) + if d.HasChanges(phoneVar, isPhoneVerifiedVar) { + phone := d.Get(phoneVar) + phoneVerified := d.Get(isPhoneVerifiedVar) + if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { + _, err = client.UpdateHumanPhone(ctx, &management.UpdateHumanPhoneRequest{ + UserId: d.Id(), + Phone: phone.(string), + IsPhoneVerified: phoneVerified.(bool), + }) + if err != nil { + return diag.Errorf("failed to update human phone: %v", err) + } } } return nil @@ -228,7 +209,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get list of users: %v", err) } user := respUser.GetUser() diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index 33b53730..d2f2e2a7 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -77,16 +77,16 @@ func GetResource() *schema.Resource { Type: schema.TypeString, Optional: true, Description: "Preferred language of the user", - Computed: true, + Default: defaultPreferredLanguage, }, genderVar: { Type: schema.TypeString, Optional: true, - Description: "Gender of the user", - Computed: true, + Description: "Gender of the user" + helper.DescriptionEnumValuesList(user.Gender_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(genderVar, value.(string), user.Gender_value) }, + Default: defaultGenderString, }, emailVar: { Type: schema.TypeString, @@ -113,6 +113,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "Initially set password for the user, not changeable after creation", Sensitive: true, + ForceNew: true, }, }, ReadContext: read, diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index eec12dcc..201f2d9b 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -136,7 +136,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get domain policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go index 62ecd6c5..759f8baa 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/v2/lockout_policy/funcs.go @@ -98,7 +98,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get lockout policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index eb045262..f548999c 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -55,131 +55,156 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) - allowRegister := d.Get(allowRegisterVar).(bool) - allowExternalIdp := d.Get(allowExternalIDPVar).(bool) - forceMfa := d.Get(forceMFAVar).(bool) - passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) - hidePasswordReset := d.Get(hidePasswordResetVar).(bool) - ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) - defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) - currentPolicy := current.GetPolicy() - if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || - currentPolicy.GetAllowRegister() != allowRegister || - currentPolicy.GetAllowExternalIdp() != allowExternalIdp || - currentPolicy.GetForceMfa() != forceMfa || - currentPolicy.GetPasswordlessType() != passwordlessType || - currentPolicy.GetHidePasswordReset() != hidePasswordReset || - currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || - currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { - - _, err = client.UpdateCustomLoginPolicy(ctx, &management.UpdateCustomLoginPolicyRequest{ - AllowUsernamePassword: allowUsernamePassword, - AllowRegister: allowRegister, - AllowExternalIdp: allowExternalIdp, - ForceMfa: forceMfa, - PasswordlessType: passwordlessType, - HidePasswordReset: hidePasswordReset, - IgnoreUnknownUsernames: ignoreUnkownUsernames, - DefaultRedirectUri: defaultRedirectUri, - PasswordCheckLifetime: durationpb.New(passwordCheckLT), - ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), - MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), - SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), - MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), - }) + d.SetId(org) + if d.HasChanges( + allowUsernamePasswordVar, + allowRegisterVar, + allowExternalIDPVar, + forceMFAVar, + passwordlessTypeVar, + hidePasswordResetVar, + ignoreUnknownUsernamesVar, + defaultRedirectURIVar, + passwordCheckLifetimeVar, + externalLoginCheckLifetimeVar, + mfaInitSkipLifetimeVar, + secondFactorCheckLifetimeVar, + multiFactorCheckLifetimeVar, + ) { + passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) if err != nil { - return diag.Errorf("failed to update login policy: %v", err) + return diag.FromErr(err) } - } - d.SetId(org) - - secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) - currentSecondFactors := make([]helper.Stringify, 0) - for _, secondFactor := range current.GetPolicy().GetSecondFactors() { - currentSecondFactors = append(currentSecondFactors, secondFactor) - } - addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) - - for _, factor := range addSecondFactor { - if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management.AddSecondFactorToLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { + externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) + if err != nil { return diag.FromErr(err) } - } - for _, factor := range deleteSecondFactors { - if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &management.RemoveSecondFactorFromLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { + mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) + if err != nil { return diag.FromErr(err) } - } - - multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) - currentMultiFactors := make([]helper.Stringify, 0) - for _, multiFactor := range current.GetPolicy().GetMultiFactors() { - currentMultiFactors = append(currentMultiFactors, multiFactor) - } - addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) - for _, factor := range addMultiFactor { - if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management.AddMultiFactorToLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { + secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) + if err != nil { return diag.FromErr(err) } - } - for _, factor := range deleteMultiFactors { - if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &management.RemoveMultiFactorFromLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { + multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) + if err != nil { return diag.FromErr(err) } + + allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) + allowRegister := d.Get(allowRegisterVar).(bool) + allowExternalIdp := d.Get(allowExternalIDPVar).(bool) + forceMfa := d.Get(forceMFAVar).(bool) + passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) + hidePasswordReset := d.Get(hidePasswordResetVar).(bool) + ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) + defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) + currentPolicy := current.GetPolicy() + + if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || + currentPolicy.GetAllowRegister() != allowRegister || + currentPolicy.GetAllowExternalIdp() != allowExternalIdp || + currentPolicy.GetForceMfa() != forceMfa || + currentPolicy.GetPasswordlessType() != passwordlessType || + currentPolicy.GetHidePasswordReset() != hidePasswordReset || + currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || + currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { + + _, err = client.UpdateCustomLoginPolicy(ctx, &management.UpdateCustomLoginPolicyRequest{ + AllowUsernamePassword: allowUsernamePassword, + AllowRegister: allowRegister, + AllowExternalIdp: allowExternalIdp, + ForceMfa: forceMfa, + PasswordlessType: passwordlessType, + HidePasswordReset: hidePasswordReset, + IgnoreUnknownUsernames: ignoreUnkownUsernames, + DefaultRedirectUri: defaultRedirectUri, + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + }) + if err != nil { + return diag.Errorf("failed to update login policy: %v", err) + } + } } - idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) - currentIdps := make([]helper.Stringify, 0) - for _, currentIdp := range current.GetPolicy().GetIdps() { - currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) + if d.HasChange(secondFactorsVar) { + secondFactors := helper.GetOkSetToStringSlice(d, secondFactorsVar) + currentSecondFactors := make([]helper.Stringify, 0) + + for _, secondFactor := range current.GetPolicy().GetSecondFactors() { + currentSecondFactors = append(currentSecondFactors, secondFactor) + } + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + + for _, factor := range addSecondFactor { + if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management.AddSecondFactorToLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteSecondFactors { + if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &management.RemoveSecondFactorFromLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } } - addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) - for _, addIdp := range addIdps { - var ownertype idp.IDPOwnerType - _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) - if err != nil { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM - } else { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + + if d.HasChange(multiFactorsVar) { + multiFactors := helper.GetOkSetToStringSlice(d, multiFactorsVar) + currentMultiFactors := make([]helper.Stringify, 0) + + for _, multiFactor := range current.GetPolicy().GetMultiFactors() { + currentMultiFactors = append(currentMultiFactors, multiFactor) } - if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { - return diag.FromErr(err) + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) + for _, factor := range addMultiFactor { + if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management.AddMultiFactorToLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteMultiFactors { + if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &management.RemoveMultiFactorFromLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } } } - for _, deleteIdp := range deleteIdps { - if _, err := client.RemoveIDPFromLoginPolicy(ctx, &management.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { - return diag.FromErr(err) + + if d.HasChange(idpsVar) { + idps := helper.GetOkSetToStringSlice(d, idpsVar) + currentIdps := make([]helper.Stringify, 0) + + for _, currentIdp := range current.GetPolicy().GetIdps() { + currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) + } + addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) + for _, addIdp := range addIdps { + var ownertype idp.IDPOwnerType + _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) + if err != nil { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM + } else { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + } + if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + return diag.FromErr(err) + } + } + for _, deleteIdp := range deleteIdps { + if _, err := client.RemoveIDPFromLoginPolicy(ctx, &management.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { + return diag.FromErr(err) + } } } @@ -220,15 +245,18 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + secondFactors := make([]policy.SecondFactorType, 0) - secondFactorsSet := d.Get(secondFactorsVar).(*schema.Set) - for _, factor := range secondFactorsSet.List() { - secondFactors = append(secondFactors, policy.SecondFactorType(policy.SecondFactorType_value[factor.(string)])) + if secondFactorsSet, ok := d.GetOk(secondFactorsVar); ok { + for _, factor := range secondFactorsSet.(*schema.Set).List() { + secondFactors = append(secondFactors, policy.SecondFactorType(policy.SecondFactorType_value[factor.(string)])) + } } multiFactors := make([]policy.MultiFactorType, 0) - multiFactorsSet := d.Get(multiFactorsVar).(*schema.Set) - for _, factor := range multiFactorsSet.List() { - multiFactors = append(multiFactors, policy.MultiFactorType(policy.MultiFactorType_value[factor.(string)])) + if multiFactorsSet, ok := d.GetOk(multiFactorsVar); ok { + for _, factor := range multiFactorsSet.(*schema.Set).List() { + multiFactors = append(multiFactors, policy.MultiFactorType(policy.MultiFactorType_value[factor.(string)])) + } } _, err = client.AddCustomLoginPolicy(ctx, &management.AddCustomLoginPolicyRequest{ @@ -252,6 +280,20 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to create login policy: %v", err) } d.SetId(org) + + idps := helper.GetOkSetToStringSlice(d, idpsVar) + for _, addIdp := range idps { + var ownertype idp.IDPOwnerType + _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) + if err != nil { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM + } else { + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + } + if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + return diag.FromErr(err) + } + } return nil } @@ -273,7 +315,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get login policy: %v", err) } policy := resp.Policy @@ -296,6 +337,42 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn multiFactorCheckLifetimeVar: policy.GetMultiFactorCheckLifetime().AsDuration().String(), } + respSecond, err := client.ListLoginPolicySecondFactors(ctx, &management.ListLoginPolicySecondFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy secondfactors: %v", err) + } + if len(respSecond.GetResult()) > 0 { + factors := make([]string, 0) + for _, item := range respSecond.GetResult() { + factors = append(factors, item.String()) + } + set[secondFactorsVar] = factors + } + + respMulti, err := client.ListLoginPolicyMultiFactors(ctx, &management.ListLoginPolicyMultiFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy multifactors: %v", err) + } + if len(respMulti.GetResult()) > 0 { + factors := make([]string, 0) + for _, item := range respMulti.GetResult() { + factors = append(factors, item.String()) + } + set[multiFactorsVar] = factors + } + + respIDPs, err := client.ListLoginPolicyIDPs(ctx, &management.ListLoginPolicyIDPsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy idps: %v", err) + } + if len(respIDPs.GetResult()) > 0 { + idps := make([]string, 0) + for _, idpItem := range respIDPs.GetResult() { + idps = append(idps, idpItem.IdpId) + } + set[idpsVar] = idps + } + for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of login policy: %v", k, err) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index 9482127e..702c0b2d 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -84,7 +84,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed second factors", }, multiFactorsVar: { @@ -92,7 +92,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed multi factors", }, idpsVar: { @@ -100,7 +100,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed idps to login or register", }, }, diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go index 9c38e1be..6c063a78 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/v2/machine_key/funcs.go @@ -51,23 +51,28 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) + keyType := d.Get(keyTypeVar).(string) + req := &management.AddMachineKeyRequest{ + UserId: d.Get(userIDVar).(string), + Type: authn.KeyType(authn.KeyType_value[keyType]), } - keyType := d.Get(keyTypeVar).(string) - resp, err := client.AddMachineKey(ctx, &management.AddMachineKeyRequest{ - UserId: d.Get(userIDVar).(string), - Type: authn.KeyType(authn.KeyType_value[keyType]), - ExpirationDate: timestamppb.New(t), - }) - d.SetId(resp.GetKeyId()) + if expiration, ok := d.GetOk(expirationDateVar); ok { + t, err := time.Parse(time.RFC3339, expiration.(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + req.ExpirationDate = timestamppb.New(t) + } + resp, err := client.AddMachineKey(ctx, req) + if err != nil { + return diag.FromErr(err) + } + d.SetId(resp.GetKeyId()) if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { return diag.FromErr(err) } - return nil } diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index c0c56090..2df251cc 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -28,7 +28,7 @@ func GetResource() *schema.Resource { keyTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the machine key", + Description: "Type of the machine key" + helper.DescriptionEnumValuesList(authn.KeyType_value), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) @@ -36,9 +36,10 @@ func GetResource() *schema.Resource { }, expirationDateVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Expiration date of the machine key", ForceNew: true, + Computed: true, }, keyDetailsVar: { Type: schema.TypeString, diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 66a6e4b9..1da37f94 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -119,7 +119,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get list of users: %v", err) } user := respUser.GetUser() diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 1ffd3ab9..ac397cc2 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -41,7 +41,6 @@ func GetResource() *schema.Resource { Computed: true, Description: "Preferred login name", }, - nameVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/idp_jwt/const.go b/zitadel/v2/org_idp_jwt/const.go similarity index 93% rename from zitadel/v2/idp_jwt/const.go rename to zitadel/v2/org_idp_jwt/const.go index daa64cbd..60ec8116 100644 --- a/zitadel/v2/idp_jwt/const.go +++ b/zitadel/v2/org_idp_jwt/const.go @@ -1,4 +1,4 @@ -package idp_jwt +package org_idp_jwt const ( idpIDVar = "idp_id" diff --git a/zitadel/v2/idp_jwt/datasource.go b/zitadel/v2/org_idp_jwt/datasource.go similarity index 98% rename from zitadel/v2/idp_jwt/datasource.go rename to zitadel/v2/org_idp_jwt/datasource.go index 261a4489..5c2993b2 100644 --- a/zitadel/v2/idp_jwt/datasource.go +++ b/zitadel/v2/org_idp_jwt/datasource.go @@ -1,4 +1,4 @@ -package idp_jwt +package org_idp_jwt import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/idp_jwt/funcs.go b/zitadel/v2/org_idp_jwt/funcs.go similarity index 70% rename from zitadel/v2/idp_jwt/funcs.go rename to zitadel/v2/org_idp_jwt/funcs.go index 75f93e24..994c4042 100644 --- a/zitadel/v2/idp_jwt/funcs.go +++ b/zitadel/v2/org_idp_jwt/funcs.go @@ -1,4 +1,4 @@ -package idp_jwt +package org_idp_jwt import ( "context" @@ -81,46 +81,49 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to read jwt idp: %v", err) } - - idpID := d.Id() - name := d.Get(nameVar).(string) - stylingType := d.Get(stylingTypeVar).(string) - autoRegister := d.Get(autoRegisterVar).(bool) - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ - IdpId: idpID, - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp: %v", err) + d.SetId(resp.GetIdp().GetId()) + + if d.HasChanges(nameVar, stylingTypeVar, autoRegisterVar) { + name := d.Get(nameVar).(string) + stylingType := d.Get(stylingTypeVar).(string) + autoRegister := d.Get(autoRegisterVar).(bool) + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: d.Id(), + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp: %v", err) + } } } - jwt := resp.GetIdp().GetJwtConfig() - jwtEndpoint := d.Get(jwtEndpointVar).(string) - issuer := d.Get(issuerVar).(string) - keysEndpoint := d.Get(keysEndpointVar).(string) - headerName := d.Get(headerNameVar).(string) - - //either nothing changed on the IDP or something besides the secret changed - if jwt.GetJwtEndpoint() != jwtEndpoint || - jwt.GetIssuer() != issuer || - jwt.GetKeysEndpoint() != keysEndpoint || - jwt.GetHeaderName() != headerName { - - _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ - IdpId: idpID, - JwtEndpoint: jwtEndpoint, - Issuer: issuer, - KeysEndpoint: keysEndpoint, - HeaderName: headerName, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp config: %v", err) + if d.HasChanges(jwtEndpointVar, issuerVar, keysEndpointVar, headerNameVar) { + jwt := resp.GetIdp().GetJwtConfig() + jwtEndpoint := d.Get(jwtEndpointVar).(string) + issuer := d.Get(issuerVar).(string) + keysEndpoint := d.Get(keysEndpointVar).(string) + headerName := d.Get(headerNameVar).(string) + + if jwt.GetJwtEndpoint() != jwtEndpoint || + jwt.GetIssuer() != issuer || + jwt.GetKeysEndpoint() != keysEndpoint || + jwt.GetHeaderName() != headerName { + + _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ + IdpId: d.Id(), + JwtEndpoint: jwtEndpoint, + Issuer: issuer, + KeysEndpoint: keysEndpoint, + HeaderName: headerName, + }) + if err != nil { + return diag.Errorf("failed to update jwt idp config: %v", err) + } } } return nil @@ -143,7 +146,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read jwt idp: %v", err) } idp := resp.GetIdp() diff --git a/zitadel/v2/idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go similarity index 94% rename from zitadel/v2/idp_jwt/resource.go rename to zitadel/v2/org_idp_jwt/resource.go index f116f618..c8a00ae7 100644 --- a/zitadel/v2/idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -1,4 +1,4 @@ -package idp_jwt +package org_idp_jwt import ( "github.com/hashicorp/go-cty/cty" @@ -27,7 +27,7 @@ func GetResource() *schema.Resource { stylingTypeVar: { Type: schema.TypeString, Required: true, - Description: "Some identity providers specify the styling of the button to their login", + Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) }, diff --git a/zitadel/v2/idp_oidc/const.go b/zitadel/v2/org_idp_oidc/const.go similarity index 95% rename from zitadel/v2/idp_oidc/const.go rename to zitadel/v2/org_idp_oidc/const.go index 46939473..f30fc8d3 100644 --- a/zitadel/v2/idp_oidc/const.go +++ b/zitadel/v2/org_idp_oidc/const.go @@ -1,4 +1,4 @@ -package idp_oidc +package org_idp_oidc const ( idpIDVar = "idp_id" diff --git a/zitadel/v2/idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go similarity index 99% rename from zitadel/v2/idp_oidc/datasource.go rename to zitadel/v2/org_idp_oidc/datasource.go index 6fe5cedc..d0b61ea9 100644 --- a/zitadel/v2/idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -1,4 +1,4 @@ -package idp_oidc +package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/zitadel/v2/idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go similarity index 64% rename from zitadel/v2/idp_oidc/funcs.go rename to zitadel/v2/org_idp_oidc/funcs.go index 60256993..b8207409 100644 --- a/zitadel/v2/idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -1,4 +1,4 @@ -package idp_oidc +package org_idp_oidc import ( "context" @@ -48,12 +48,6 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - scopes := make([]string, 0) - scopesSet := d.Get(scopesVar).(*schema.Set) - for _, scope := range scopesSet.List() { - scopes = append(scopes, scope.(string)) - } - stylingType := d.Get(stylingTypeVar) displayNameMapping := d.Get(displayNameMappingVar).(string) usernameMapping := d.Get(usernameMappingVar).(string) @@ -63,7 +57,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientId: d.Get(clientIDVar).(string), ClientSecret: d.Get(clientSecretVar).(string), Issuer: d.Get(issuerVar).(string), - Scopes: scopes, + Scopes: helper.GetOkSetToStringSlice(d, scopesVar), DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), AutoRegister: d.Get(autoRegisterVar).(bool), @@ -93,62 +87,55 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to read oidc idp: %v", err) } - - idpID := d.Id() - name := d.Get(nameVar).(string) - stylingType := d.Get(stylingTypeVar).(string) - autoRegister := d.Get(autoRegisterVar).(bool) - changed := false - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - changed = true - _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ - IdpId: idpID, - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update oidc idp: %v", err) + d.SetId(resp.GetIdp().GetId()) + + if d.HasChanges(nameVar, stylingTypeVar, autoRegisterVar) { + name := d.Get(nameVar).(string) + stylingType := d.Get(stylingTypeVar).(string) + autoRegister := d.Get(autoRegisterVar).(bool) + if resp.GetIdp().GetName() != name || + resp.GetIdp().GetStylingType().String() != stylingType || + resp.GetIdp().GetAutoRegister() != autoRegister { + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: d.Id(), + Name: name, + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), + AutoRegister: autoRegister, + }) + if err != nil { + return diag.Errorf("failed to update oidc idp: %v", err) + } } } - oidc := resp.GetIdp().GetOidcConfig() - clientID := d.Get(clientIDVar).(string) - clientSecret := d.Get(clientSecretVar).(string) - issuer := d.Get(issuerVar).(string) - scopesSet := d.Get(scopesVar).(*schema.Set) - displayNameMapping := d.Get(displayNameMappingVar).(string) - usernameMapping := d.Get(usernameMappingVar).(string) - - scopes := make([]string, 0) - for _, scope := range scopesSet.List() { - scopes = append(scopes, scope.(string)) - } - - //either nothing changed on the IDP or something besides the secret changed - if (oidc.GetClientId() != clientID || - oidc.GetIssuer() != issuer || - !reflect.DeepEqual(oidc.GetScopes(), scopes) || - oidc.GetDisplayNameMapping().String() != displayNameMapping || - oidc.GetUsernameMapping().String() != usernameMapping) || - !changed { - - _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ - IdpId: idpID, - ClientId: clientID, - ClientSecret: clientSecret, - Issuer: issuer, - Scopes: scopes, - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), - }) - if err != nil { - return diag.Errorf("failed to update oidc idp config: %v", err) + if d.HasChanges(clientIDVar, clientSecretVar, issuerVar, displayNameMappingVar, usernameMappingVar, scopesVar) { + oidc := resp.GetIdp().GetOidcConfig() + clientID := d.Get(clientIDVar).(string) + clientSecret := d.Get(clientSecretVar).(string) + issuer := d.Get(issuerVar).(string) + displayNameMapping := d.Get(displayNameMappingVar).(string) + usernameMapping := d.Get(usernameMappingVar).(string) + scopes := helper.GetOkSetToStringSlice(d, scopesVar) + + if oidc.GetClientId() != clientID || + oidc.GetIssuer() != issuer || + !reflect.DeepEqual(oidc.GetScopes(), scopes) || + oidc.GetDisplayNameMapping().String() != displayNameMapping || + oidc.GetUsernameMapping().String() != usernameMapping { + _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ + IdpId: d.Id(), + ClientId: clientID, + ClientSecret: clientSecret, + Issuer: issuer, + Scopes: scopes, + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + }) + if err != nil { + return diag.Errorf("failed to update oidc idp config: %v", err) + } } } - d.SetId(idpID) return nil } @@ -169,7 +156,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read oidc idp: %v", err) } idp := resp.GetIdp() diff --git a/zitadel/v2/idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go similarity index 95% rename from zitadel/v2/idp_oidc/resource.go rename to zitadel/v2/org_idp_oidc/resource.go index c62d9941..19358fc8 100644 --- a/zitadel/v2/idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -1,4 +1,4 @@ -package idp_oidc +package org_idp_oidc import ( "github.com/hashicorp/go-cty/cty" @@ -27,7 +27,7 @@ func GetResource() *schema.Resource { stylingTypeVar: { Type: schema.TypeString, Required: true, - Description: "Some identity providers specify the styling of the button to their login", + Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) }, diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index 4803a0f2..3e8eb4bd 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -48,14 +48,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - roles := make([]string, 0) - for _, role := range d.Get(rolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - _, err = client.UpdateOrgMember(ctx, &management.UpdateOrgMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: roles, + Roles: helper.GetOkSetToStringSlice(d, rolesVar), }) if err != nil { return diag.Errorf("failed to update orgmember: %v", err) @@ -78,14 +73,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } userID := d.Get(userIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(rolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - _, err = client.AddOrgMember(ctx, &management.AddOrgMemberRequest{ UserId: userID, - Roles: roles, + Roles: helper.GetOkSetToStringSlice(d, rolesVar), }) if err != nil { return diag.Errorf("failed to create orgmember: %v", err) @@ -120,7 +110,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read orgmember: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go index d67cc0bc..cbe7e01e 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -106,7 +106,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get password complexity policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go index 635eaadf..9107039c 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/v2/pat/funcs.go @@ -50,15 +50,21 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - t, err := time.Parse(time.RFC3339, d.Get(expirationDateVar).(string)) - if err != nil { - return diag.Errorf("failed to parse time: %v", err) + req := &management.AddPersonalAccessTokenRequest{ + UserId: d.Get(userIDVar).(string), + } + if expiration, ok := d.GetOk(expirationDateVar); ok { + t, err := time.Parse(time.RFC3339, expiration.(string)) + if err != nil { + return diag.Errorf("failed to parse time: %v", err) + } + req.ExpirationDate = timestamppb.New(t) } - resp, err := client.AddPersonalAccessToken(ctx, &management.AddPersonalAccessTokenRequest{ - UserId: d.Get(userIDVar).(string), - ExpirationDate: timestamppb.New(t), - }) + resp, err := client.AddPersonalAccessToken(ctx, req) + if err != nil { + return diag.FromErr(err) + } if err := d.Set(tokenVar, resp.GetToken()); err != nil { return diag.FromErr(err) diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index 8b22d8cd..3d1deede 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -28,7 +28,7 @@ func GetResource() *schema.Resource { }, expirationDateVar: { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Expiration date of the token", ForceNew: true, }, diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index ec539a5e..671455d4 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -102,7 +102,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get privacy policy: %v", err) } policy := resp.Policy diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go index 4cf43d45..652819eb 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/v2/project/funcs.go @@ -108,7 +108,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read project: %v", err) } project := resp.GetProject() diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index 53062fa8..b3fb1392 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -50,7 +50,7 @@ func GetResource() *schema.Resource { privateLabelingSettingVar: { Type: schema.TypeString, Optional: true, - Description: "Defines from where the private labeling should be triggered", + Description: "Defines from where the private labeling should be triggered" + helper.DescriptionEnumValuesList(project.PrivateLabelingSetting_value), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(privateLabelingSettingVar, value, project.PrivateLabelingSetting_value) }, diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go index d77aabc5..9760e9a7 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/v2/project_grant/funcs.go @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectGrant(ctx, &management.UpdateProjectGrantRequest{ GrantId: d.Id(), ProjectId: d.Get(projectIDVar).(string), - RoleKeys: d.Get(roleKeysVar).([]string), + RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), }) if err != nil { return diag.Errorf("failed to update projectgrant: %v", err) @@ -71,15 +71,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - roles := make([]string, 0) - for _, role := range d.Get(roleKeysVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - resp, err := client.AddProjectGrant(ctx, &management.AddProjectGrantRequest{ GrantedOrgId: d.Get(grantedOrgIDVar).(string), ProjectId: d.Get(projectIDVar).(string), - RoleKeys: roles, + RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), }) if err != nil { return diag.Errorf("failed to create projectgrant: %v", err) @@ -105,7 +100,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read projectgrant: %v", err) } projectGrant := resp.GetProjectGrant() diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index c4875368..d0bd3741 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -51,7 +51,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectGrantMember(ctx, &management.UpdateProjectGrantMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: d.Get(rolesVar).([]string), + Roles: helper.GetOkSetToStringSlice(d, rolesVar), ProjectId: d.Get(projectIDVar).(string), GrantId: d.Get(grantIDVar).(string), }) @@ -78,15 +78,11 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia userID := d.Get(userIDVar).(string) projectID := d.Get(projectIDVar).(string) grantID := d.Get(grantIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(rolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } _, err = client.AddProjectGrantMember(ctx, &management.AddProjectGrantMemberRequest{ UserId: userID, ProjectId: projectID, GrantId: grantID, - Roles: roles, + Roles: helper.GetOkSetToStringSlice(d, rolesVar), }) if err != nil { return diag.Errorf("failed to create projectgrantmember: %v", err) @@ -125,7 +121,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read projectgrantmember: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go index 901f9de2..82c2f04b 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/v2/project_member/funcs.go @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectMember(ctx, &management.UpdateProjectMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: d.Get(rolesVar).([]string), + Roles: helper.GetOkSetToStringSlice(d, rolesVar), ProjectId: d.Get(projectIDVar).(string), }) if err != nil { @@ -75,15 +75,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia userID := d.Get(userIDVar).(string) projectID := d.Get(projectIDVar).(string) - roles := make([]string, 0) - for _, role := range d.Get(rolesVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - _, err = client.AddProjectMember(ctx, &management.AddProjectMemberRequest{ UserId: userID, ProjectId: projectID, - Roles: roles, + Roles: helper.GetOkSetToStringSlice(d, rolesVar), }) if err != nil { return diag.Errorf("failed to create projectmember: %v", err) @@ -120,7 +115,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read projectmember: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/v2/project_role/funcs.go index 06e8446d..f7e7bd56 100644 --- a/zitadel/v2/project_role/funcs.go +++ b/zitadel/v2/project_role/funcs.go @@ -121,7 +121,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil || resp.Result == nil || len(resp.Result) == 0 { d.SetId("") return nil - //return diag.Errorf("failed to read project role: %v", err) } if len(resp.Result) == 1 { diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index 3178401f..403b832e 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -44,22 +44,13 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - tls, tlsOk := d.GetOk(tlsVar) - user, userOk := d.GetOk(userVar) - password, pwOk := d.GetOk(passwordVar) req := &admin.AddSMTPConfigRequest{ SenderAddress: d.Get(senderAddressVar).(string), SenderName: d.Get(senderNameVar).(string), Host: d.Get(hostVar).(string), - } - if tlsOk { - req.Tls = tls.(bool) - } - if userOk { - req.User = user.(string) - } - if pwOk { - req.Password = password.(string) + User: d.Get(userVar).(string), + Tls: d.Get(tlsVar).(bool), + Password: d.Get(passwordVar).(string), } resp, err := client.AddSMTPConfig(ctx, req) @@ -92,9 +83,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia senderAddress := d.Get(senderAddressVar).(string) senderName := d.Get(senderNameVar).(string) - tls, tlsOk := d.GetOk(tlsVar) + tls := d.Get(tlsVar).(bool) host := d.Get(hostVar).(string) - user, userOk := d.GetOk(userVar) + user := d.Get(userVar).(string) if smtp.SmtpConfig.SenderName != senderName || smtp.SmtpConfig.SenderAddress != senderAddress || @@ -106,14 +97,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia SenderAddress: senderAddress, SenderName: senderName, Host: host, + Tls: tls, + User: user, } - if tlsOk { - req.Tls = tls.(bool) - } - if userOk { - req.User = user.(string) - } - _, err = client.UpdateSMTPConfig(ctx, req) if err != nil { return diag.Errorf("failed to update smtp config: %v", err) @@ -122,12 +108,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(passwordVar) { - password, pwOk := d.GetOk(passwordVar) - req := &admin.UpdateSMTPConfigPasswordRequest{} - if pwOk { - req.Password = password.(string) - } - _, err = client.UpdateSMTPConfigPassword(ctx, req) + _, err = client.UpdateSMTPConfigPassword(ctx, &admin.UpdateSMTPConfigPasswordRequest{ + Password: d.Get(passwordVar).(string), + }) if err != nil { return diag.Errorf("failed to update smtp config password: %v", err) } @@ -154,16 +137,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId("") return nil } - password, pwOk := d.GetOk(passwordVar) set := map[string]interface{}{ senderAddressVar: resp.GetSmtpConfig().GetSenderAddress(), senderNameVar: resp.GetSmtpConfig().GetSenderName(), tlsVar: resp.GetSmtpConfig().GetTls(), hostVar: resp.GetSmtpConfig().GetHost(), userVar: resp.GetSmtpConfig().GetUser(), - } - if pwOk { - set[passwordVar] = password.(string) + passwordVar: d.Get(passwordVar).(string), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index f0f64d16..92a97f8b 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -49,15 +49,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - actionsSet := d.Get(actionsVar).(*schema.Set) - actions := make([]string, 0) - for _, action := range actionsSet.List() { - actions = append(actions, action.(string)) - } _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: action.FlowType(action.FlowType_value[d.Get(flowTypeVar).(string)]), TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerTypeVar).(string)]), - ActionIds: actions, + ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) if err != nil { return diag.Errorf("failed to update trigger actions: %v", err) @@ -80,17 +75,12 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - actionsSet := d.Get(actionsVar).(*schema.Set) - actions := make([]string, 0) - for _, action := range actionsSet.List() { - actions = append(actions, action.(string)) - } flowType := d.Get(flowTypeVar).(string) triggerType := d.Get(triggerTypeVar).(string) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: action.FlowType(action.FlowType_value[flowType]), TriggerType: action.TriggerType(action.TriggerType_value[triggerType]), - ActionIds: actions, + ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index e227dbf1..75d06d4a 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -22,7 +22,7 @@ func GetResource() *schema.Resource { flowTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the flow to which the action triggers belong", + Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(action.FlowType_value), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(flowTypeVar, value, action.FlowType_value) @@ -31,7 +31,7 @@ func GetResource() *schema.Resource { triggerTypeVar: { Type: schema.TypeString, Required: true, - Description: "Trigger type on when the actions get triggered", + Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(action.TriggerType_value), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(triggerTypeVar, value, action.TriggerType_value) diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go index cf665e40..6ea4ce37 100644 --- a/zitadel/v2/user_grant/const.go +++ b/zitadel/v2/user_grant/const.go @@ -1,9 +1,9 @@ package user_grant const ( - userGrantProjectIDVar = "project_id" - userGrantProjectGrantIDVar = "project_grant_id" - userGrantUserIDVar = "user_id" - userGrantRoleKeysVar = "role_keys" - userGrantOrgIDVar = "org_id" + projectIDVar = "project_id" + projectGrantIDVar = "project_grant_id" + userIDVar = "user_id" + roleKeysVar = "role_keys" + orgIDVar = "org_id" ) diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/v2/user_grant/funcs.go index 11ea7af9..0fbfa3d1 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/v2/user_grant/funcs.go @@ -20,14 +20,14 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } _, err = client.RemoveUserGrant(ctx, &management.RemoveUserGrantRequest{ GrantId: d.Id(), - UserId: d.Get(userGrantUserIDVar).(string), + UserId: d.Get(userIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete usergrant: %v", err) @@ -43,19 +43,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } - roles := make([]string, 0) - for _, role := range d.Get(userGrantRoleKeysVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } _, err = client.UpdateUserGrant(ctx, &management.UpdateUserGrantRequest{ GrantId: d.Id(), - UserId: d.Get(userGrantUserIDVar).(string), - RoleKeys: roles, + UserId: d.Get(userIDVar).(string), + RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), }) if err != nil { return diag.Errorf("failed to update usergrant: %v", err) @@ -71,21 +67,16 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } - roles := make([]string, 0) - for _, role := range d.Get(userGrantRoleKeysVar).(*schema.Set).List() { - roles = append(roles, role.(string)) - } - resp, err := client.AddUserGrant(ctx, &management.AddUserGrantRequest{ - UserId: d.Get(userGrantUserIDVar).(string), - ProjectGrantId: d.Get(userGrantProjectGrantIDVar).(string), - ProjectId: d.Get(userGrantProjectIDVar).(string), - RoleKeys: roles, + UserId: d.Get(userIDVar).(string), + ProjectGrantId: d.Get(projectGrantIDVar).(string), + ProjectId: d.Get(projectIDVar).(string), + RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), }) if err != nil { return diag.Errorf("failed to create usergrant: %v", err) @@ -102,17 +93,17 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(userGrantOrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } - projectID := d.Get(userGrantProjectIDVar) - projectGrantID := d.Get(userGrantProjectGrantIDVar) + projectID := d.Get(projectIDVar) + projectGrantID := d.Get(projectGrantIDVar) queries := []*user.UserGrantQuery{ {Query: &user.UserGrantQuery_UserIdQuery{ UserIdQuery: &user.UserGrantUserIDQuery{ - UserId: d.Get(userGrantUserIDVar).(string), + UserId: d.Get(userIDVar).(string), }, }}, } @@ -138,21 +129,20 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to read usergrant: %v", err) } if len(grants.GetResult()) == 1 { grant := grants.GetResult()[0] set := map[string]interface{}{ - userGrantUserIDVar: grant.GetUserId(), - userGrantRoleKeysVar: grant.GetRoleKeys(), - userGrantOrgIDVar: grant.GetDetails().GetResourceOwner(), + userIDVar: grant.GetUserId(), + roleKeysVar: grant.GetRoleKeys(), + orgIDVar: grant.GetDetails().GetResourceOwner(), } if grant.GetProjectId() != "" { - set[userGrantProjectIDVar] = grant.GetProjectId() + set[projectIDVar] = grant.GetProjectId() } if grant.GetProjectGrantId() != "" { - set[userGrantProjectGrantIDVar] = grant.GetProjectGrantId() + set[projectGrantIDVar] = grant.GetProjectGrantId() } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go index 3124e9aa..62680018 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/v2/user_grant/resource.go @@ -8,25 +8,25 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the authorization given to a user directly, including the given roles.", Schema: map[string]*schema.Schema{ - userGrantProjectIDVar: { + projectIDVar: { Type: schema.TypeString, Optional: true, Description: "ID of the project", ForceNew: true, }, - userGrantProjectGrantIDVar: { + projectGrantIDVar: { Type: schema.TypeString, Optional: true, Description: "ID of the granted project", ForceNew: true, }, - userGrantUserIDVar: { + userIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", ForceNew: true, }, - userGrantRoleKeysVar: { + roleKeysVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, @@ -34,7 +34,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "List of roles granted", }, - userGrantOrgIDVar: { + orgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization which owns the resource", From 34fd19381cea96ff30026494636d03377789f85c Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 18 Nov 2022 16:36:41 +0100 Subject: [PATCH 023/260] feat(gen): add generated text resources with docs and examples --- docs/resources/application_api.md | 5 +- docs/resources/application_oidc.md | 4 +- docs/resources/domain_claimed_message_text.md | 49 + docs/resources/init_message_text.md | 49 + docs/resources/login_texts.md | 810 ++ docs/resources/password_reset_message_text.md | 49 + .../passwordless_registration_message_text.md | 49 + docs/resources/verify_email_message_text.md | 49 + docs/resources/verify_phone_message_text.md | 49 + .../resources/domain_claimed_message_text.tf | 14 + .../provider/resources/init_message_text.tf | 14 + examples/provider/resources/login_texts.tf | 293 + .../resources/password_reset_message_text.tf | 14 + .../passwordless_registration_message_text.tf | 14 + .../resources/verify_email_message_text.tf | 14 + .../resources/verify_phone_message_text.tf | 14 + gen.sh | 14 + gen/config.yaml | 39 + .../zitadel/pkg/grpc/text/text_terraform.go | 12034 ++++++++++++++++ go.mod | 40 +- go.sum | 142 +- main.go | 34 +- .../domain_claimed_message_text.md.tmpl | 16 + templates/resources/init_message_text.md.tmpl | 16 + templates/resources/login_texts.md.tmpl | 16 + .../password_reset_message_text.md.tmpl | 16 + ...wordless_registration_message_text.md.tmpl | 16 + .../verify_email_message_text.md.tmpl | 16 + .../verify_phone_message_text.md.tmpl | 16 + zitadel/provider.go | 107 +- .../domain_claimed_message_text/resource.go | 254 + zitadel/v2/helper/client.go | 17 +- zitadel/v2/helper/helper.go | 15 + zitadel/v2/init_message_text/resource.go | 254 + zitadel/v2/login_texts/resource.go | 254 + .../password_reset_message_text/resource.go | 254 + .../resource.go | 254 + .../v2/verify_email_message_text/resource.go | 254 + .../v2/verify_phone_message_text/resource.go | 254 + 39 files changed, 15679 insertions(+), 143 deletions(-) create mode 100644 docs/resources/domain_claimed_message_text.md create mode 100644 docs/resources/init_message_text.md create mode 100644 docs/resources/login_texts.md create mode 100644 docs/resources/password_reset_message_text.md create mode 100644 docs/resources/passwordless_registration_message_text.md create mode 100644 docs/resources/verify_email_message_text.md create mode 100644 docs/resources/verify_phone_message_text.md create mode 100644 examples/provider/resources/domain_claimed_message_text.tf create mode 100644 examples/provider/resources/init_message_text.tf create mode 100644 examples/provider/resources/login_texts.tf create mode 100644 examples/provider/resources/password_reset_message_text.tf create mode 100644 examples/provider/resources/passwordless_registration_message_text.tf create mode 100644 examples/provider/resources/verify_email_message_text.tf create mode 100644 examples/provider/resources/verify_phone_message_text.tf create mode 100755 gen.sh create mode 100644 gen/config.yaml create mode 100644 gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go create mode 100644 templates/resources/domain_claimed_message_text.md.tmpl create mode 100644 templates/resources/init_message_text.md.tmpl create mode 100644 templates/resources/login_texts.md.tmpl create mode 100644 templates/resources/password_reset_message_text.md.tmpl create mode 100644 templates/resources/passwordless_registration_message_text.md.tmpl create mode 100644 templates/resources/verify_email_message_text.md.tmpl create mode 100644 templates/resources/verify_phone_message_text.md.tmpl create mode 100644 zitadel/v2/domain_claimed_message_text/resource.go create mode 100644 zitadel/v2/init_message_text/resource.go create mode 100644 zitadel/v2/login_texts/resource.go create mode 100644 zitadel/v2/password_reset_message_text/resource.go create mode 100644 zitadel/v2/passwordless_registration_message_text/resource.go create mode 100644 zitadel/v2/verify_email_message_text/resource.go create mode 100644 zitadel/v2/verify_phone_message_text/resource.go diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index f80889d7..6959988f 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -27,11 +27,14 @@ resource zitadel_application_api application_api { ### Required -- `auth_method_type` (String) Auth method type - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project +### Optional + +- `auth_method_type` (String) Auth method type + ### Read-Only - `client_id` (String, Sensitive) generated ID for this config diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 711b239f..d2c4be97 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -41,8 +41,6 @@ resource zitadel_application_oidc application_oidc { ### Required -- `app_type` (String) App type -- `auth_method_type` (String) Auth method type - `clock_skew` (String) Clockskew - `grant_types` (List of String) Grant types - `name` (String) Name of the application @@ -56,6 +54,8 @@ resource zitadel_application_oidc application_oidc { - `access_token_role_assertion` (Boolean) Access token role assertion - `access_token_type` (String) Access token type - `additional_origins` (List of String) Additional origins +- `app_type` (String) App type +- `auth_method_type` (String) Auth method type - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion - `id_token_userinfo_assertion` (Boolean) Token userinfo assertion diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md new file mode 100644 index 00000000..f572ea5f --- /dev/null +++ b/docs/resources/domain_claimed_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_domain_claimed_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_domain_claimed_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_domain_claimed_message_text domain_claimed { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md new file mode 100644 index 00000000..5861e264 --- /dev/null +++ b/docs/resources/init_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_init_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_init_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_init_message_text init { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md new file mode 100644 index 00000000..28116620 --- /dev/null +++ b/docs/resources/login_texts.md @@ -0,0 +1,810 @@ +--- +page_title: "zitadel_login_texts Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_login_texts (Resource) + + + +## Example Usage + +```terraform +resource zitadel_login_texts login_texts { + org_id = "188087895133782187" + language = "en" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "example" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `email_verification_done_text` (Attributes) (see [below for nested schema](#nestedatt--email_verification_done_text)) +- `email_verification_text` (Attributes) (see [below for nested schema](#nestedatt--email_verification_text)) +- `external_registration_user_overview_text` (Attributes) (see [below for nested schema](#nestedatt--external_registration_user_overview_text)) +- `external_user_not_found_text` (Attributes) (see [below for nested schema](#nestedatt--external_user_not_found_text)) +- `footer_text` (Attributes) (see [below for nested schema](#nestedatt--footer_text)) +- `init_mfa_done_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_done_text)) +- `init_mfa_otp_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_otp_text)) +- `init_mfa_prompt_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_prompt_text)) +- `init_mfa_u2f_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_u2f_text)) +- `init_password_done_text` (Attributes) (see [below for nested schema](#nestedatt--init_password_done_text)) +- `init_password_text` (Attributes) (see [below for nested schema](#nestedatt--init_password_text)) +- `initialize_done_text` (Attributes) (see [below for nested schema](#nestedatt--initialize_done_text)) +- `initialize_user_text` (Attributes) (see [below for nested schema](#nestedatt--initialize_user_text)) +- `linking_user_done_text` (Attributes) (see [below for nested schema](#nestedatt--linking_user_done_text)) +- `login_text` (Attributes) (see [below for nested schema](#nestedatt--login_text)) +- `logout_text` (Attributes) (see [below for nested schema](#nestedatt--logout_text)) +- `mfa_providers_text` (Attributes) (see [below for nested schema](#nestedatt--mfa_providers_text)) +- `password_change_done_text` (Attributes) (see [below for nested schema](#nestedatt--password_change_done_text)) +- `password_change_text` (Attributes) (see [below for nested schema](#nestedatt--password_change_text)) +- `password_reset_done_text` (Attributes) (see [below for nested schema](#nestedatt--password_reset_done_text)) +- `password_text` (Attributes) (see [below for nested schema](#nestedatt--password_text)) +- `passwordless_prompt_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_prompt_text)) +- `passwordless_registration_done_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_registration_done_text)) +- `passwordless_registration_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_registration_text)) +- `passwordless_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_text)) +- `registration_option_text` (Attributes) (see [below for nested schema](#nestedatt--registration_option_text)) +- `registration_org_text` (Attributes) (see [below for nested schema](#nestedatt--registration_org_text)) +- `registration_user_text` (Attributes) (see [below for nested schema](#nestedatt--registration_user_text)) +- `select_account_text` (Attributes) (see [below for nested schema](#nestedatt--select_account_text)) +- `success_login_text` (Attributes) (see [below for nested schema](#nestedatt--success_login_text)) +- `username_change_done_text` (Attributes) (see [below for nested schema](#nestedatt--username_change_done_text)) +- `username_change_text` (Attributes) (see [below for nested schema](#nestedatt--username_change_text)) +- `verify_mfa_otp_text` (Attributes) (see [below for nested schema](#nestedatt--verify_mfa_otp_text)) +- `verify_mfa_u2f_text` (Attributes) (see [below for nested schema](#nestedatt--verify_mfa_u2f_text)) + +### Read-Only + +- `id` (String) The ID of this resource. + + +### Nested Schema for `email_verification_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `login_button_text` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `email_verification_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `external_registration_user_overview_text` + +Optional: + +- `back_button_text` (String) +- `description` (String) +- `email_label` (String) +- `firstname_label` (String) +- `language_label` (String) +- `lastname_label` (String) +- `next_button_text` (String) +- `nickname_label` (String) +- `phone_label` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_confirm_and` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `external_user_not_found_text` + +Optional: + +- `auto_register_button_text` (String) +- `description` (String) +- `link_button_text` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_confirm_and` (String) +- `tos_link_text` (String) + + + +### Nested Schema for `footer_text` + +Optional: + +- `help` (String) +- `privacy_policy` (String) +- `tos` (String) + + + +### Nested Schema for `init_mfa_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `init_mfa_otp_text` + +Optional: + +- `cancel_button_text` (String) +- `code_label` (String) +- `description` (String) +- `description_otp` (String) +- `next_button_text` (String) +- `secret_label` (String) +- `title` (String) + + + +### Nested Schema for `init_mfa_prompt_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `otp_option` (String) +- `skip_button_text` (String) +- `title` (String) +- `u2f_option` (String) + + + +### Nested Schema for `init_mfa_u2f_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `register_token_button_text` (String) +- `title` (String) +- `token_name_label` (String) + + + +### Nested Schema for `init_password_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `init_password_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `initialize_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `initialize_user_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `linking_user_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `login_text` + +Optional: + +- `description` (String) +- `description_linking_process` (String) +- `external_user_description` (String) +- `login_name_label` (String) +- `login_name_placeholder` (String) +- `next_button_text` (String) +- `register_button_text` (String) +- `title` (String) +- `title_linking_process` (String) +- `user_must_be_member_of_org` (String) +- `user_name_placeholder` (String) + + + +### Nested Schema for `logout_text` + +Optional: + +- `description` (String) +- `login_button_text` (String) +- `title` (String) + + + +### Nested Schema for `mfa_providers_text` + +Optional: + +- `choose_other` (String) +- `otp` (String) +- `u2f` (String) + + + +### Nested Schema for `password_change_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `password_change_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `old_password_label` (String) +- `title` (String) + + + +### Nested Schema for `password_reset_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `password_text` + +Optional: + +- `back_button_text` (String) +- `confirmation` (String) +- `description` (String) +- `has_lowercase` (String) +- `has_number` (String) +- `has_symbol` (String) +- `has_uppercase` (String) +- `min_length` (String) +- `next_button_text` (String) +- `password_label` (String) +- `reset_link_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_prompt_text` + +Optional: + +- `description` (String) +- `description_init` (String) +- `next_button_text` (String) +- `passwordless_button_text` (String) +- `skip_button_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_registration_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `description_close` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_registration_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `register_token_button_text` (String) +- `title` (String) +- `token_name_label` (String) + + + +### Nested Schema for `passwordless_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `login_with_pw_button_text` (String) +- `not_supported` (String) +- `title` (String) +- `validate_token_button_text` (String) + + + +### Nested Schema for `registration_option_text` + +Optional: + +- `description` (String) +- `external_login_description` (String) +- `title` (String) +- `user_name_button_text` (String) + + + +### Nested Schema for `registration_org_text` + +Optional: + +- `description` (String) +- `email_label` (String) +- `firstname_label` (String) +- `lastname_label` (String) +- `orgname_label` (String) +- `password_confirm_label` (String) +- `password_label` (String) +- `privacy_link_text` (String) +- `save_button_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_confirm_and` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `registration_user_text` + +Optional: + +- `back_button_text` (String) +- `description` (String) +- `description_org_register` (String) +- `email_label` (String) +- `firstname_label` (String) +- `gender_label` (String) +- `language_label` (String) +- `lastname_label` (String) +- `next_button_text` (String) +- `password_confirm_label` (String) +- `password_label` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_confirm_and` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `select_account_text` + +Optional: + +- `description` (String) +- `description_linking_process` (String) +- `other_user` (String) +- `session_state_active` (String) +- `session_state_inactive` (String) +- `title` (String) +- `title_linking_process` (String) +- `user_must_be_member_of_org` (String) + + + +### Nested Schema for `success_login_text` + +Optional: + +- `auto_redirect_description` (String) Text to describe that auto redirect should happen after successful login +- `next_button_text` (String) +- `redirected_description` (String) Text to describe that the window can be closed after redirect +- `title` (String) + + + +### Nested Schema for `username_change_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `username_change_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) +- `username_label` (String) + + + +### Nested Schema for `verify_mfa_otp_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `verify_mfa_u2f_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `title` (String) +- `validate_token_text` (String) \ No newline at end of file diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md new file mode 100644 index 00000000..4e202e65 --- /dev/null +++ b/docs/resources/password_reset_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_password_reset_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_password_reset_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_password_reset_message_text password_reset { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md new file mode 100644 index 00000000..1ba31f90 --- /dev/null +++ b/docs/resources/passwordless_registration_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_passwordless_registration_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_passwordless_registration_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_passwordless_registration_message_text passwordless_registration { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md new file mode 100644 index 00000000..da7e5d80 --- /dev/null +++ b/docs/resources/verify_email_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_verify_email_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_verify_email_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_verify_email_message_text verify_email { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md new file mode 100644 index 00000000..3a4c5009 --- /dev/null +++ b/docs/resources/verify_phone_message_text.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_verify_phone_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_verify_phone_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_verify_phone_message_text verify_phone { + org_id = "188087895133782187" + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/resources/domain_claimed_message_text.tf b/examples/provider/resources/domain_claimed_message_text.tf new file mode 100644 index 00000000..88e6c734 --- /dev/null +++ b/examples/provider/resources/domain_claimed_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_domain_claimed_message_text domain_claimed_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/init_message_text.tf b/examples/provider/resources/init_message_text.tf new file mode 100644 index 00000000..8e7ac115 --- /dev/null +++ b/examples/provider/resources/init_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_init_message_text init_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/login_texts.tf b/examples/provider/resources/login_texts.tf new file mode 100644 index 00000000..be57d19d --- /dev/null +++ b/examples/provider/resources/login_texts.tf @@ -0,0 +1,293 @@ +resource zitadel_login_texts login_texts_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "example" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +} \ No newline at end of file diff --git a/examples/provider/resources/password_reset_message_text.tf b/examples/provider/resources/password_reset_message_text.tf new file mode 100644 index 00000000..9273909c --- /dev/null +++ b/examples/provider/resources/password_reset_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_password_reset_message_text password_reset_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/passwordless_registration_message_text.tf b/examples/provider/resources/passwordless_registration_message_text.tf new file mode 100644 index 00000000..b511d8aa --- /dev/null +++ b/examples/provider/resources/passwordless_registration_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_passwordless_registration_message_text passwordless_registration_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/verify_email_message_text.tf b/examples/provider/resources/verify_email_message_text.tf new file mode 100644 index 00000000..758efc93 --- /dev/null +++ b/examples/provider/resources/verify_email_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_verify_email_message_text verify_email_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/verify_phone_message_text.tf b/examples/provider/resources/verify_phone_message_text.tf new file mode 100644 index 00000000..c3e6d5b2 --- /dev/null +++ b/examples/provider/resources/verify_phone_message_text.tf @@ -0,0 +1,14 @@ +resource zitadel_verify_phone_message_text verify_phone_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/gen.sh b/gen.sh new file mode 100755 index 00000000..cde6a922 --- /dev/null +++ b/gen.sh @@ -0,0 +1,14 @@ +protoc \ + -I$(PWD) \ + -I$(go env GOPATH)/src/github.com/gogo/protobuf \ + -I$(go env GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ + -I$(go env GOPATH)/src/github.com/bufbuild/protoc-gen-validate \ + -I$(go env GOPATH)/src/github.com/zitadel/zitadel/proto \ + --plugin=$(go env GOBIN)/protoc-gen-terraform \ + --terraform_out=config=gen/config.yaml:gen \ + $(go env GOPATH)/src/github.com/zitadel/zitadel/proto/zitadel/text.proto + +sed -i '' 's#_ "github.com/zitadel/zitadel/pkg/grpc/object"##g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +sed -i '' 's#textpb "textpb"#textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text"#g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +sed -i '' 's/U2f/U2F/g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go + diff --git a/gen/config.yaml b/gen/config.yaml new file mode 100644 index 00000000..7f5eea20 --- /dev/null +++ b/gen/config.yaml @@ -0,0 +1,39 @@ +--- +types: + - LoginCustomText + - MessageCustomText + +target_package_name: text +default_package_name: textpb + +use_state_for_unknown_by_default: true +sort: true + +exclude_fields: + - LoginCustomText.details + - LoginCustomText.is_default + - MessageCustomText.details + - MessageCustomText.is_default + +injected_fields: + LoginCustomText: + - name: id + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + computed: true + - name: org_id + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + required: true + - name: language + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + required: true + MessageCustomText: + - name: id + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + computed: true + - name: org_id + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + required: true + - name: language + type: github.com/hashicorp/terraform-plugin-framework/types.StringType + required: true + diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go new file mode 100644 index 00000000..3d18889d --- /dev/null +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -0,0 +1,12034 @@ +/* +Copyright 2015-2022 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zitadel/text.proto + +package text + +import ( + context "context" + fmt "fmt" + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + math "math" + + _ "github.com/envoyproxy/protoc-gen-validate/validate" + proto "github.com/gogo/protobuf/proto" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + github_com_hashicorp_terraform_plugin_framework_attr "github.com/hashicorp/terraform-plugin-framework/attr" + github_com_hashicorp_terraform_plugin_framework_diag "github.com/hashicorp/terraform-plugin-framework/diag" + github_com_hashicorp_terraform_plugin_framework_tfsdk "github.com/hashicorp/terraform-plugin-framework/tfsdk" + github_com_hashicorp_terraform_plugin_framework_types "github.com/hashicorp/terraform-plugin-framework/types" + github_com_hashicorp_terraform_plugin_go_tftypes "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// GenSchemaLoginCustomText returns tfsdk.Schema definition for LoginCustomText +func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema, github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics) { + return github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema{Attributes: map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "email_verification_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "login_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "email_verification_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "code_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "resend_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "external_registration_user_overview_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "back_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "email_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "firstname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "language_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "lastname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "nickname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "phone_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "privacy_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_and_privacy_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm_and": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "username_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "external_user_not_found_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "auto_register_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "link_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "privacy_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_and_privacy_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm_and": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "footer_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "help": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "privacy_policy": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "id": { + Computed: true, + Optional: false, + Required: false, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "init_mfa_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "init_mfa_otp_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "code_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_otp": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "secret_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "init_mfa_prompt_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "otp_option": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "skip_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "u2f_option": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "init_mfa_u2f_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "error_retry": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "not_supported": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "register_token_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "token_name_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "init_password_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "init_password_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "code_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_confirm_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "resend_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "initialize_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "initialize_user_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "code_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_confirm_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "resend_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "language": { + Computed: false, + Optional: false, + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "linking_user_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "login_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_linking_process": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "external_user_description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "login_name_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "login_name_placeholder": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "register_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title_linking_process": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "user_must_be_member_of_org": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "user_name_placeholder": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "logout_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "login_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "mfa_providers_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "choose_other": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "otp": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "u2f": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "org_id": { + Computed: false, + Optional: false, + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_change_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "password_change_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_confirm_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "new_password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "old_password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "password_reset_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "password_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "back_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "confirmation": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "has_lowercase": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "has_number": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "has_symbol": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "has_uppercase": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "min_length": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "reset_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "passwordless_prompt_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_init": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "passwordless_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "skip_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "passwordless_registration_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_close": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "passwordless_registration_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "error_retry": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "not_supported": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "register_token_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "token_name_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "passwordless_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "error_retry": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "login_with_pw_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "not_supported": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "validate_token_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "registration_option_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "external_login_description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "user_name_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "registration_org_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "email_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "firstname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "lastname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "orgname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_confirm_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "privacy_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "save_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_and_privacy_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm_and": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "username_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "registration_user_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "back_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_org_register": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "email_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "firstname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "gender_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "language_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "lastname_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_confirm_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "password_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "privacy_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_and_privacy_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_confirm_and": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "tos_link_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "username_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "select_account_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description_linking_process": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "other_user": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "session_state_active": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "session_state_inactive": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title_linking_process": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "user_must_be_member_of_org": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "success_login_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "auto_redirect_description": { + Description: "Text to describe that auto redirect should happen after successful login", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "redirected_description": { + Description: "Text to describe that the window can be closed after redirect", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "username_change_done_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "username_change_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "cancel_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "username_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "verify_mfa_otp_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "code_label": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "next_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + "verify_mfa_u2f_text": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "error_retry": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "not_supported": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "validate_token_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "", + Optional: true, + }, + }}, nil +} + +// GenSchemaMessageCustomText returns tfsdk.Schema definition for MessageCustomText +func GenSchemaMessageCustomText(ctx context.Context) (github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema, github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics) { + return github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema{Attributes: map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "footer_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "greeting": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "id": { + Computed: true, + Optional: false, + Required: false, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "language": { + Computed: false, + Optional: false, + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "org_id": { + Computed: false, + Optional: false, + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "pre_header": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "subject": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "title": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }}, nil +} + +// CopyLoginCustomTextFromTerraform copies contents of the source Terraform object into a target struct +func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp_terraform_plugin_framework_types.Object, obj *textpb.LoginCustomText) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + { + a, ok := tf.Attrs["email_verification_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.EmailVerificationDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.EmailVerificationDoneText = &textpb.EmailVerificationDoneScreenText{} + obj := obj.EmailVerificationDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["login_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text.login_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginButtonText = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["email_verification_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.EmailVerificationText = nil + if !v.Null && !v.Unknown { + tf := v + obj.EmailVerificationText = &textpb.EmailVerificationScreenText{} + obj := obj.EmailVerificationText + { + a, ok := tf.Attrs["code_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text.code_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CodeLabel = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["resend_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text.resend_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ResendButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.email_verification_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.email_verification_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["external_registration_user_overview_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.ExternalRegistrationUserOverviewText = nil + if !v.Null && !v.Unknown { + tf := v + obj.ExternalRegistrationUserOverviewText = &textpb.ExternalRegistrationUserOverviewScreenText{} + obj := obj.ExternalRegistrationUserOverviewText + { + a, ok := tf.Attrs["back_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.back_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.BackButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["email_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.email_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.EmailLabel = t + } + } + } + { + a, ok := tf.Attrs["firstname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.firstname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.FirstnameLabel = t + } + } + } + { + a, ok := tf.Attrs["language_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.language_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.language_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LanguageLabel = t + } + } + } + { + a, ok := tf.Attrs["lastname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.lastname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LastnameLabel = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["nickname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.nickname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.nickname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NicknameLabel = t + } + } + } + { + a, ok := tf.Attrs["phone_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.phone_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.phone_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PhoneLabel = t + } + } + } + { + a, ok := tf.Attrs["privacy_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.privacy_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyLinkText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["tos_and_privacy_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_and_privacy_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosAndPrivacyLabel = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirm = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm_and"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirmAnd = t + } + } + } + { + a, ok := tf.Attrs["tos_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosLinkText = t + } + } + } + { + a, ok := tf.Attrs["username_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.username_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UsernameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["external_user_not_found_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.ExternalUserNotFoundText = nil + if !v.Null && !v.Unknown { + tf := v + obj.ExternalUserNotFoundText = &textpb.ExternalUserNotFoundScreenText{} + obj := obj.ExternalUserNotFoundText + { + a, ok := tf.Attrs["auto_register_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.auto_register_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.auto_register_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.AutoRegisterButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["link_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.link_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.link_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LinkButtonText = t + } + } + } + { + a, ok := tf.Attrs["privacy_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.privacy_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyLinkText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["tos_and_privacy_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.tos_and_privacy_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosAndPrivacyLabel = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirm = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm_and"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirmAnd = t + } + } + } + { + a, ok := tf.Attrs["tos_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.tos_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosLinkText = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["footer_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.FooterText = nil + if !v.Null && !v.Unknown { + tf := v + obj.FooterText = &textpb.FooterText{} + obj := obj.FooterText + { + a, ok := tf.Attrs["help"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text.help"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text.help", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Help = t + } + } + } + { + a, ok := tf.Attrs["privacy_policy"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text.privacy_policy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text.privacy_policy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyPolicy = t + } + } + } + { + a, ok := tf.Attrs["tos"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text.tos"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text.tos", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Tos = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_mfa_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitMfaDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitMfaDoneText = &textpb.InitMFADoneScreenText{} + obj := obj.InitMfaDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_mfa_otp_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitMfaOtpText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitMfaOtpText = &textpb.InitMFAOTPScreenText{} + obj := obj.InitMfaOtpText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["code_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.code_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CodeLabel = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_otp"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.description_otp"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.description_otp", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionOtp = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["secret_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.secret_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.secret_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SecretLabel = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_otp_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_mfa_prompt_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitMfaPromptText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitMfaPromptText = &textpb.InitMFAPromptScreenText{} + obj := obj.InitMfaPromptText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["otp_option"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.otp_option"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.otp_option", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.OtpOption = t + } + } + } + { + a, ok := tf.Attrs["skip_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.skip_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.skip_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SkipButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["u2f_option"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_prompt_text.u2f_option"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.u2f_option", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.U2FOption = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_mfa_u2f_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitMfaU2FText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitMfaU2FText = &textpb.InitMFAU2FScreenText{} + obj := obj.InitMfaU2FText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["error_retry"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.error_retry"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ErrorRetry = t + } + } + } + { + a, ok := tf.Attrs["not_supported"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.not_supported"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NotSupported = t + } + } + } + { + a, ok := tf.Attrs["register_token_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.register_token_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.register_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RegisterTokenButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["token_name_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_mfa_u2f_text.token_name_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.token_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TokenNameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_password_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitPasswordDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitPasswordDoneText = &textpb.InitPasswordDoneScreenText{} + obj := obj.InitPasswordDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["init_password_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitPasswordText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitPasswordText = &textpb.InitPasswordScreenText{} + obj := obj.InitPasswordText + { + a, ok := tf.Attrs["code_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.code_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CodeLabel = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["new_password_confirm_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.new_password_confirm_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordConfirmLabel = t + } + } + } + { + a, ok := tf.Attrs["new_password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.new_password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["resend_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.resend_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ResendButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.init_password_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.init_password_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["initialize_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitializeDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitializeDoneText = &textpb.InitializeUserDoneScreenText{} + obj := obj.InitializeDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["initialize_user_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.InitializeUserText = nil + if !v.Null && !v.Unknown { + tf := v + obj.InitializeUserText = &textpb.InitializeUserScreenText{} + obj := obj.InitializeUserText + { + a, ok := tf.Attrs["code_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.code_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CodeLabel = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["new_password_confirm_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.new_password_confirm_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordConfirmLabel = t + } + } + } + { + a, ok := tf.Attrs["new_password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.new_password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["resend_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.resend_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ResendButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.initialize_user_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.initialize_user_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["linking_user_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.linking_user_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.linking_user_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.LinkingUserDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.LinkingUserDoneText = &textpb.LinkingUserDoneScreenText{} + obj := obj.LinkingUserDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.linking_user_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.linking_user_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.linking_user_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.linking_user_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.linking_user_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.linking_user_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.linking_user_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.linking_user_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["login_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.LoginText = nil + if !v.Null && !v.Unknown { + tf := v + obj.LoginText = &textpb.LoginScreenText{} + obj := obj.LoginText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_linking_process"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.description_linking_process"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.description_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionLinkingProcess = t + } + } + } + { + a, ok := tf.Attrs["external_user_description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.external_user_description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.external_user_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ExternalUserDescription = t + } + } + } + { + a, ok := tf.Attrs["login_name_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.login_name_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.login_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginNameLabel = t + } + } + } + { + a, ok := tf.Attrs["login_name_placeholder"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.login_name_placeholder"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.login_name_placeholder", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginNamePlaceholder = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["register_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.register_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.register_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RegisterButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["title_linking_process"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.title_linking_process"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.title_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TitleLinkingProcess = t + } + } + } + { + a, ok := tf.Attrs["user_must_be_member_of_org"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.user_must_be_member_of_org"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.user_must_be_member_of_org", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UserMustBeMemberOfOrg = t + } + } + } + { + a, ok := tf.Attrs["user_name_placeholder"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.login_text.user_name_placeholder"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.login_text.user_name_placeholder", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UserNamePlaceholder = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["logout_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.logout_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.logout_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.LogoutText = nil + if !v.Null && !v.Unknown { + tf := v + obj.LogoutText = &textpb.LogoutDoneScreenText{} + obj := obj.LogoutText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.logout_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.logout_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["login_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.logout_text.login_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.logout_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.logout_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.logout_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["mfa_providers_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.mfa_providers_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.mfa_providers_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.MfaProvidersText = nil + if !v.Null && !v.Unknown { + tf := v + obj.MfaProvidersText = &textpb.MFAProvidersText{} + obj := obj.MfaProvidersText + { + a, ok := tf.Attrs["choose_other"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.mfa_providers_text.choose_other"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.mfa_providers_text.choose_other", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ChooseOther = t + } + } + } + { + a, ok := tf.Attrs["otp"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.mfa_providers_text.otp"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.mfa_providers_text.otp", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Otp = t + } + } + } + { + a, ok := tf.Attrs["u2f"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.mfa_providers_text.u2f"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.mfa_providers_text.u2f", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.U2F = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["password_change_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordChangeDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordChangeDoneText = &textpb.PasswordChangeDoneScreenText{} + obj := obj.PasswordChangeDoneText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["password_change_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordChangeText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordChangeText = &textpb.PasswordChangeScreenText{} + obj := obj.PasswordChangeText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["new_password_confirm_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.new_password_confirm_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordConfirmLabel = t + } + } + } + { + a, ok := tf.Attrs["new_password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.new_password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NewPasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["old_password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.old_password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.old_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.OldPasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_change_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_change_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["password_reset_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_reset_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_reset_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordResetDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordResetDoneText = &textpb.PasswordResetDoneScreenText{} + obj := obj.PasswordResetDoneText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_reset_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_reset_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_reset_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_reset_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_reset_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_reset_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["password_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordText = &textpb.PasswordScreenText{} + obj := obj.PasswordText + { + a, ok := tf.Attrs["back_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.back_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.BackButtonText = t + } + } + } + { + a, ok := tf.Attrs["confirmation"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.confirmation"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.confirmation", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Confirmation = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["has_lowercase"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.has_lowercase"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.has_lowercase", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HasLowercase = t + } + } + } + { + a, ok := tf.Attrs["has_number"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.has_number"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.has_number", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HasNumber = t + } + } + } + { + a, ok := tf.Attrs["has_symbol"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.has_symbol"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.has_symbol", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HasSymbol = t + } + } + } + { + a, ok := tf.Attrs["has_uppercase"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.has_uppercase"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.has_uppercase", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HasUppercase = t + } + } + } + { + a, ok := tf.Attrs["min_length"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.min_length"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.min_length", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.MinLength = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["reset_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.reset_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.reset_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ResetLinkText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.password_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.password_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["passwordless_prompt_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordlessPromptText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordlessPromptText = &textpb.PasswordlessPromptScreenText{} + obj := obj.PasswordlessPromptText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_init"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.description_init"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.description_init", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionInit = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["passwordless_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.passwordless_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.passwordless_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordlessButtonText = t + } + } + } + { + a, ok := tf.Attrs["skip_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.skip_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.skip_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SkipButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_prompt_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["passwordless_registration_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordlessRegistrationDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordlessRegistrationDoneText = &textpb.PasswordlessRegistrationDoneScreenText{} + obj := obj.PasswordlessRegistrationDoneText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_close"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text.description_close"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.description_close", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionClose = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["passwordless_registration_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordlessRegistrationText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordlessRegistrationText = &textpb.PasswordlessRegistrationScreenText{} + obj := obj.PasswordlessRegistrationText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["error_retry"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.error_retry"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ErrorRetry = t + } + } + } + { + a, ok := tf.Attrs["not_supported"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.not_supported"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NotSupported = t + } + } + } + { + a, ok := tf.Attrs["register_token_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.register_token_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.register_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RegisterTokenButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["token_name_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_registration_text.token_name_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_registration_text.token_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TokenNameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["passwordless_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.PasswordlessText = nil + if !v.Null && !v.Unknown { + tf := v + obj.PasswordlessText = &textpb.PasswordlessScreenText{} + obj := obj.PasswordlessText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["error_retry"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.error_retry"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ErrorRetry = t + } + } + } + { + a, ok := tf.Attrs["login_with_pw_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.login_with_pw_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.login_with_pw_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginWithPwButtonText = t + } + } + } + { + a, ok := tf.Attrs["not_supported"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.not_supported"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NotSupported = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["validate_token_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.passwordless_text.validate_token_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.passwordless_text.validate_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ValidateTokenButtonText = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["registration_option_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.RegistrationOptionText = nil + if !v.Null && !v.Unknown { + tf := v + obj.RegistrationOptionText = &textpb.RegistrationOptionScreenText{} + obj := obj.RegistrationOptionText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["external_login_description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text.external_login_description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text.external_login_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ExternalLoginDescription = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["user_name_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text.user_name_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text.user_name_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UserNameButtonText = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["registration_org_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.RegistrationOrgText = nil + if !v.Null && !v.Unknown { + tf := v + obj.RegistrationOrgText = &textpb.RegistrationOrgScreenText{} + obj := obj.RegistrationOrgText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["email_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.email_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.EmailLabel = t + } + } + } + { + a, ok := tf.Attrs["firstname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.firstname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.FirstnameLabel = t + } + } + } + { + a, ok := tf.Attrs["lastname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.lastname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LastnameLabel = t + } + } + } + { + a, ok := tf.Attrs["orgname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.orgname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.orgname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.OrgnameLabel = t + } + } + } + { + a, ok := tf.Attrs["password_confirm_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.password_confirm_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordConfirmLabel = t + } + } + } + { + a, ok := tf.Attrs["password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["privacy_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.privacy_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyLinkText = t + } + } + } + { + a, ok := tf.Attrs["save_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.save_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.save_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SaveButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["tos_and_privacy_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.tos_and_privacy_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosAndPrivacyLabel = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.tos_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirm = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm_and"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.tos_confirm_and"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirmAnd = t + } + } + } + { + a, ok := tf.Attrs["tos_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.tos_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosLinkText = t + } + } + } + { + a, ok := tf.Attrs["username_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.username_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UsernameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["registration_user_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.RegistrationUserText = nil + if !v.Null && !v.Unknown { + tf := v + obj.RegistrationUserText = &textpb.RegistrationUserScreenText{} + obj := obj.RegistrationUserText + { + a, ok := tf.Attrs["back_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.back_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.BackButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_org_register"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.description_org_register"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.description_org_register", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionOrgRegister = t + } + } + } + { + a, ok := tf.Attrs["email_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.email_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.EmailLabel = t + } + } + } + { + a, ok := tf.Attrs["firstname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.firstname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.FirstnameLabel = t + } + } + } + { + a, ok := tf.Attrs["gender_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.gender_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.gender_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.GenderLabel = t + } + } + } + { + a, ok := tf.Attrs["language_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.language_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.language_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LanguageLabel = t + } + } + } + { + a, ok := tf.Attrs["lastname_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.lastname_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LastnameLabel = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["password_confirm_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.password_confirm_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordConfirmLabel = t + } + } + } + { + a, ok := tf.Attrs["password_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.password_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PasswordLabel = t + } + } + } + { + a, ok := tf.Attrs["privacy_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.privacy_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyLinkText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["tos_and_privacy_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.tos_and_privacy_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosAndPrivacyLabel = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.tos_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirm = t + } + } + } + { + a, ok := tf.Attrs["tos_confirm_and"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.tos_confirm_and"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosConfirmAnd = t + } + } + } + { + a, ok := tf.Attrs["tos_link_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.tos_link_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TosLinkText = t + } + } + } + { + a, ok := tf.Attrs["username_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.username_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UsernameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["select_account_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.SelectAccountText = nil + if !v.Null && !v.Unknown { + tf := v + obj.SelectAccountText = &textpb.SelectAccountScreenText{} + obj := obj.SelectAccountText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["description_linking_process"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.description_linking_process"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.description_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DescriptionLinkingProcess = t + } + } + } + { + a, ok := tf.Attrs["other_user"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.other_user"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.other_user", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.OtherUser = t + } + } + } + { + a, ok := tf.Attrs["session_state_active"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.session_state_active"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.session_state_active", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SessionStateActive = t + } + } + } + { + a, ok := tf.Attrs["session_state_inactive"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.session_state_inactive"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.session_state_inactive", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SessionStateInactive = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["title_linking_process"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.title_linking_process"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.title_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.TitleLinkingProcess = t + } + } + } + { + a, ok := tf.Attrs["user_must_be_member_of_org"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.select_account_text.user_must_be_member_of_org"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.select_account_text.user_must_be_member_of_org", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UserMustBeMemberOfOrg = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["success_login_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.success_login_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.success_login_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.SuccessLoginText = nil + if !v.Null && !v.Unknown { + tf := v + obj.SuccessLoginText = &textpb.SuccessLoginScreenText{} + obj := obj.SuccessLoginText + { + a, ok := tf.Attrs["auto_redirect_description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.success_login_text.auto_redirect_description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.success_login_text.auto_redirect_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.AutoRedirectDescription = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.success_login_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.success_login_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["redirected_description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.success_login_text.redirected_description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.success_login_text.redirected_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RedirectedDescription = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.success_login_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.success_login_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["username_change_done_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_done_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_done_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.UsernameChangeDoneText = nil + if !v.Null && !v.Unknown { + tf := v + obj.UsernameChangeDoneText = &textpb.UsernameChangeDoneScreenText{} + obj := obj.UsernameChangeDoneText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_done_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_done_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_done_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["username_change_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.UsernameChangeText = nil + if !v.Null && !v.Unknown { + tf := v + obj.UsernameChangeText = &textpb.UsernameChangeScreenText{} + obj := obj.UsernameChangeText + { + a, ok := tf.Attrs["cancel_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text.cancel_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CancelButtonText = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["username_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.username_change_text.username_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.username_change_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UsernameLabel = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["verify_mfa_otp_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_otp_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.VerifyMfaOtpText = nil + if !v.Null && !v.Unknown { + tf := v + obj.VerifyMfaOtpText = &textpb.VerifyMFAOTPScreenText{} + obj := obj.VerifyMfaOtpText + { + a, ok := tf.Attrs["code_label"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_otp_text.code_label"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.CodeLabel = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_otp_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["next_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_otp_text.next_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NextButtonText = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_otp_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["verify_mfa_u2f_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.VerifyMfaU2FText = nil + if !v.Null && !v.Unknown { + tf := v + obj.VerifyMfaU2FText = &textpb.VerifyMFAU2FScreenText{} + obj := obj.VerifyMfaU2FText + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["error_retry"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text.error_retry"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ErrorRetry = t + } + } + } + { + a, ok := tf.Attrs["not_supported"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text.not_supported"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NotSupported = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + { + a, ok := tf.Attrs["validate_token_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.verify_mfa_u2f_text.validate_token_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.validate_token_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ValidateTokenText = t + } + } + } + } + } + } + } + return diags +} + +// CopyLoginCustomTextToTerraform copies contents of the source Terraform object into a target struct +func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomText, tf *github_com_hashicorp_terraform_plugin_framework_types.Object) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + tf.Null = false + tf.Unknown = false + if tf.Attrs == nil { + tf.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value) + } + { + a, ok := tf.AttrTypes["email_verification_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["email_verification_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.EmailVerificationDoneText == nil { + v.Null = true + } else { + obj := obj.EmailVerificationDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["login_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text.login_button_text"}) + } else { + v, ok := tf.Attrs["login_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_done_text.login_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginButtonText) == "" + } + v.Value = string(obj.LoginButtonText) + v.Unknown = false + tf.Attrs["login_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["email_verification_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["email_verification_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["email_verification_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.EmailVerificationText == nil { + v.Null = true + } else { + obj := obj.EmailVerificationText + tf := &v + { + t, ok := tf.AttrTypes["code_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text.code_label"}) + } else { + v, ok := tf.Attrs["code_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_text.code_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CodeLabel) == "" + } + v.Value = string(obj.CodeLabel) + v.Unknown = false + tf.Attrs["code_label"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["resend_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text.resend_button_text"}) + } else { + v, ok := tf.Attrs["resend_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_text.resend_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ResendButtonText) == "" + } + v.Value = string(obj.ResendButtonText) + v.Unknown = false + tf.Attrs["resend_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.email_verification_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.email_verification_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.email_verification_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["email_verification_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["external_registration_user_overview_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["external_registration_user_overview_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.ExternalRegistrationUserOverviewText == nil { + v.Null = true + } else { + obj := obj.ExternalRegistrationUserOverviewText + tf := &v + { + t, ok := tf.AttrTypes["back_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.back_button_text"}) + } else { + v, ok := tf.Attrs["back_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.back_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.BackButtonText) == "" + } + v.Value = string(obj.BackButtonText) + v.Unknown = false + tf.Attrs["back_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["email_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.email_label"}) + } else { + v, ok := tf.Attrs["email_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.email_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.EmailLabel) == "" + } + v.Value = string(obj.EmailLabel) + v.Unknown = false + tf.Attrs["email_label"] = v + } + } + { + t, ok := tf.AttrTypes["firstname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.firstname_label"}) + } else { + v, ok := tf.Attrs["firstname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.firstname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.FirstnameLabel) == "" + } + v.Value = string(obj.FirstnameLabel) + v.Unknown = false + tf.Attrs["firstname_label"] = v + } + } + { + t, ok := tf.AttrTypes["language_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.language_label"}) + } else { + v, ok := tf.Attrs["language_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.language_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.language_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LanguageLabel) == "" + } + v.Value = string(obj.LanguageLabel) + v.Unknown = false + tf.Attrs["language_label"] = v + } + } + { + t, ok := tf.AttrTypes["lastname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.lastname_label"}) + } else { + v, ok := tf.Attrs["lastname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.lastname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LastnameLabel) == "" + } + v.Value = string(obj.LastnameLabel) + v.Unknown = false + tf.Attrs["lastname_label"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["nickname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.nickname_label"}) + } else { + v, ok := tf.Attrs["nickname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.nickname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.nickname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NicknameLabel) == "" + } + v.Value = string(obj.NicknameLabel) + v.Unknown = false + tf.Attrs["nickname_label"] = v + } + } + { + t, ok := tf.AttrTypes["phone_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.phone_label"}) + } else { + v, ok := tf.Attrs["phone_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.phone_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.phone_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PhoneLabel) == "" + } + v.Value = string(obj.PhoneLabel) + v.Unknown = false + tf.Attrs["phone_label"] = v + } + } + { + t, ok := tf.AttrTypes["privacy_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.privacy_link_text"}) + } else { + v, ok := tf.Attrs["privacy_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.privacy_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyLinkText) == "" + } + v.Value = string(obj.PrivacyLinkText) + v.Unknown = false + tf.Attrs["privacy_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["tos_and_privacy_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_and_privacy_label"}) + } else { + v, ok := tf.Attrs["tos_and_privacy_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.tos_and_privacy_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosAndPrivacyLabel) == "" + } + v.Value = string(obj.TosAndPrivacyLabel) + v.Unknown = false + tf.Attrs["tos_and_privacy_label"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm"}) + } else { + v, ok := tf.Attrs["tos_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.tos_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirm) == "" + } + v.Value = string(obj.TosConfirm) + v.Unknown = false + tf.Attrs["tos_confirm"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm_and"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and"}) + } else { + v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirmAnd) == "" + } + v.Value = string(obj.TosConfirmAnd) + v.Unknown = false + tf.Attrs["tos_confirm_and"] = v + } + } + { + t, ok := tf.AttrTypes["tos_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_link_text"}) + } else { + v, ok := tf.Attrs["tos_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.tos_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosLinkText) == "" + } + v.Value = string(obj.TosLinkText) + v.Unknown = false + tf.Attrs["tos_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["username_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.username_label"}) + } else { + v, ok := tf.Attrs["username_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.username_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UsernameLabel) == "" + } + v.Value = string(obj.UsernameLabel) + v.Unknown = false + tf.Attrs["username_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["external_registration_user_overview_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["external_user_not_found_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["external_user_not_found_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.ExternalUserNotFoundText == nil { + v.Null = true + } else { + obj := obj.ExternalUserNotFoundText + tf := &v + { + t, ok := tf.AttrTypes["auto_register_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.auto_register_button_text"}) + } else { + v, ok := tf.Attrs["auto_register_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.auto_register_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.auto_register_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.AutoRegisterButtonText) == "" + } + v.Value = string(obj.AutoRegisterButtonText) + v.Unknown = false + tf.Attrs["auto_register_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["link_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.link_button_text"}) + } else { + v, ok := tf.Attrs["link_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.link_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.link_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LinkButtonText) == "" + } + v.Value = string(obj.LinkButtonText) + v.Unknown = false + tf.Attrs["link_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["privacy_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.privacy_link_text"}) + } else { + v, ok := tf.Attrs["privacy_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.privacy_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyLinkText) == "" + } + v.Value = string(obj.PrivacyLinkText) + v.Unknown = false + tf.Attrs["privacy_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["tos_and_privacy_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.tos_and_privacy_label"}) + } else { + v, ok := tf.Attrs["tos_and_privacy_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.tos_and_privacy_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosAndPrivacyLabel) == "" + } + v.Value = string(obj.TosAndPrivacyLabel) + v.Unknown = false + tf.Attrs["tos_and_privacy_label"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm"}) + } else { + v, ok := tf.Attrs["tos_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.tos_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirm) == "" + } + v.Value = string(obj.TosConfirm) + v.Unknown = false + tf.Attrs["tos_confirm"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm_and"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and"}) + } else { + v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.tos_confirm_and", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirmAnd) == "" + } + v.Value = string(obj.TosConfirmAnd) + v.Unknown = false + tf.Attrs["tos_confirm_and"] = v + } + } + { + t, ok := tf.AttrTypes["tos_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.tos_link_text"}) + } else { + v, ok := tf.Attrs["tos_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.tos_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosLinkText) == "" + } + v.Value = string(obj.TosLinkText) + v.Unknown = false + tf.Attrs["tos_link_text"] = v + } + } + } + v.Unknown = false + tf.Attrs["external_user_not_found_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["footer_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["footer_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.FooterText == nil { + v.Null = true + } else { + obj := obj.FooterText + tf := &v + { + t, ok := tf.AttrTypes["help"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text.help"}) + } else { + v, ok := tf.Attrs["help"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.footer_text.help", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text.help", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Help) == "" + } + v.Value = string(obj.Help) + v.Unknown = false + tf.Attrs["help"] = v + } + } + { + t, ok := tf.AttrTypes["privacy_policy"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text.privacy_policy"}) + } else { + v, ok := tf.Attrs["privacy_policy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.footer_text.privacy_policy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text.privacy_policy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyPolicy) == "" + } + v.Value = string(obj.PrivacyPolicy) + v.Unknown = false + tf.Attrs["privacy_policy"] = v + } + } + { + t, ok := tf.AttrTypes["tos"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text.tos"}) + } else { + v, ok := tf.Attrs["tos"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.footer_text.tos", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text.tos", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Tos) == "" + } + v.Value = string(obj.Tos) + v.Unknown = false + tf.Attrs["tos"] = v + } + } + } + v.Unknown = false + tf.Attrs["footer_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_mfa_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_mfa_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitMfaDoneText == nil { + v.Null = true + } else { + obj := obj.InitMfaDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_mfa_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_mfa_otp_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_mfa_otp_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitMfaOtpText == nil { + v.Null = true + } else { + obj := obj.InitMfaOtpText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["code_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.code_label"}) + } else { + v, ok := tf.Attrs["code_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.code_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CodeLabel) == "" + } + v.Value = string(obj.CodeLabel) + v.Unknown = false + tf.Attrs["code_label"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_otp"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.description_otp"}) + } else { + v, ok := tf.Attrs["description_otp"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.description_otp", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.description_otp", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionOtp) == "" + } + v.Value = string(obj.DescriptionOtp) + v.Unknown = false + tf.Attrs["description_otp"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["secret_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.secret_label"}) + } else { + v, ok := tf.Attrs["secret_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.secret_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.secret_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SecretLabel) == "" + } + v.Value = string(obj.SecretLabel) + v.Unknown = false + tf.Attrs["secret_label"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_otp_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_otp_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_otp_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_mfa_otp_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_mfa_prompt_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_mfa_prompt_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitMfaPromptText == nil { + v.Null = true + } else { + obj := obj.InitMfaPromptText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["otp_option"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.otp_option"}) + } else { + v, ok := tf.Attrs["otp_option"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.otp_option", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.otp_option", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.OtpOption) == "" + } + v.Value = string(obj.OtpOption) + v.Unknown = false + tf.Attrs["otp_option"] = v + } + } + { + t, ok := tf.AttrTypes["skip_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.skip_button_text"}) + } else { + v, ok := tf.Attrs["skip_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.skip_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.skip_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SkipButtonText) == "" + } + v.Value = string(obj.SkipButtonText) + v.Unknown = false + tf.Attrs["skip_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["u2f_option"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_prompt_text.u2f_option"}) + } else { + v, ok := tf.Attrs["u2f_option"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_prompt_text.u2f_option", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_prompt_text.u2f_option", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.U2FOption) == "" + } + v.Value = string(obj.U2FOption) + v.Unknown = false + tf.Attrs["u2f_option"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_mfa_prompt_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_mfa_u2f_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_mfa_u2f_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitMfaU2FText == nil { + v.Null = true + } else { + obj := obj.InitMfaU2FText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["error_retry"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.error_retry"}) + } else { + v, ok := tf.Attrs["error_retry"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.error_retry", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ErrorRetry) == "" + } + v.Value = string(obj.ErrorRetry) + v.Unknown = false + tf.Attrs["error_retry"] = v + } + } + { + t, ok := tf.AttrTypes["not_supported"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.not_supported"}) + } else { + v, ok := tf.Attrs["not_supported"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.not_supported", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NotSupported) == "" + } + v.Value = string(obj.NotSupported) + v.Unknown = false + tf.Attrs["not_supported"] = v + } + } + { + t, ok := tf.AttrTypes["register_token_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.register_token_button_text"}) + } else { + v, ok := tf.Attrs["register_token_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.register_token_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.register_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RegisterTokenButtonText) == "" + } + v.Value = string(obj.RegisterTokenButtonText) + v.Unknown = false + tf.Attrs["register_token_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["token_name_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_mfa_u2f_text.token_name_label"}) + } else { + v, ok := tf.Attrs["token_name_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_mfa_u2f_text.token_name_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_mfa_u2f_text.token_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TokenNameLabel) == "" + } + v.Value = string(obj.TokenNameLabel) + v.Unknown = false + tf.Attrs["token_name_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_mfa_u2f_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_password_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_password_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitPasswordDoneText == nil { + v.Null = true + } else { + obj := obj.InitPasswordDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_password_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["init_password_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["init_password_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitPasswordText == nil { + v.Null = true + } else { + obj := obj.InitPasswordText + tf := &v + { + t, ok := tf.AttrTypes["code_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.code_label"}) + } else { + v, ok := tf.Attrs["code_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.code_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CodeLabel) == "" + } + v.Value = string(obj.CodeLabel) + v.Unknown = false + tf.Attrs["code_label"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_confirm_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.new_password_confirm_label"}) + } else { + v, ok := tf.Attrs["new_password_confirm_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.new_password_confirm_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordConfirmLabel) == "" + } + v.Value = string(obj.NewPasswordConfirmLabel) + v.Unknown = false + tf.Attrs["new_password_confirm_label"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.new_password_label"}) + } else { + v, ok := tf.Attrs["new_password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.new_password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordLabel) == "" + } + v.Value = string(obj.NewPasswordLabel) + v.Unknown = false + tf.Attrs["new_password_label"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["resend_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.resend_button_text"}) + } else { + v, ok := tf.Attrs["resend_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.resend_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ResendButtonText) == "" + } + v.Value = string(obj.ResendButtonText) + v.Unknown = false + tf.Attrs["resend_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.init_password_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.init_password_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.init_password_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["init_password_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["initialize_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["initialize_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitializeDoneText == nil { + v.Null = true + } else { + obj := obj.InitializeDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["initialize_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["initialize_user_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["initialize_user_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.InitializeUserText == nil { + v.Null = true + } else { + obj := obj.InitializeUserText + tf := &v + { + t, ok := tf.AttrTypes["code_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.code_label"}) + } else { + v, ok := tf.Attrs["code_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.code_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CodeLabel) == "" + } + v.Value = string(obj.CodeLabel) + v.Unknown = false + tf.Attrs["code_label"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_confirm_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.new_password_confirm_label"}) + } else { + v, ok := tf.Attrs["new_password_confirm_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.new_password_confirm_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordConfirmLabel) == "" + } + v.Value = string(obj.NewPasswordConfirmLabel) + v.Unknown = false + tf.Attrs["new_password_confirm_label"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.new_password_label"}) + } else { + v, ok := tf.Attrs["new_password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.new_password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordLabel) == "" + } + v.Value = string(obj.NewPasswordLabel) + v.Unknown = false + tf.Attrs["new_password_label"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["resend_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.resend_button_text"}) + } else { + v, ok := tf.Attrs["resend_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.resend_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.resend_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ResendButtonText) == "" + } + v.Value = string(obj.ResendButtonText) + v.Unknown = false + tf.Attrs["resend_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.initialize_user_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.initialize_user_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.initialize_user_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["initialize_user_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["linking_user_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.linking_user_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.linking_user_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["linking_user_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.LinkingUserDoneText == nil { + v.Null = true + } else { + obj := obj.LinkingUserDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.linking_user_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.linking_user_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.linking_user_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.linking_user_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.linking_user_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.linking_user_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.linking_user_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.linking_user_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.linking_user_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.linking_user_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.linking_user_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.linking_user_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["linking_user_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["login_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["login_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.LoginText == nil { + v.Null = true + } else { + obj := obj.LoginText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_linking_process"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.description_linking_process"}) + } else { + v, ok := tf.Attrs["description_linking_process"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.description_linking_process", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.description_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionLinkingProcess) == "" + } + v.Value = string(obj.DescriptionLinkingProcess) + v.Unknown = false + tf.Attrs["description_linking_process"] = v + } + } + { + t, ok := tf.AttrTypes["external_user_description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.external_user_description"}) + } else { + v, ok := tf.Attrs["external_user_description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.external_user_description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.external_user_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ExternalUserDescription) == "" + } + v.Value = string(obj.ExternalUserDescription) + v.Unknown = false + tf.Attrs["external_user_description"] = v + } + } + { + t, ok := tf.AttrTypes["login_name_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.login_name_label"}) + } else { + v, ok := tf.Attrs["login_name_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.login_name_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.login_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginNameLabel) == "" + } + v.Value = string(obj.LoginNameLabel) + v.Unknown = false + tf.Attrs["login_name_label"] = v + } + } + { + t, ok := tf.AttrTypes["login_name_placeholder"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.login_name_placeholder"}) + } else { + v, ok := tf.Attrs["login_name_placeholder"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.login_name_placeholder", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.login_name_placeholder", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginNamePlaceholder) == "" + } + v.Value = string(obj.LoginNamePlaceholder) + v.Unknown = false + tf.Attrs["login_name_placeholder"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["register_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.register_button_text"}) + } else { + v, ok := tf.Attrs["register_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.register_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.register_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RegisterButtonText) == "" + } + v.Value = string(obj.RegisterButtonText) + v.Unknown = false + tf.Attrs["register_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["title_linking_process"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.title_linking_process"}) + } else { + v, ok := tf.Attrs["title_linking_process"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.title_linking_process", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.title_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TitleLinkingProcess) == "" + } + v.Value = string(obj.TitleLinkingProcess) + v.Unknown = false + tf.Attrs["title_linking_process"] = v + } + } + { + t, ok := tf.AttrTypes["user_must_be_member_of_org"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.user_must_be_member_of_org"}) + } else { + v, ok := tf.Attrs["user_must_be_member_of_org"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.user_must_be_member_of_org", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.user_must_be_member_of_org", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UserMustBeMemberOfOrg) == "" + } + v.Value = string(obj.UserMustBeMemberOfOrg) + v.Unknown = false + tf.Attrs["user_must_be_member_of_org"] = v + } + } + { + t, ok := tf.AttrTypes["user_name_placeholder"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.login_text.user_name_placeholder"}) + } else { + v, ok := tf.Attrs["user_name_placeholder"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.login_text.user_name_placeholder", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.login_text.user_name_placeholder", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UserNamePlaceholder) == "" + } + v.Value = string(obj.UserNamePlaceholder) + v.Unknown = false + tf.Attrs["user_name_placeholder"] = v + } + } + } + v.Unknown = false + tf.Attrs["login_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["logout_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.logout_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.logout_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["logout_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.LogoutText == nil { + v.Null = true + } else { + obj := obj.LogoutText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.logout_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.logout_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.logout_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["login_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.logout_text.login_button_text"}) + } else { + v, ok := tf.Attrs["login_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.logout_text.login_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.logout_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginButtonText) == "" + } + v.Value = string(obj.LoginButtonText) + v.Unknown = false + tf.Attrs["login_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.logout_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.logout_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.logout_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["logout_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["mfa_providers_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.mfa_providers_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.mfa_providers_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["mfa_providers_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.MfaProvidersText == nil { + v.Null = true + } else { + obj := obj.MfaProvidersText + tf := &v + { + t, ok := tf.AttrTypes["choose_other"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.mfa_providers_text.choose_other"}) + } else { + v, ok := tf.Attrs["choose_other"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.mfa_providers_text.choose_other", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.mfa_providers_text.choose_other", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ChooseOther) == "" + } + v.Value = string(obj.ChooseOther) + v.Unknown = false + tf.Attrs["choose_other"] = v + } + } + { + t, ok := tf.AttrTypes["otp"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.mfa_providers_text.otp"}) + } else { + v, ok := tf.Attrs["otp"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.mfa_providers_text.otp", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.mfa_providers_text.otp", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Otp) == "" + } + v.Value = string(obj.Otp) + v.Unknown = false + tf.Attrs["otp"] = v + } + } + { + t, ok := tf.AttrTypes["u2f"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.mfa_providers_text.u2f"}) + } else { + v, ok := tf.Attrs["u2f"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.mfa_providers_text.u2f", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.mfa_providers_text.u2f", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.U2F) == "" + } + v.Value = string(obj.U2F) + v.Unknown = false + tf.Attrs["u2f"] = v + } + } + } + v.Unknown = false + tf.Attrs["mfa_providers_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["password_change_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["password_change_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordChangeDoneText == nil { + v.Null = true + } else { + obj := obj.PasswordChangeDoneText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["password_change_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["password_change_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["password_change_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordChangeText == nil { + v.Null = true + } else { + obj := obj.PasswordChangeText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_confirm_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.new_password_confirm_label"}) + } else { + v, ok := tf.Attrs["new_password_confirm_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.new_password_confirm_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.new_password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordConfirmLabel) == "" + } + v.Value = string(obj.NewPasswordConfirmLabel) + v.Unknown = false + tf.Attrs["new_password_confirm_label"] = v + } + } + { + t, ok := tf.AttrTypes["new_password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.new_password_label"}) + } else { + v, ok := tf.Attrs["new_password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.new_password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.new_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NewPasswordLabel) == "" + } + v.Value = string(obj.NewPasswordLabel) + v.Unknown = false + tf.Attrs["new_password_label"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["old_password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.old_password_label"}) + } else { + v, ok := tf.Attrs["old_password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.old_password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.old_password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.OldPasswordLabel) == "" + } + v.Value = string(obj.OldPasswordLabel) + v.Unknown = false + tf.Attrs["old_password_label"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_change_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_change_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_change_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["password_change_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["password_reset_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_reset_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_reset_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["password_reset_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordResetDoneText == nil { + v.Null = true + } else { + obj := obj.PasswordResetDoneText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_reset_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_reset_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_reset_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_reset_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_reset_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_reset_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_reset_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_reset_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_reset_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["password_reset_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["password_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["password_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordText == nil { + v.Null = true + } else { + obj := obj.PasswordText + tf := &v + { + t, ok := tf.AttrTypes["back_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.back_button_text"}) + } else { + v, ok := tf.Attrs["back_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.back_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.BackButtonText) == "" + } + v.Value = string(obj.BackButtonText) + v.Unknown = false + tf.Attrs["back_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["confirmation"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.confirmation"}) + } else { + v, ok := tf.Attrs["confirmation"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.confirmation", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.confirmation", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Confirmation) == "" + } + v.Value = string(obj.Confirmation) + v.Unknown = false + tf.Attrs["confirmation"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["has_lowercase"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.has_lowercase"}) + } else { + v, ok := tf.Attrs["has_lowercase"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.has_lowercase", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.has_lowercase", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HasLowercase) == "" + } + v.Value = string(obj.HasLowercase) + v.Unknown = false + tf.Attrs["has_lowercase"] = v + } + } + { + t, ok := tf.AttrTypes["has_number"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.has_number"}) + } else { + v, ok := tf.Attrs["has_number"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.has_number", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.has_number", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HasNumber) == "" + } + v.Value = string(obj.HasNumber) + v.Unknown = false + tf.Attrs["has_number"] = v + } + } + { + t, ok := tf.AttrTypes["has_symbol"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.has_symbol"}) + } else { + v, ok := tf.Attrs["has_symbol"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.has_symbol", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.has_symbol", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HasSymbol) == "" + } + v.Value = string(obj.HasSymbol) + v.Unknown = false + tf.Attrs["has_symbol"] = v + } + } + { + t, ok := tf.AttrTypes["has_uppercase"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.has_uppercase"}) + } else { + v, ok := tf.Attrs["has_uppercase"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.has_uppercase", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.has_uppercase", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HasUppercase) == "" + } + v.Value = string(obj.HasUppercase) + v.Unknown = false + tf.Attrs["has_uppercase"] = v + } + } + { + t, ok := tf.AttrTypes["min_length"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.min_length"}) + } else { + v, ok := tf.Attrs["min_length"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.min_length", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.min_length", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.MinLength) == "" + } + v.Value = string(obj.MinLength) + v.Unknown = false + tf.Attrs["min_length"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.password_label"}) + } else { + v, ok := tf.Attrs["password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordLabel) == "" + } + v.Value = string(obj.PasswordLabel) + v.Unknown = false + tf.Attrs["password_label"] = v + } + } + { + t, ok := tf.AttrTypes["reset_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.reset_link_text"}) + } else { + v, ok := tf.Attrs["reset_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.reset_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.reset_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ResetLinkText) == "" + } + v.Value = string(obj.ResetLinkText) + v.Unknown = false + tf.Attrs["reset_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.password_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.password_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.password_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["password_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["passwordless_prompt_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["passwordless_prompt_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordlessPromptText == nil { + v.Null = true + } else { + obj := obj.PasswordlessPromptText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_init"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.description_init"}) + } else { + v, ok := tf.Attrs["description_init"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.description_init", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.description_init", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionInit) == "" + } + v.Value = string(obj.DescriptionInit) + v.Unknown = false + tf.Attrs["description_init"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["passwordless_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.passwordless_button_text"}) + } else { + v, ok := tf.Attrs["passwordless_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.passwordless_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.passwordless_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordlessButtonText) == "" + } + v.Value = string(obj.PasswordlessButtonText) + v.Unknown = false + tf.Attrs["passwordless_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["skip_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.skip_button_text"}) + } else { + v, ok := tf.Attrs["skip_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.skip_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.skip_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SkipButtonText) == "" + } + v.Value = string(obj.SkipButtonText) + v.Unknown = false + tf.Attrs["skip_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_prompt_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_prompt_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_prompt_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["passwordless_prompt_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["passwordless_registration_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["passwordless_registration_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordlessRegistrationDoneText == nil { + v.Null = true + } else { + obj := obj.PasswordlessRegistrationDoneText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_done_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_close"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text.description_close"}) + } else { + v, ok := tf.Attrs["description_close"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_done_text.description_close", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.description_close", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionClose) == "" + } + v.Value = string(obj.DescriptionClose) + v.Unknown = false + tf.Attrs["description_close"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["passwordless_registration_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["passwordless_registration_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["passwordless_registration_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordlessRegistrationText == nil { + v.Null = true + } else { + obj := obj.PasswordlessRegistrationText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["error_retry"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.error_retry"}) + } else { + v, ok := tf.Attrs["error_retry"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.error_retry", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ErrorRetry) == "" + } + v.Value = string(obj.ErrorRetry) + v.Unknown = false + tf.Attrs["error_retry"] = v + } + } + { + t, ok := tf.AttrTypes["not_supported"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.not_supported"}) + } else { + v, ok := tf.Attrs["not_supported"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.not_supported", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NotSupported) == "" + } + v.Value = string(obj.NotSupported) + v.Unknown = false + tf.Attrs["not_supported"] = v + } + } + { + t, ok := tf.AttrTypes["register_token_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.register_token_button_text"}) + } else { + v, ok := tf.Attrs["register_token_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.register_token_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.register_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RegisterTokenButtonText) == "" + } + v.Value = string(obj.RegisterTokenButtonText) + v.Unknown = false + tf.Attrs["register_token_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["token_name_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_registration_text.token_name_label"}) + } else { + v, ok := tf.Attrs["token_name_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_registration_text.token_name_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_registration_text.token_name_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TokenNameLabel) == "" + } + v.Value = string(obj.TokenNameLabel) + v.Unknown = false + tf.Attrs["token_name_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["passwordless_registration_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["passwordless_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["passwordless_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.PasswordlessText == nil { + v.Null = true + } else { + obj := obj.PasswordlessText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["error_retry"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.error_retry"}) + } else { + v, ok := tf.Attrs["error_retry"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.error_retry", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ErrorRetry) == "" + } + v.Value = string(obj.ErrorRetry) + v.Unknown = false + tf.Attrs["error_retry"] = v + } + } + { + t, ok := tf.AttrTypes["login_with_pw_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.login_with_pw_button_text"}) + } else { + v, ok := tf.Attrs["login_with_pw_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.login_with_pw_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.login_with_pw_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginWithPwButtonText) == "" + } + v.Value = string(obj.LoginWithPwButtonText) + v.Unknown = false + tf.Attrs["login_with_pw_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["not_supported"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.not_supported"}) + } else { + v, ok := tf.Attrs["not_supported"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.not_supported", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NotSupported) == "" + } + v.Value = string(obj.NotSupported) + v.Unknown = false + tf.Attrs["not_supported"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["validate_token_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.passwordless_text.validate_token_button_text"}) + } else { + v, ok := tf.Attrs["validate_token_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.passwordless_text.validate_token_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.passwordless_text.validate_token_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ValidateTokenButtonText) == "" + } + v.Value = string(obj.ValidateTokenButtonText) + v.Unknown = false + tf.Attrs["validate_token_button_text"] = v + } + } + } + v.Unknown = false + tf.Attrs["passwordless_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["registration_option_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["registration_option_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.RegistrationOptionText == nil { + v.Null = true + } else { + obj := obj.RegistrationOptionText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_option_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["external_login_description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text.external_login_description"}) + } else { + v, ok := tf.Attrs["external_login_description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_option_text.external_login_description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text.external_login_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ExternalLoginDescription) == "" + } + v.Value = string(obj.ExternalLoginDescription) + v.Unknown = false + tf.Attrs["external_login_description"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_option_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["user_name_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text.user_name_button_text"}) + } else { + v, ok := tf.Attrs["user_name_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_option_text.user_name_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text.user_name_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UserNameButtonText) == "" + } + v.Value = string(obj.UserNameButtonText) + v.Unknown = false + tf.Attrs["user_name_button_text"] = v + } + } + } + v.Unknown = false + tf.Attrs["registration_option_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["registration_org_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["registration_org_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.RegistrationOrgText == nil { + v.Null = true + } else { + obj := obj.RegistrationOrgText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["email_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.email_label"}) + } else { + v, ok := tf.Attrs["email_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.email_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.EmailLabel) == "" + } + v.Value = string(obj.EmailLabel) + v.Unknown = false + tf.Attrs["email_label"] = v + } + } + { + t, ok := tf.AttrTypes["firstname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.firstname_label"}) + } else { + v, ok := tf.Attrs["firstname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.firstname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.FirstnameLabel) == "" + } + v.Value = string(obj.FirstnameLabel) + v.Unknown = false + tf.Attrs["firstname_label"] = v + } + } + { + t, ok := tf.AttrTypes["lastname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.lastname_label"}) + } else { + v, ok := tf.Attrs["lastname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.lastname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LastnameLabel) == "" + } + v.Value = string(obj.LastnameLabel) + v.Unknown = false + tf.Attrs["lastname_label"] = v + } + } + { + t, ok := tf.AttrTypes["orgname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.orgname_label"}) + } else { + v, ok := tf.Attrs["orgname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.orgname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.orgname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.OrgnameLabel) == "" + } + v.Value = string(obj.OrgnameLabel) + v.Unknown = false + tf.Attrs["orgname_label"] = v + } + } + { + t, ok := tf.AttrTypes["password_confirm_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.password_confirm_label"}) + } else { + v, ok := tf.Attrs["password_confirm_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.password_confirm_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordConfirmLabel) == "" + } + v.Value = string(obj.PasswordConfirmLabel) + v.Unknown = false + tf.Attrs["password_confirm_label"] = v + } + } + { + t, ok := tf.AttrTypes["password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.password_label"}) + } else { + v, ok := tf.Attrs["password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordLabel) == "" + } + v.Value = string(obj.PasswordLabel) + v.Unknown = false + tf.Attrs["password_label"] = v + } + } + { + t, ok := tf.AttrTypes["privacy_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.privacy_link_text"}) + } else { + v, ok := tf.Attrs["privacy_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.privacy_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyLinkText) == "" + } + v.Value = string(obj.PrivacyLinkText) + v.Unknown = false + tf.Attrs["privacy_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["save_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.save_button_text"}) + } else { + v, ok := tf.Attrs["save_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.save_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.save_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SaveButtonText) == "" + } + v.Value = string(obj.SaveButtonText) + v.Unknown = false + tf.Attrs["save_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["tos_and_privacy_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.tos_and_privacy_label"}) + } else { + v, ok := tf.Attrs["tos_and_privacy_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.tos_and_privacy_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosAndPrivacyLabel) == "" + } + v.Value = string(obj.TosAndPrivacyLabel) + v.Unknown = false + tf.Attrs["tos_and_privacy_label"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.tos_confirm"}) + } else { + v, ok := tf.Attrs["tos_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.tos_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirm) == "" + } + v.Value = string(obj.TosConfirm) + v.Unknown = false + tf.Attrs["tos_confirm"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm_and"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.tos_confirm_and"}) + } else { + v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.tos_confirm_and", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirmAnd) == "" + } + v.Value = string(obj.TosConfirmAnd) + v.Unknown = false + tf.Attrs["tos_confirm_and"] = v + } + } + { + t, ok := tf.AttrTypes["tos_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.tos_link_text"}) + } else { + v, ok := tf.Attrs["tos_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.tos_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosLinkText) == "" + } + v.Value = string(obj.TosLinkText) + v.Unknown = false + tf.Attrs["tos_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["username_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.username_label"}) + } else { + v, ok := tf.Attrs["username_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.username_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UsernameLabel) == "" + } + v.Value = string(obj.UsernameLabel) + v.Unknown = false + tf.Attrs["username_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["registration_org_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["registration_user_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["registration_user_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.RegistrationUserText == nil { + v.Null = true + } else { + obj := obj.RegistrationUserText + tf := &v + { + t, ok := tf.AttrTypes["back_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.back_button_text"}) + } else { + v, ok := tf.Attrs["back_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.back_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.back_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.BackButtonText) == "" + } + v.Value = string(obj.BackButtonText) + v.Unknown = false + tf.Attrs["back_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_org_register"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.description_org_register"}) + } else { + v, ok := tf.Attrs["description_org_register"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.description_org_register", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.description_org_register", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionOrgRegister) == "" + } + v.Value = string(obj.DescriptionOrgRegister) + v.Unknown = false + tf.Attrs["description_org_register"] = v + } + } + { + t, ok := tf.AttrTypes["email_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.email_label"}) + } else { + v, ok := tf.Attrs["email_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.email_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.email_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.EmailLabel) == "" + } + v.Value = string(obj.EmailLabel) + v.Unknown = false + tf.Attrs["email_label"] = v + } + } + { + t, ok := tf.AttrTypes["firstname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.firstname_label"}) + } else { + v, ok := tf.Attrs["firstname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.firstname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.firstname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.FirstnameLabel) == "" + } + v.Value = string(obj.FirstnameLabel) + v.Unknown = false + tf.Attrs["firstname_label"] = v + } + } + { + t, ok := tf.AttrTypes["gender_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.gender_label"}) + } else { + v, ok := tf.Attrs["gender_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.gender_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.gender_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.GenderLabel) == "" + } + v.Value = string(obj.GenderLabel) + v.Unknown = false + tf.Attrs["gender_label"] = v + } + } + { + t, ok := tf.AttrTypes["language_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.language_label"}) + } else { + v, ok := tf.Attrs["language_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.language_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.language_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LanguageLabel) == "" + } + v.Value = string(obj.LanguageLabel) + v.Unknown = false + tf.Attrs["language_label"] = v + } + } + { + t, ok := tf.AttrTypes["lastname_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.lastname_label"}) + } else { + v, ok := tf.Attrs["lastname_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.lastname_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.lastname_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LastnameLabel) == "" + } + v.Value = string(obj.LastnameLabel) + v.Unknown = false + tf.Attrs["lastname_label"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["password_confirm_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.password_confirm_label"}) + } else { + v, ok := tf.Attrs["password_confirm_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.password_confirm_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.password_confirm_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordConfirmLabel) == "" + } + v.Value = string(obj.PasswordConfirmLabel) + v.Unknown = false + tf.Attrs["password_confirm_label"] = v + } + } + { + t, ok := tf.AttrTypes["password_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.password_label"}) + } else { + v, ok := tf.Attrs["password_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.password_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.password_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PasswordLabel) == "" + } + v.Value = string(obj.PasswordLabel) + v.Unknown = false + tf.Attrs["password_label"] = v + } + } + { + t, ok := tf.AttrTypes["privacy_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.privacy_link_text"}) + } else { + v, ok := tf.Attrs["privacy_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.privacy_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.privacy_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyLinkText) == "" + } + v.Value = string(obj.PrivacyLinkText) + v.Unknown = false + tf.Attrs["privacy_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["tos_and_privacy_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.tos_and_privacy_label"}) + } else { + v, ok := tf.Attrs["tos_and_privacy_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.tos_and_privacy_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.tos_and_privacy_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosAndPrivacyLabel) == "" + } + v.Value = string(obj.TosAndPrivacyLabel) + v.Unknown = false + tf.Attrs["tos_and_privacy_label"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.tos_confirm"}) + } else { + v, ok := tf.Attrs["tos_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.tos_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirm) == "" + } + v.Value = string(obj.TosConfirm) + v.Unknown = false + tf.Attrs["tos_confirm"] = v + } + } + { + t, ok := tf.AttrTypes["tos_confirm_and"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.tos_confirm_and"}) + } else { + v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.tos_confirm_and", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosConfirmAnd) == "" + } + v.Value = string(obj.TosConfirmAnd) + v.Unknown = false + tf.Attrs["tos_confirm_and"] = v + } + } + { + t, ok := tf.AttrTypes["tos_link_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.tos_link_text"}) + } else { + v, ok := tf.Attrs["tos_link_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.tos_link_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.tos_link_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TosLinkText) == "" + } + v.Value = string(obj.TosLinkText) + v.Unknown = false + tf.Attrs["tos_link_text"] = v + } + } + { + t, ok := tf.AttrTypes["username_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.username_label"}) + } else { + v, ok := tf.Attrs["username_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.username_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UsernameLabel) == "" + } + v.Value = string(obj.UsernameLabel) + v.Unknown = false + tf.Attrs["username_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["registration_user_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["select_account_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["select_account_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.SelectAccountText == nil { + v.Null = true + } else { + obj := obj.SelectAccountText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["description_linking_process"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.description_linking_process"}) + } else { + v, ok := tf.Attrs["description_linking_process"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.description_linking_process", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.description_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DescriptionLinkingProcess) == "" + } + v.Value = string(obj.DescriptionLinkingProcess) + v.Unknown = false + tf.Attrs["description_linking_process"] = v + } + } + { + t, ok := tf.AttrTypes["other_user"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.other_user"}) + } else { + v, ok := tf.Attrs["other_user"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.other_user", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.other_user", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.OtherUser) == "" + } + v.Value = string(obj.OtherUser) + v.Unknown = false + tf.Attrs["other_user"] = v + } + } + { + t, ok := tf.AttrTypes["session_state_active"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.session_state_active"}) + } else { + v, ok := tf.Attrs["session_state_active"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.session_state_active", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.session_state_active", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SessionStateActive) == "" + } + v.Value = string(obj.SessionStateActive) + v.Unknown = false + tf.Attrs["session_state_active"] = v + } + } + { + t, ok := tf.AttrTypes["session_state_inactive"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.session_state_inactive"}) + } else { + v, ok := tf.Attrs["session_state_inactive"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.session_state_inactive", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.session_state_inactive", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SessionStateInactive) == "" + } + v.Value = string(obj.SessionStateInactive) + v.Unknown = false + tf.Attrs["session_state_inactive"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["title_linking_process"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.title_linking_process"}) + } else { + v, ok := tf.Attrs["title_linking_process"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.title_linking_process", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.title_linking_process", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.TitleLinkingProcess) == "" + } + v.Value = string(obj.TitleLinkingProcess) + v.Unknown = false + tf.Attrs["title_linking_process"] = v + } + } + { + t, ok := tf.AttrTypes["user_must_be_member_of_org"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.select_account_text.user_must_be_member_of_org"}) + } else { + v, ok := tf.Attrs["user_must_be_member_of_org"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.select_account_text.user_must_be_member_of_org", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.select_account_text.user_must_be_member_of_org", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UserMustBeMemberOfOrg) == "" + } + v.Value = string(obj.UserMustBeMemberOfOrg) + v.Unknown = false + tf.Attrs["user_must_be_member_of_org"] = v + } + } + } + v.Unknown = false + tf.Attrs["select_account_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["success_login_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.success_login_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.success_login_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["success_login_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.SuccessLoginText == nil { + v.Null = true + } else { + obj := obj.SuccessLoginText + tf := &v + { + t, ok := tf.AttrTypes["auto_redirect_description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.success_login_text.auto_redirect_description"}) + } else { + v, ok := tf.Attrs["auto_redirect_description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.success_login_text.auto_redirect_description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.success_login_text.auto_redirect_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.AutoRedirectDescription) == "" + } + v.Value = string(obj.AutoRedirectDescription) + v.Unknown = false + tf.Attrs["auto_redirect_description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.success_login_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.success_login_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.success_login_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["redirected_description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.success_login_text.redirected_description"}) + } else { + v, ok := tf.Attrs["redirected_description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.success_login_text.redirected_description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.success_login_text.redirected_description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RedirectedDescription) == "" + } + v.Value = string(obj.RedirectedDescription) + v.Unknown = false + tf.Attrs["redirected_description"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.success_login_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.success_login_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.success_login_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["success_login_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["username_change_done_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_done_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_done_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["username_change_done_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.UsernameChangeDoneText == nil { + v.Null = true + } else { + obj := obj.UsernameChangeDoneText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_done_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_done_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_done_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_done_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_done_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_done_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_done_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_done_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_done_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["username_change_done_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["username_change_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["username_change_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.UsernameChangeText == nil { + v.Null = true + } else { + obj := obj.UsernameChangeText + tf := &v + { + t, ok := tf.AttrTypes["cancel_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text.cancel_button_text"}) + } else { + v, ok := tf.Attrs["cancel_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_text.cancel_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text.cancel_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CancelButtonText) == "" + } + v.Value = string(obj.CancelButtonText) + v.Unknown = false + tf.Attrs["cancel_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["username_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.username_change_text.username_label"}) + } else { + v, ok := tf.Attrs["username_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.username_change_text.username_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.username_change_text.username_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UsernameLabel) == "" + } + v.Value = string(obj.UsernameLabel) + v.Unknown = false + tf.Attrs["username_label"] = v + } + } + } + v.Unknown = false + tf.Attrs["username_change_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["verify_mfa_otp_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_otp_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["verify_mfa_otp_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.VerifyMfaOtpText == nil { + v.Null = true + } else { + obj := obj.VerifyMfaOtpText + tf := &v + { + t, ok := tf.AttrTypes["code_label"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_otp_text.code_label"}) + } else { + v, ok := tf.Attrs["code_label"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_otp_text.code_label", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.code_label", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.CodeLabel) == "" + } + v.Value = string(obj.CodeLabel) + v.Unknown = false + tf.Attrs["code_label"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_otp_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_otp_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["next_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_otp_text.next_button_text"}) + } else { + v, ok := tf.Attrs["next_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_otp_text.next_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.next_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NextButtonText) == "" + } + v.Value = string(obj.NextButtonText) + v.Unknown = false + tf.Attrs["next_button_text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_otp_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_otp_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_otp_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + } + v.Unknown = false + tf.Attrs["verify_mfa_otp_text"] = v + } + } + } + { + a, ok := tf.AttrTypes["verify_mfa_u2f_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["verify_mfa_u2f_text"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.VerifyMfaU2FText == nil { + v.Null = true + } else { + obj := obj.VerifyMfaU2FText + tf := &v + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_u2f_text.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + t, ok := tf.AttrTypes["error_retry"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text.error_retry"}) + } else { + v, ok := tf.Attrs["error_retry"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_u2f_text.error_retry", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.error_retry", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ErrorRetry) == "" + } + v.Value = string(obj.ErrorRetry) + v.Unknown = false + tf.Attrs["error_retry"] = v + } + } + { + t, ok := tf.AttrTypes["not_supported"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text.not_supported"}) + } else { + v, ok := tf.Attrs["not_supported"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_u2f_text.not_supported", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.not_supported", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NotSupported) == "" + } + v.Value = string(obj.NotSupported) + v.Unknown = false + tf.Attrs["not_supported"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_u2f_text.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + { + t, ok := tf.AttrTypes["validate_token_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.verify_mfa_u2f_text.validate_token_text"}) + } else { + v, ok := tf.Attrs["validate_token_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.verify_mfa_u2f_text.validate_token_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.verify_mfa_u2f_text.validate_token_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ValidateTokenText) == "" + } + v.Value = string(obj.ValidateTokenText) + v.Unknown = false + tf.Attrs["validate_token_text"] = v + } + } + } + v.Unknown = false + tf.Attrs["verify_mfa_u2f_text"] = v + } + } + } + return diags +} + +// CopyMessageCustomTextFromTerraform copies contents of the source Terraform object into a target struct +func CopyMessageCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp_terraform_plugin_framework_types.Object, obj *textpb.MessageCustomText) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + { + a, ok := tf.Attrs["button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ButtonText = t + } + } + } + { + a, ok := tf.Attrs["footer_text"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.footer_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.footer_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.FooterText = t + } + } + } + { + a, ok := tf.Attrs["greeting"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.greeting"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.greeting", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Greeting = t + } + } + } + { + a, ok := tf.Attrs["pre_header"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.pre_header"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.pre_header", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PreHeader = t + } + } + } + { + a, ok := tf.Attrs["subject"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.subject"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.subject", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Subject = t + } + } + } + { + a, ok := tf.Attrs["text"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Text = t + } + } + } + { + a, ok := tf.Attrs["title"] + if !ok { + diags.Append(attrReadMissingDiag{"MessageCustomText.title"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"MessageCustomText.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Title = t + } + } + } + return diags +} + +// CopyMessageCustomTextToTerraform copies contents of the source Terraform object into a target struct +func CopyMessageCustomTextToTerraform(ctx context.Context, obj textpb.MessageCustomText, tf *github_com_hashicorp_terraform_plugin_framework_types.Object) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + tf.Null = false + tf.Unknown = false + if tf.Attrs == nil { + tf.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value) + } + { + t, ok := tf.AttrTypes["button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.button_text"}) + } else { + v, ok := tf.Attrs["button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ButtonText) == "" + } + v.Value = string(obj.ButtonText) + v.Unknown = false + tf.Attrs["button_text"] = v + } + } + { + t, ok := tf.AttrTypes["footer_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.footer_text"}) + } else { + v, ok := tf.Attrs["footer_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.footer_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.footer_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.FooterText) == "" + } + v.Value = string(obj.FooterText) + v.Unknown = false + tf.Attrs["footer_text"] = v + } + } + { + t, ok := tf.AttrTypes["greeting"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.greeting"}) + } else { + v, ok := tf.Attrs["greeting"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.greeting", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.greeting", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Greeting) == "" + } + v.Value = string(obj.Greeting) + v.Unknown = false + tf.Attrs["greeting"] = v + } + } + { + t, ok := tf.AttrTypes["pre_header"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.pre_header"}) + } else { + v, ok := tf.Attrs["pre_header"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.pre_header", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.pre_header", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PreHeader) == "" + } + v.Value = string(obj.PreHeader) + v.Unknown = false + tf.Attrs["pre_header"] = v + } + } + { + t, ok := tf.AttrTypes["subject"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.subject"}) + } else { + v, ok := tf.Attrs["subject"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.subject", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.subject", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Subject) == "" + } + v.Value = string(obj.Subject) + v.Unknown = false + tf.Attrs["subject"] = v + } + } + { + t, ok := tf.AttrTypes["text"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.text"}) + } else { + v, ok := tf.Attrs["text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Text) == "" + } + v.Value = string(obj.Text) + v.Unknown = false + tf.Attrs["text"] = v + } + } + { + t, ok := tf.AttrTypes["title"] + if !ok { + diags.Append(attrWriteMissingDiag{"MessageCustomText.title"}) + } else { + v, ok := tf.Attrs["title"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"MessageCustomText.title", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"MessageCustomText.title", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Title) == "" + } + v.Value = string(obj.Title) + v.Unknown = false + tf.Attrs["title"] = v + } + } + return diags +} + +// attrReadMissingDiag represents diagnostic message on an attribute missing in the source object +type attrReadMissingDiag struct { + Path string +} + +func (d attrReadMissingDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrReadMissingDiag) Summary() string { + return "Error reading from Terraform object" +} + +func (d attrReadMissingDiag) Detail() string { + return fmt.Sprintf("A value for %v is missing in the source Terraform object Attrs", d.Path) +} + +func (d attrReadMissingDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrReadConversionFailureDiag represents diagnostic message on a failed type conversion on read +type attrReadConversionFailureDiag struct { + Path string + Type string +} + +func (d attrReadConversionFailureDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrReadConversionFailureDiag) Summary() string { + return "Error reading from Terraform object" +} + +func (d attrReadConversionFailureDiag) Detail() string { + return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type) +} + +func (d attrReadConversionFailureDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteMissingDiag represents diagnostic message on an attribute missing in the target object +type attrWriteMissingDiag struct { + Path string +} + +func (d attrWriteMissingDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteMissingDiag) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteMissingDiag) Detail() string { + return fmt.Sprintf("A value for %v is missing in the source Terraform object AttrTypes", d.Path) +} + +func (d attrWriteMissingDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteConversionFailureDiag represents diagnostic message on a failed type conversion on write +type attrWriteConversionFailureDiag struct { + Path string + Type string +} + +func (d attrWriteConversionFailureDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteConversionFailureDiag) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteConversionFailureDiag) Detail() string { + return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type) +} + +func (d attrWriteConversionFailureDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteGeneralError represents diagnostic message on a generic error on write +type attrWriteGeneralError struct { + Path string + Err error +} + +func (d attrWriteGeneralError) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteGeneralError) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteGeneralError) Detail() string { + return fmt.Sprintf("%s: %s", d.Path, d.Err.Error()) +} + +func (d attrWriteGeneralError) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} diff --git a/go.mod b/go.mod index da021f94..20cb7e87 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,16 @@ module github.com/zitadel/terraform-provider-zitadel go 1.19 require ( - github.com/hashicorp/terraform-plugin-log v0.4.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 + github.com/envoyproxy/protoc-gen-validate v0.6.7 + github.com/gogo/protobuf v1.3.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 + github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/terraform-plugin-framework v0.15.0 + github.com/hashicorp/terraform-plugin-go v0.14.1 + github.com/hashicorp/terraform-plugin-log v0.7.0 + github.com/hashicorp/terraform-plugin-mux v0.7.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/zitadel/oidc v1.7.0 - github.com/zitadel/zitadel-go v0.3.5 github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 google.golang.org/protobuf v1.28.1 ) @@ -14,30 +20,26 @@ require ( require ( github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/envoyproxy/protoc-gen-validate v0.6.7 // indirect - github.com/fatih/color v1.7.0 // indirect + github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect - github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect - github.com/hashicorp/go-hclog v1.2.0 // indirect + github.com/hashicorp/go-hclog v1.2.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.3 // indirect + github.com/hashicorp/go-plugin v1.4.6 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.4.0 // indirect - github.com/hashicorp/hcl/v2 v2.12.0 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/hcl/v2 v2.15.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-plugin-go v0.9.0 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect + github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/kr/pretty v0.2.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect @@ -47,15 +49,15 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + github.com/zclconf/go-cty v1.12.1 // indirect + golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 // indirect - google.golang.org/grpc v1.48.0 // indirect + google.golang.org/grpc v1.50.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index d71d23d0..aec96966 100644 --- a/go.sum +++ b/go.sum @@ -56,26 +56,17 @@ cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 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/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= -github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -96,7 +87,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -109,17 +99,10 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.7 h1:qcZcULcd/abmQg6dwigimCNEyi4gg31M/xaciQlDml8= github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -128,6 +111,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= @@ -178,8 +162,9 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= 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-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -219,68 +204,61 @@ github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlI github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1/go.mod h1:chrfS3YoLAlKTRE5cFWvCbt8uGAjshktT4PveTUpsFQ= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 h1:BqHID5W5qnMkug0Z8UmL8tN0gAy4jQ+B4WFt8cCgluU= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2/go.mod h1:ZbS3MZTZq/apAfAEHGoB5HbsQQstoqP92SjAqtQ9zeg= 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/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= -github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= +github.com/hashicorp/go-hclog v1.2.1/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.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= -github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= +github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= 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.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +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/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= -github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs= github.com/hashicorp/hcl/v2 v2.12.0 h1:PsYxySWpMD4KPaoJLnsHwtK5Qptvj/4Q6s0t4sUxZf4= github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= +github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= 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.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M= -github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= -github.com/hashicorp/terraform-plugin-go v0.9.0 h1:FvLY/3z4SNVatPZdoFcyrlNbCar+WyyOTv5X4Tp+WZc= -github.com/hashicorp/terraform-plugin-go v0.9.0/go.mod h1:EawBkgjBWNf7jiKnVoyDyF39OSV+u6KUX+Y73EPj3oM= -github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps= -github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc= -github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg= +github.com/hashicorp/terraform-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q= +github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= +github.com/hashicorp/terraform-plugin-framework v0.16.0 h1:kEHh0d6dp5Ig/ey6PYXkWDZPMLIW8Me41T/Oa7bpO4s= +github.com/hashicorp/terraform-plugin-framework v0.16.0/go.mod h1:Vk5MuIJoE1qksHZawAZr6psx6YXsQBFIKDrWbROrwus= +github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek= +github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ= +github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= +github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= +github.com/hashicorp/terraform-plugin-mux v0.7.0 h1:wRbSYzg+v2sn5Mdee0UKm4YTt4wJG0LfSwtgNuBkglY= +github.com/hashicorp/terraform-plugin-mux v0.7.0/go.mod h1:Ae30Mc5lz4d1awtiCbHP0YyvgBeiQ00Q1nAq0U3lb+I= github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 h1:9fjPgCenJqnbjo95SDcbJ+YdLyEC1N35cwKWcRWhJTQ= github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0/go.mod h1:hLa0sTiySU/AWEgV2GxJh0/pQIqcCmm30IPja9N9lTg= -github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= -github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= +github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= +github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= 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/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -295,18 +273,15 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= 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/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +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= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= @@ -318,23 +293,17 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= -github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -346,13 +315,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -362,7 +330,6 @@ github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvC github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -371,19 +338,14 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= +github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -github.com/zitadel/logging v0.3.3/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.5.1/go.mod h1:s/hyqXVzchd3Y3XA2STBv2g4UKc5HeFf4Og/Mu98AYs= github.com/zitadel/oidc v1.7.0 h1:Hy24siGCg2ciQmicF6zkGpCFOQir0zOBK63CZPS3ZKM= github.com/zitadel/oidc v1.7.0/go.mod h1:lbT3Wd/8MujrbLWdVm6Ll6VJjmAUfzW9SscvB4GwLTQ= -github.com/zitadel/zitadel-go v0.3.5 h1:j0rWIs/jC39BkKUSIYzKbFhr1NQ/0KBAvC0LfsiNX4o= -github.com/zitadel/zitadel-go v0.3.5/go.mod h1:EFtsbJQRt7cjIK6zV+wwo7OWVjtxD5HaBfJ+9VxBwtI= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.4 h1:TbRSz8Sl3ZL+g3evMCeKo5CPtdHSZlaEQcmc4yghElI= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.4/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 h1:EeRJNEAlBeP0nUJ5H2SMfk+wngbowwtSMRub+/7cGxI= github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -397,7 +359,6 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -405,11 +366,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= +golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -446,7 +406,6 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -482,7 +441,6 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -530,9 +488,7 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ 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/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= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -542,13 +498,12 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -571,10 +526,8 @@ golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -585,6 +538,7 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/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-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -653,7 +607,6 @@ golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -723,7 +676,6 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 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-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -752,7 +704,6 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -801,13 +752,11 @@ google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 h1:sRT5xdTkj1Kbk30qbYC7VyMj73N5pZYsw6v+Nrzdhno= google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -839,10 +788,10 @@ google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11 google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= +google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -861,21 +810,15 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= @@ -890,4 +833,3 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/main.go b/main.go index 2822cd7f..a35e665e 100644 --- a/main.go +++ b/main.go @@ -1,22 +1,42 @@ package main import ( + "context" "flag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" + "log" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" + "github.com/zitadel/terraform-provider-zitadel/zitadel" ) func main() { + ctx := context.Background() var debug bool flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") flag.Parse() - plugin.Serve(&plugin.ServeOpts{ - Debug: debug, - ProviderFunc: func() *schema.Provider { - return zitadel.Provider() + upgradedSdkProvider, err := tf5to6server.UpgradeServer(ctx, zitadel.Provider().GRPCProvider) + if err != nil { + log.Fatal(err) + } + + providers := []func() tfprotov6.ProviderServer{ + func() tfprotov6.ProviderServer { + return upgradedSdkProvider }, - }) + providerserver.NewProtocol6(zitadel.NewProviderPV6()), + } + + muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...) + err = tf6server.Serve("registry.terraform.io/providers/zitadel/zitadel", muxServer.ProviderServer) + + if err != nil { + log.Fatalln(err.Error()) + } } diff --git a/templates/resources/domain_claimed_message_text.md.tmpl b/templates/resources/domain_claimed_message_text.md.tmpl new file mode 100644 index 00000000..ead94351 --- /dev/null +++ b/templates/resources/domain_claimed_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/domain_claimed_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/init_message_text.md.tmpl b/templates/resources/init_message_text.md.tmpl new file mode 100644 index 00000000..3adec240 --- /dev/null +++ b/templates/resources/init_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/init_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/login_texts.md.tmpl b/templates/resources/login_texts.md.tmpl new file mode 100644 index 00000000..1cc7ec62 --- /dev/null +++ b/templates/resources/login_texts.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/login_texts.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/password_reset_message_text.md.tmpl b/templates/resources/password_reset_message_text.md.tmpl new file mode 100644 index 00000000..66bdbbff --- /dev/null +++ b/templates/resources/password_reset_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/password_reset_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/passwordless_registration_message_text.md.tmpl b/templates/resources/passwordless_registration_message_text.md.tmpl new file mode 100644 index 00000000..b998aaec --- /dev/null +++ b/templates/resources/passwordless_registration_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/passwordless_registration_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/verify_email_message_text.md.tmpl b/templates/resources/verify_email_message_text.md.tmpl new file mode 100644 index 00000000..5b8a8b08 --- /dev/null +++ b/templates/resources/verify_email_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/verify_email_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/verify_phone_message_text.md.tmpl b/templates/resources/verify_phone_message_text.md.tmpl new file mode 100644 index 00000000..d471b6c7 --- /dev/null +++ b/templates/resources/verify_phone_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/verify_phone_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 2b945bd9..2fd2f346 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,12 @@ package zitadel import ( "context" + "github.com/hashicorp/terraform-plugin-framework/datasource" + fdiag "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,19 +17,24 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_claimed_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_jwt" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_texts" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/passwordless_registration_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" @@ -35,8 +46,97 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_phone_message_text" ) +var ( + _ provider.Provider = &providerPV6{} +) + +type providerPV6 struct { +} + +func NewProviderPV6() provider.Provider { + return &providerPV6{} +} + +type providerModel struct { + Insecure types.Bool `tfsdk:"insecure"` + Domain types.String `tfsdk:"domain"` + Token types.String `tfsdk:"token"` + Port types.String `tfsdk:"port"` +} + +func (p *providerPV6) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "zitadel" +} +func (p *providerPV6) GetSchema(_ context.Context) (tfsdk.Schema, fdiag.Diagnostics) { + return tfsdk.Schema{ + Attributes: map[string]tfsdk.Attribute{ + helper.DomainVar: { + Type: types.StringType, + Required: true, + Description: "Domain used to connect to the ZITADEL instance", + }, + helper.InsecureVar: { + Type: types.BoolType, + Optional: true, + Description: "Use insecure connection", + }, + helper.TokenVar: { + Type: types.StringType, + Required: true, + Description: "Path to the file containing credentials to connect to ZITADEL", + }, + helper.PortVar: { + Type: types.StringType, + Optional: true, + Description: "Used port if not the default ports 80 or 443 are configured", + }, + }, + }, nil +} + +func (p *providerPV6) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + var config providerModel + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + info, err := helper.GetClientInfo( + config.Insecure.ValueBool(), + config.Domain.ValueString(), + config.Token.ValueString(), + config.Port.ValueString(), + ) + if err != nil { + resp.Diagnostics.AddError("failed to handle provider config", err.Error()) + return + } + + resp.DataSourceData = info + resp.ResourceData = info +} + +func (p *providerPV6) DataSources(_ context.Context) []func() datasource.DataSource { + return nil +} + +func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { + return []func() resource.Resource{ + init_message_text.NewInitMessageText, + login_texts.NewLoginTexts, + password_reset_message_text.NewPasswordResetMessageText, + verify_email_message_text.NewVerifyEmailMessageText, + verify_phone_message_text.NewVerifyPhoneMessageText, + domain_claimed_message_text.NewDomainClaimedMessageText, + passwordless_registration_message_text.NewPasswordlessRegistrationMessageText, + } +} + func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ @@ -109,7 +209,12 @@ func Provider() *schema.Provider { } func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { - clientinfo, err := helper.GetClientInfo(d) + clientinfo, err := helper.GetClientInfo( + d.Get(helper.InsecureVar).(bool), + d.Get(helper.DomainVar).(string), + d.Get(helper.TokenVar).(string), + d.Get(helper.PortVar).(string), + ) if err != nil { return nil, diag.FromErr(err) } diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go new file mode 100644 index 00000000..706967d2 --- /dev/null +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -0,0 +1,254 @@ +package domain_claimed_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &domainClaimedMessageTextResource{} +) + +func NewDomainClaimedMessageText() resource.Resource { + return &domainClaimedMessageTextResource{} +} + +type domainClaimedMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *domainClaimedMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_domain_claimed_message_text" +} + +func (r *domainClaimedMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *domainClaimedMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *domainClaimedMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomDomainClaimedMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomDomainClaimedMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *domainClaimedMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomDomainClaimedMessageText(ctx, &management.GetCustomDomainClaimedMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *domainClaimedMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomDomainClaimedMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomDomainClaimedMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *domainClaimedMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomDomainClaimedMessageTextToDefault(ctx, &management.ResetCustomDomainClaimedMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index c9d75064..041ae0a8 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -3,7 +3,6 @@ package helper import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/oidc/pkg/oidc" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/management" @@ -24,20 +23,12 @@ type ClientInfo struct { Options []zitadel.Option } -func GetClientInfo(d *schema.ResourceData) (*ClientInfo, error) { - insecure := d.Get(InsecureVar).(bool) - domain := d.Get(DomainVar).(string) - options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(d.Get(TokenVar).(string)))} - - portStr := "" - port := d.Get(PortVar) - if port != nil { - portStr = port.(string) - } +func GetClientInfo(insecure bool, domain string, token string, port string) (*ClientInfo, error) { + options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(token))} issuer := "" - if portStr != "" { - domain = domain + ":" + portStr + if port != "" { + domain = domain + ":" + port issuer = domain } else { issuer = domain diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index a389519b..30b7b28e 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -1,6 +1,9 @@ package helper import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -94,3 +97,15 @@ func GetID(d *schema.ResourceData, idVar string) string { } return idStr } + +func GetStringFromAttr(ctx context.Context, attrs map[string]attr.Value, key string) string { + value, err := attrs[key].ToTerraformValue(ctx) + if err != nil { + return "" + } + var str string + if err := value.As(&str); err != nil { + return "" + } + return str +} diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go new file mode 100644 index 00000000..c7f5a81e --- /dev/null +++ b/zitadel/v2/init_message_text/resource.go @@ -0,0 +1,254 @@ +package init_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &initMessageTextResource{} +) + +func NewInitMessageText() resource.Resource { + return &initMessageTextResource{} +} + +type initMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *initMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_init_message_text" +} + +func (r *initMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *initMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *initMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomInitMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomInitMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *initMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomInitMessageText(ctx, &management.GetCustomInitMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *initMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomInitMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomInitMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *initMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomInitMessageTextToDefault(ctx, &management.ResetCustomInitMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go new file mode 100644 index 00000000..1660aa4d --- /dev/null +++ b/zitadel/v2/login_texts/resource.go @@ -0,0 +1,254 @@ +package login_texts + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &loginTextsResource{} +) + +func NewLoginTexts() resource.Resource { + return &loginTextsResource{} +} + +type loginTextsResource struct { + clientInfo *helper.ClientInfo +} + +func (r *loginTextsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_login_texts" +} + +func (r *loginTextsResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaLoginCustomText(ctx) +} + +func (r *loginTextsResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *loginTextsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.LoginCustomText{} + resp.Diagnostics.Append(text.CopyLoginCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal login texts", err.Error()) + return + } + zReq := &management.SetCustomLoginTextsRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal login texts", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomLoginText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create login texts", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *loginTextsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomLoginTexts(ctx, &management.GetCustomLoginTextsRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading login texts", "No custom login texts existing") + } + + resp.Diagnostics.Append(text.CopyLoginCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *loginTextsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.LoginCustomText{} + resp.Diagnostics.Append(text.CopyLoginCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal login texts", err.Error()) + return + } + zReq := &management.SetCustomLoginTextsRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal login texts", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomLoginText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update login texts", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *loginTextsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomLoginTextToDefault(ctx, &management.ResetCustomLoginTextsToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete login texts", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go new file mode 100644 index 00000000..0e42a703 --- /dev/null +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -0,0 +1,254 @@ +package password_reset_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &passwordResetMessageTextResource{} +) + +func NewPasswordResetMessageText() resource.Resource { + return &passwordResetMessageTextResource{} +} + +type passwordResetMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *passwordResetMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_password_reset_message_text" +} + +func (r *passwordResetMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *passwordResetMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *passwordResetMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordResetMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordResetMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordResetMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordResetMessageText(ctx, &management.GetCustomPasswordResetMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *passwordResetMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordResetMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordResetMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordResetMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordResetMessageTextToDefault(ctx, &management.ResetCustomPasswordResetMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go new file mode 100644 index 00000000..27f93f6e --- /dev/null +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -0,0 +1,254 @@ +package passwordless_registration_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &passwordlessRegistrationMessageTextResource{} +) + +func NewPasswordlessRegistrationMessageText() resource.Resource { + return &passwordlessRegistrationMessageTextResource{} +} + +type passwordlessRegistrationMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *passwordlessRegistrationMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_passwordless_registration_message_text" +} + +func (r *passwordlessRegistrationMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *passwordlessRegistrationMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *passwordlessRegistrationMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordlessRegistrationMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordlessRegistrationMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordlessRegistrationMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordlessRegistrationMessageText(ctx, &management.GetCustomPasswordlessRegistrationMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *passwordlessRegistrationMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordlessRegistrationMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordlessRegistrationMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordlessRegistrationMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordlessRegistrationMessageTextToDefault(ctx, &management.ResetCustomPasswordlessRegistrationMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go new file mode 100644 index 00000000..14f0b065 --- /dev/null +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -0,0 +1,254 @@ +package verify_email_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &verifyEmailMessageTextResource{} +) + +func NewVerifyEmailMessageText() resource.Resource { + return &verifyEmailMessageTextResource{} +} + +type verifyEmailMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *verifyEmailMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_verify_email_message_text" +} + +func (r *verifyEmailMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *verifyEmailMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *verifyEmailMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomVerifyEmailMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomVerifyEmailMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *verifyEmailMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomVerifyEmailMessageText(ctx, &management.GetCustomVerifyEmailMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *verifyEmailMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomVerifyEmailMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomVerifyEmailMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *verifyEmailMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomVerifyEmailMessageTextToDefault(ctx, &management.ResetCustomVerifyEmailMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go new file mode 100644 index 00000000..38a0f6e7 --- /dev/null +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -0,0 +1,254 @@ +package verify_phone_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &verifyPhoneMessageTextResource{} +) + +func NewVerifyPhoneMessageText() resource.Resource { + return &verifyPhoneMessageTextResource{} +} + +type verifyPhoneMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *verifyPhoneMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_verify_phone_message_text" +} + +func (r *verifyPhoneMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *verifyPhoneMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *verifyPhoneMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomVerifyPhoneMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomVerifyPhoneMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *verifyPhoneMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomVerifyPhoneMessageText(ctx, &management.GetCustomVerifyPhoneMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *verifyPhoneMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomVerifyPhoneMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomVerifyPhoneMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *verifyPhoneMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomVerifyPhoneMessageTextToDefault(ctx, &management.ResetCustomVerifyPhoneMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} From 2aacd045fb7231bb27553cc2bb1f3089e2c8e340 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 23 Nov 2022 19:01:23 +0100 Subject: [PATCH 024/260] feat(gen): add generated default text resources with docs and examples --- .../default_domain_claimed_message_text.md | 47 ++++ docs/resources/default_init_message_text.md | 47 ++++ .../default_password_reset_message_text.md | 47 ++++ ..._passwordless_registration_message_text.md | 47 ++++ .../default_verify_email_message_text.md | 47 ++++ .../default_verify_phone_message_text.md | 47 ++++ docs/resources/domain_claimed_message_text.md | 6 +- docs/resources/init_message_text.md | 6 +- docs/resources/login_texts.md | 6 +- docs/resources/password_reset_message_text.md | 6 +- .../passwordless_registration_message_text.md | 6 +- docs/resources/verify_email_message_text.md | 6 +- docs/resources/verify_phone_message_text.md | 6 +- .../default_domain_claimed_message_text.tf | 11 + .../resources/default_init_message_text.tf | 11 + .../default_password_reset_message_text.tf | 11 + ..._passwordless_registration_message_text.tf | 11 + .../default_verify_email_message_text.tf | 11 + .../default_verify_phone_message_text.tf | 11 + main.go | 8 +- ...efault_domain_claimed_message_text.md.tmpl | 16 ++ .../default_init_message_text.md.tmpl | 16 ++ ...efault_password_reset_message_text.md.tmpl | 16 ++ ...wordless_registration_message_text.md.tmpl | 16 ++ .../default_verify_email_message_text.md.tmpl | 16 ++ .../default_verify_phone_message_text.md.tmpl | 16 ++ zitadel/provider.go | 26 +- .../resource.go | 239 ++++++++++++++++++ .../v2/default_init_message_text/resource.go | 236 +++++++++++++++++ .../resource.go | 236 +++++++++++++++++ .../resource.go | 236 +++++++++++++++++ .../resource.go | 236 +++++++++++++++++ .../resource.go | 236 +++++++++++++++++ .../domain_claimed_message_text/resource.go | 2 +- zitadel/v2/init_message_text/resource.go | 2 +- zitadel/v2/login_texts/resource.go | 2 +- .../password_reset_message_text/resource.go | 2 +- .../resource.go | 2 +- .../v2/verify_email_message_text/resource.go | 2 +- .../v2/verify_phone_message_text/resource.go | 2 +- 40 files changed, 1924 insertions(+), 29 deletions(-) create mode 100644 docs/resources/default_domain_claimed_message_text.md create mode 100644 docs/resources/default_init_message_text.md create mode 100644 docs/resources/default_password_reset_message_text.md create mode 100644 docs/resources/default_passwordless_registration_message_text.md create mode 100644 docs/resources/default_verify_email_message_text.md create mode 100644 docs/resources/default_verify_phone_message_text.md create mode 100644 examples/provider/resources/default_domain_claimed_message_text.tf create mode 100644 examples/provider/resources/default_init_message_text.tf create mode 100644 examples/provider/resources/default_password_reset_message_text.tf create mode 100644 examples/provider/resources/default_passwordless_registration_message_text.tf create mode 100644 examples/provider/resources/default_verify_email_message_text.tf create mode 100644 examples/provider/resources/default_verify_phone_message_text.tf create mode 100644 templates/resources/default_domain_claimed_message_text.md.tmpl create mode 100644 templates/resources/default_init_message_text.md.tmpl create mode 100644 templates/resources/default_password_reset_message_text.md.tmpl create mode 100644 templates/resources/default_passwordless_registration_message_text.md.tmpl create mode 100644 templates/resources/default_verify_email_message_text.md.tmpl create mode 100644 templates/resources/default_verify_phone_message_text.md.tmpl create mode 100644 zitadel/v2/default_domain_claimed_message_text/resource.go create mode 100644 zitadel/v2/default_init_message_text/resource.go create mode 100644 zitadel/v2/default_password_reset_message_text/resource.go create mode 100644 zitadel/v2/default_passwordless_registration_message_text/resource.go create mode 100644 zitadel/v2/default_verify_email_message_text/resource.go create mode 100644 zitadel/v2/default_verify_phone_message_text/resource.go diff --git a/docs/resources/default_domain_claimed_message_text.md b/docs/resources/default_domain_claimed_message_text.md new file mode 100644 index 00000000..0a78f4c4 --- /dev/null +++ b/docs/resources/default_domain_claimed_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_domain_claimed_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_domain_claimed_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_domain_claimed_message_text domain_claimed_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_init_message_text.md b/docs/resources/default_init_message_text.md new file mode 100644 index 00000000..0ee31efb --- /dev/null +++ b/docs/resources/default_init_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_init_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_init_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_init_message_text init_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_password_reset_message_text.md b/docs/resources/default_password_reset_message_text.md new file mode 100644 index 00000000..05b88c16 --- /dev/null +++ b/docs/resources/default_password_reset_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_password_reset_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_password_reset_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_password_reset_message_text password_reset_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_passwordless_registration_message_text.md b/docs/resources/default_passwordless_registration_message_text.md new file mode 100644 index 00000000..6c0a0571 --- /dev/null +++ b/docs/resources/default_passwordless_registration_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_passwordless_registration_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_passwordless_registration_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_verify_email_message_text.md b/docs/resources/default_verify_email_message_text.md new file mode 100644 index 00000000..f20991a7 --- /dev/null +++ b/docs/resources/default_verify_email_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_verify_email_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_verify_email_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_verify_email_message_text verify_email_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_verify_phone_message_text.md b/docs/resources/default_verify_phone_message_text.md new file mode 100644 index 00000000..ed093981 --- /dev/null +++ b/docs/resources/default_verify_phone_message_text.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_default_verify_phone_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_verify_phone_message_text (Resource) + + + +## Example Usage + +```terraform +resource zitadel_default_verify_phone_message_text verify_phone_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md index f572ea5f..b0b6b1eb 100644 --- a/docs/resources/domain_claimed_message_text.md +++ b/docs/resources/domain_claimed_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_domain_claimed_message_text domain_claimed { - org_id = "188087895133782187" +resource zitadel_domain_claimed_message_text domain_claimed_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md index 5861e264..005ae8e2 100644 --- a/docs/resources/init_message_text.md +++ b/docs/resources/init_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_init_message_text init { - org_id = "188087895133782187" +resource zitadel_init_message_text init_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index 28116620..c7e1ff85 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_login_texts login_texts { - org_id = "188087895133782187" +resource zitadel_login_texts login_texts_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" email_verification_done_text = { diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md index 4e202e65..973be5d5 100644 --- a/docs/resources/password_reset_message_text.md +++ b/docs/resources/password_reset_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_password_reset_message_text password_reset { - org_id = "188087895133782187" +resource zitadel_password_reset_message_text password_reset_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md index 1ba31f90..6ba6a0dd 100644 --- a/docs/resources/passwordless_registration_message_text.md +++ b/docs/resources/passwordless_registration_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_passwordless_registration_message_text passwordless_registration { - org_id = "188087895133782187" +resource zitadel_passwordless_registration_message_text passwordless_registration_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md index da7e5d80..42e650fb 100644 --- a/docs/resources/verify_email_message_text.md +++ b/docs/resources/verify_email_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_email_message_text verify_email { - org_id = "188087895133782187" +resource zitadel_verify_email_message_text verify_email_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md index 3a4c5009..7b6d1a5b 100644 --- a/docs/resources/verify_phone_message_text.md +++ b/docs/resources/verify_phone_message_text.md @@ -12,8 +12,10 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_phone_message_text verify_phone { - org_id = "188087895133782187" +resource zitadel_verify_phone_message_text verify_phone_en { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id language = "en" title = "title example" diff --git a/examples/provider/resources/default_domain_claimed_message_text.tf b/examples/provider/resources/default_domain_claimed_message_text.tf new file mode 100644 index 00000000..c401364c --- /dev/null +++ b/examples/provider/resources/default_domain_claimed_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_domain_claimed_message_text domain_claimed_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/default_init_message_text.tf b/examples/provider/resources/default_init_message_text.tf new file mode 100644 index 00000000..8450094e --- /dev/null +++ b/examples/provider/resources/default_init_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_init_message_text init_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/default_password_reset_message_text.tf b/examples/provider/resources/default_password_reset_message_text.tf new file mode 100644 index 00000000..3fafca82 --- /dev/null +++ b/examples/provider/resources/default_password_reset_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_password_reset_message_text password_reset_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/default_passwordless_registration_message_text.tf b/examples/provider/resources/default_passwordless_registration_message_text.tf new file mode 100644 index 00000000..7591f22f --- /dev/null +++ b/examples/provider/resources/default_passwordless_registration_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/default_verify_email_message_text.tf b/examples/provider/resources/default_verify_email_message_text.tf new file mode 100644 index 00000000..de135c59 --- /dev/null +++ b/examples/provider/resources/default_verify_email_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_verify_email_message_text verify_email_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/examples/provider/resources/default_verify_phone_message_text.tf b/examples/provider/resources/default_verify_phone_message_text.tf new file mode 100644 index 00000000..ed0aee87 --- /dev/null +++ b/examples/provider/resources/default_verify_phone_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_verify_phone_message_text verify_phone_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} \ No newline at end of file diff --git a/main.go b/main.go index a35e665e..0596299a 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,13 @@ func main() { } muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...) - err = tf6server.Serve("registry.terraform.io/providers/zitadel/zitadel", muxServer.ProviderServer) + + opts := []tf6server.ServeOpt{} + if debug { + opts = append(opts, tf6server.WithManagedDebug()) + } + + err = tf6server.Serve("registry.terraform.io/zitadel/zitadel", muxServer.ProviderServer, opts...) if err != nil { log.Fatalln(err.Error()) diff --git a/templates/resources/default_domain_claimed_message_text.md.tmpl b/templates/resources/default_domain_claimed_message_text.md.tmpl new file mode 100644 index 00000000..8328db47 --- /dev/null +++ b/templates/resources/default_domain_claimed_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_domain_claimed_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_init_message_text.md.tmpl b/templates/resources/default_init_message_text.md.tmpl new file mode 100644 index 00000000..77e66953 --- /dev/null +++ b/templates/resources/default_init_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_init_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_password_reset_message_text.md.tmpl b/templates/resources/default_password_reset_message_text.md.tmpl new file mode 100644 index 00000000..143b5f6c --- /dev/null +++ b/templates/resources/default_password_reset_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_password_reset_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_passwordless_registration_message_text.md.tmpl b/templates/resources/default_passwordless_registration_message_text.md.tmpl new file mode 100644 index 00000000..c5cc4e95 --- /dev/null +++ b/templates/resources/default_passwordless_registration_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_passwordless_registration_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_verify_email_message_text.md.tmpl b/templates/resources/default_verify_email_message_text.md.tmpl new file mode 100644 index 00000000..dc5fd52f --- /dev/null +++ b/templates/resources/default_verify_email_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_verify_email_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_verify_phone_message_text.md.tmpl b/templates/resources/default_verify_phone_message_text.md.tmpl new file mode 100644 index 00000000..46315f47 --- /dev/null +++ b/templates/resources/default_verify_phone_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_verify_phone_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 2fd2f346..09e93341 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -16,6 +16,12 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_phone_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_claimed_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" @@ -127,13 +133,19 @@ func (p *providerPV6) DataSources(_ context.Context) []func() datasource.DataSou func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ - init_message_text.NewInitMessageText, - login_texts.NewLoginTexts, - password_reset_message_text.NewPasswordResetMessageText, - verify_email_message_text.NewVerifyEmailMessageText, - verify_phone_message_text.NewVerifyPhoneMessageText, - domain_claimed_message_text.NewDomainClaimedMessageText, - passwordless_registration_message_text.NewPasswordlessRegistrationMessageText, + init_message_text.New, + login_texts.New, + password_reset_message_text.New, + verify_email_message_text.New, + verify_phone_message_text.New, + domain_claimed_message_text.New, + passwordless_registration_message_text.New, + default_domain_claimed_message_text.New, + default_init_message_text.New, + default_password_reset_message_text.New, + default_passwordless_registration_message_text.New, + default_verify_email_message_text.New, + default_verify_phone_message_text.New, } } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource.go b/zitadel/v2/default_domain_claimed_message_text/resource.go new file mode 100644 index 00000000..df73eded --- /dev/null +++ b/zitadel/v2/default_domain_claimed_message_text/resource.go @@ -0,0 +1,239 @@ +package default_domain_claimed_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultDomainClaimedMessageTextResource{} +) + +func New() resource.Resource { + return &defaultDomainClaimedMessageTextResource{} +} + +type defaultDomainClaimedMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultDomainClaimedMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_domain_claimed_message_text" +} + +func (r *defaultDomainClaimedMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultDomainClaimedMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultDomainClaimedMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultDomainClaimedMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultDomainClaimedMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultDomainClaimedMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomDomainClaimedMessageText(ctx, &admin.GetCustomDomainClaimedMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultDomainClaimedMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultDomainClaimedMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultDomainClaimedMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultDomainClaimedMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomDomainClaimedMessageTextToDefault(ctx, &admin.ResetCustomDomainClaimedMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + + return language +} diff --git a/zitadel/v2/default_init_message_text/resource.go b/zitadel/v2/default_init_message_text/resource.go new file mode 100644 index 00000000..c78151f0 --- /dev/null +++ b/zitadel/v2/default_init_message_text/resource.go @@ -0,0 +1,236 @@ +package default_init_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultInitMessageTextResource{} +) + +func New() resource.Resource { + return &defaultInitMessageTextResource{} +} + +type defaultInitMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultInitMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_init_message_text" +} + +func (r *defaultInitMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultInitMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultInitMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultInitMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultInitMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultInitMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomInitMessageText(ctx, &admin.GetCustomInitMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultInitMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultInitMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultInitMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultInitMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomInitMessageTextToDefault(ctx, &admin.ResetCustomInitMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/default_password_reset_message_text/resource.go b/zitadel/v2/default_password_reset_message_text/resource.go new file mode 100644 index 00000000..dbcd4d5f --- /dev/null +++ b/zitadel/v2/default_password_reset_message_text/resource.go @@ -0,0 +1,236 @@ +package default_password_reset_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultPasswordResetMessageTextResource{} +) + +func New() resource.Resource { + return &defaultPasswordResetMessageTextResource{} +} + +type defaultPasswordResetMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultPasswordResetMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_password_reset_message_text" +} + +func (r *defaultPasswordResetMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultPasswordResetMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultPasswordResetMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordResetMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordResetMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordResetMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordResetMessageText(ctx, &admin.GetCustomPasswordResetMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultPasswordResetMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordResetMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordResetMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordResetMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordResetMessageTextToDefault(ctx, &admin.ResetCustomPasswordResetMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource.go b/zitadel/v2/default_passwordless_registration_message_text/resource.go new file mode 100644 index 00000000..7647ee4b --- /dev/null +++ b/zitadel/v2/default_passwordless_registration_message_text/resource.go @@ -0,0 +1,236 @@ +package default_passwordless_registration_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultPasswordlessRegistrationMessageTextResource{} +) + +func New() resource.Resource { + return &defaultPasswordlessRegistrationMessageTextResource{} +} + +type defaultPasswordlessRegistrationMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_passwordless_registration_message_text" +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordlessRegistrationMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordlessRegistrationMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordlessRegistrationMessageText(ctx, &admin.GetCustomPasswordlessRegistrationMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordlessRegistrationMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordlessRegistrationMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordlessRegistrationMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordlessRegistrationMessageTextToDefault(ctx, &admin.ResetCustomPasswordlessRegistrationMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/default_verify_email_message_text/resource.go b/zitadel/v2/default_verify_email_message_text/resource.go new file mode 100644 index 00000000..724f00a2 --- /dev/null +++ b/zitadel/v2/default_verify_email_message_text/resource.go @@ -0,0 +1,236 @@ +package default_verify_email_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultVerifyEmailMessageTextResource{} +) + +func New() resource.Resource { + return &defaultVerifyEmailMessageTextResource{} +} + +type defaultVerifyEmailMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultVerifyEmailMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_verify_email_message_text" +} + +func (r *defaultVerifyEmailMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultVerifyEmailMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultVerifyEmailMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultVerifyEmailMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultVerifyEmailMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultVerifyEmailMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomVerifyEmailMessageText(ctx, &admin.GetCustomVerifyEmailMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultVerifyEmailMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultVerifyEmailMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultVerifyEmailMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultVerifyEmailMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomVerifyEmailMessageTextToDefault(ctx, &admin.ResetCustomVerifyEmailMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/default_verify_phone_message_text/resource.go b/zitadel/v2/default_verify_phone_message_text/resource.go new file mode 100644 index 00000000..b85802de --- /dev/null +++ b/zitadel/v2/default_verify_phone_message_text/resource.go @@ -0,0 +1,236 @@ +package default_verify_phone_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultVerifyPhoneMessageTextResource{} +) + +func New() resource.Resource { + return &defaultVerifyPhoneMessageTextResource{} +} + +type defaultVerifyPhoneMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultVerifyPhoneMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_verify_phone_message_text" +} + +func (r *defaultVerifyPhoneMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultVerifyPhoneMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultVerifyPhoneMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultVerifyPhoneMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultVerifyPhoneMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultVerifyPhoneMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomVerifyPhoneMessageText(ctx, &admin.GetCustomVerifyPhoneMessageTextRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + if zResp.CustomText.IsDefault { + resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultVerifyPhoneMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultVerifyPhoneMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultVerifyPhoneMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultVerifyPhoneMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomVerifyPhoneMessageTextToDefault(ctx, &admin.ResetCustomVerifyPhoneMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index 706967d2..687db48d 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &domainClaimedMessageTextResource{} ) -func NewDomainClaimedMessageText() resource.Resource { +func New() resource.Resource { return &domainClaimedMessageTextResource{} } diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go index c7f5a81e..57b2f3c6 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/v2/init_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &initMessageTextResource{} ) -func NewInitMessageText() resource.Resource { +func New() resource.Resource { return &initMessageTextResource{} } diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index 1660aa4d..19f74b1c 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &loginTextsResource{} ) -func NewLoginTexts() resource.Resource { +func New() resource.Resource { return &loginTextsResource{} } diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index 0e42a703..7a254618 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &passwordResetMessageTextResource{} ) -func NewPasswordResetMessageText() resource.Resource { +func New() resource.Resource { return &passwordResetMessageTextResource{} } diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go index 27f93f6e..8f6e8226 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &passwordlessRegistrationMessageTextResource{} ) -func NewPasswordlessRegistrationMessageText() resource.Resource { +func New() resource.Resource { return &passwordlessRegistrationMessageTextResource{} } diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index 14f0b065..2c2f0e07 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &verifyEmailMessageTextResource{} ) -func NewVerifyEmailMessageText() resource.Resource { +func New() resource.Resource { return &verifyEmailMessageTextResource{} } diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index 38a0f6e7..8802fb91 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -28,7 +28,7 @@ var ( _ resource.Resource = &verifyPhoneMessageTextResource{} ) -func NewVerifyPhoneMessageText() resource.Resource { +func New() resource.Resource { return &verifyPhoneMessageTextResource{} } From f13d293a207f6c774e44fd1689e404d0775b6e72 Mon Sep 17 00:00:00 2001 From: Stefan Benz <46600784+stebenz@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:06:20 +0100 Subject: [PATCH 025/260] fix: update zitadel/v2/default_lockout_policy/funcs.go Co-authored-by: Elio Bischof --- zitadel/v2/default_lockout_policy/funcs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index a63637f7..12760576 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -30,7 +30,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ - MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + MaxPasswordAttempts: d.Get(maxPasswordAttemptsVar).(uint32), }) if err != nil { return diag.Errorf("failed to update default lockout policy: %v", err) From 9d7f31455bc9080f548cd1020c7918f554e06269 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 29 Nov 2022 10:56:50 +0100 Subject: [PATCH 026/260] fix: delete changed checks on zitadel side --- zitadel/v2/default_label_policy/funcs.go | 49 +++-- zitadel/v2/default_login_policy/funcs.go | 236 ++++++++++++----------- 2 files changed, 155 insertions(+), 130 deletions(-) diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 0bffc3a3..368367b5 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -29,27 +29,38 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdateLabelPolicy(ctx, &admin.UpdateLabelPolicyRequest{ - PrimaryColor: d.Get(primaryColorVar).(string), - HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), - WarnColor: d.Get(warnColorVar).(string), - BackgroundColor: d.Get(backgroundColorVar).(string), - FontColor: d.Get(fontColorVar).(string), - PrimaryColorDark: d.Get(primaryColorDarkVar).(string), - BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), - WarnColorDark: d.Get(warnColorDarkVar).(string), - FontColorDark: d.Get(fontColorDarkVar).(string), - DisableWatermark: d.Get(disableWatermarkVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update default label policy: %v", err) + if d.HasChanges( + primaryColorVar, + hideLoginNameSuffixVar, + warnColorVar, + backgroundColorVar, + fontColorVar, + primaryColorDarkVar, + backgroundColorDarkVar, + warnColorDarkVar, + fontColorDarkVar, + disableWatermarkVar, + ) { + resp, err := client.UpdateLabelPolicy(ctx, &admin.UpdateLabelPolicyRequest{ + PrimaryColor: d.Get(primaryColorVar).(string), + HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), + WarnColor: d.Get(warnColorVar).(string), + BackgroundColor: d.Get(backgroundColorVar).(string), + FontColor: d.Get(fontColorVar).(string), + PrimaryColorDark: d.Get(primaryColorDarkVar).(string), + BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), + WarnColorDark: d.Get(warnColorDarkVar).(string), + FontColorDark: d.Get(fontColorDarkVar).(string), + DisableWatermark: d.Get(disableWatermarkVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update default label policy: %v", err) + } + d.SetId(resp.Details.ResourceOwner) } - d.SetId(resp.Details.ResourceOwner) - active := d.Get(setActiveVar) - if active != nil { - activeBool := active.(bool) - if activeBool { + if d.HasChange(setActiveVar) { + if d.Get(setActiveVar).(bool) { if _, err := client.ActivateLabelPolicy(ctx, &admin.ActivateLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate default label policy: %v", err) } diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 00ab57d0..b7567e91 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -37,55 +37,50 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) - allowRegister := d.Get(allowRegisterVar).(bool) - allowExternalIdp := d.Get(allowExternalIDPVar).(bool) - forceMfa := d.Get(forceMFAVar).(bool) - passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) - hidePasswordReset := d.Get(hidePasswordResetVar).(bool) - ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) - defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) - currentPolicy := current.GetPolicy() - if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || - currentPolicy.GetAllowRegister() != allowRegister || - currentPolicy.GetAllowExternalIdp() != allowExternalIdp || - currentPolicy.GetForceMfa() != forceMfa || - currentPolicy.GetPasswordlessType() != passwordlessType || - currentPolicy.GetHidePasswordReset() != hidePasswordReset || - currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || - currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { + if d.HasChanges(passwordCheckLifetimeVar, + externalLoginCheckLifetimeVar, + mfaInitSkipLifetimeVar, + secondFactorCheckLifetimeVar, + multiFactorCheckLifetimeVar, + allowUsernamePasswordVar, + allowRegisterVar, + allowExternalIDPVar, + forceMFAVar, + passwordlessTypeVar, + hidePasswordResetVar, + ignoreUnknownUsernamesVar, + defaultRedirectURIVar, + ) { + passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + externalLoginCheckLT, err := time.ParseDuration(d.Get(externalLoginCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + mfaInitSkipLT, err := time.ParseDuration(d.Get(mfaInitSkipLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + secondFactorCheckLT, err := time.ParseDuration(d.Get(secondFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + multiFactorCheckLT, err := time.ParseDuration(d.Get(multiFactorCheckLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } resp, err := client.UpdateLoginPolicy(ctx, &admin.UpdateLoginPolicyRequest{ - AllowUsernamePassword: allowUsernamePassword, - AllowRegister: allowRegister, - AllowExternalIdp: allowExternalIdp, - ForceMfa: forceMfa, - PasswordlessType: passwordlessType, - HidePasswordReset: hidePasswordReset, - IgnoreUnknownUsernames: ignoreUnkownUsernames, - DefaultRedirectUri: defaultRedirectUri, + AllowUsernamePassword: d.Get(allowUsernamePasswordVar).(bool), + AllowRegister: d.Get(allowRegisterVar).(bool), + AllowExternalIdp: d.Get(allowExternalIDPVar).(bool), + ForceMfa: d.Get(forceMFAVar).(bool), + PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), + HidePasswordReset: d.Get(hidePasswordResetVar).(bool), + IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), + DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), PasswordCheckLifetime: durationpb.New(passwordCheckLT), ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), @@ -98,66 +93,71 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia d.SetId(resp.GetDetails().GetResourceOwner()) } - secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) - currentSecondFactors := make([]helper.Stringify, 0) - for _, secondFactor := range current.GetPolicy().GetSecondFactors() { - currentSecondFactors = append(currentSecondFactors, secondFactor) - } - addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) - - for _, factor := range addSecondFactor { - if _, err := client.AddSecondFactorToLoginPolicy(ctx, &admin.AddSecondFactorToLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) + if d.HasChange(secondFactorsVar) { + secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) + currentSecondFactors := make([]helper.Stringify, 0) + for _, secondFactor := range current.GetPolicy().GetSecondFactors() { + currentSecondFactors = append(currentSecondFactors, secondFactor) } - } - for _, factor := range deleteSecondFactors { - if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &admin.RemoveSecondFactorFromLoginPolicyRequest{ - Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + + for _, factor := range addSecondFactor { + if _, err := client.AddSecondFactorToLoginPolicy(ctx, &admin.AddSecondFactorToLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteSecondFactors { + if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &admin.RemoveSecondFactorFromLoginPolicyRequest{ + Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } } } - multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) - currentMultiFactors := make([]helper.Stringify, 0) - for _, multiFactor := range current.GetPolicy().GetMultiFactors() { - currentMultiFactors = append(currentMultiFactors, multiFactor) - } - addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) - for _, factor := range addMultiFactor { - if _, err := client.AddMultiFactorToLoginPolicy(ctx, &admin.AddMultiFactorToLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) + if d.HasChange(multiFactorsVar) { + multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) + currentMultiFactors := make([]helper.Stringify, 0) + for _, multiFactor := range current.GetPolicy().GetMultiFactors() { + currentMultiFactors = append(currentMultiFactors, multiFactor) } - } - for _, factor := range deleteMultiFactors { - if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &admin.RemoveMultiFactorFromLoginPolicyRequest{ - Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), - }); err != nil { - return diag.FromErr(err) + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) + for _, factor := range addMultiFactor { + if _, err := client.AddMultiFactorToLoginPolicy(ctx, &admin.AddMultiFactorToLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } + } + for _, factor := range deleteMultiFactors { + if _, err := client.RemoveMultiFactorFromLoginPolicy(ctx, &admin.RemoveMultiFactorFromLoginPolicyRequest{ + Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), + }); err != nil { + return diag.FromErr(err) + } } } - idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) - currentIdps := make([]helper.Stringify, 0) - for _, currentIdp := range current.GetPolicy().GetIdps() { - currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) - } - addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) - for _, addIdp := range addIdps { - if _, err := client.AddIDPToLoginPolicy(ctx, &admin.AddIDPToLoginPolicyRequest{IdpId: addIdp}); err != nil { - return diag.FromErr(err) + if d.HasChange(idpsVar) { + idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) + currentIdps := make([]helper.Stringify, 0) + for _, currentIdp := range current.GetPolicy().GetIdps() { + currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) } - } - for _, deleteIdp := range deleteIdps { - if _, err := client.RemoveIDPFromLoginPolicy(ctx, &admin.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { - return diag.FromErr(err) + addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) + for _, addIdp := range addIdps { + if _, err := client.AddIDPToLoginPolicy(ctx, &admin.AddIDPToLoginPolicyRequest{IdpId: addIdp}); err != nil { + return diag.FromErr(err) + } + } + for _, deleteIdp := range deleteIdps { + if _, err := client.RemoveIDPFromLoginPolicy(ctx, &admin.RemoveIDPFromLoginPolicyRequest{IdpId: deleteIdp}); err != nil { + return diag.FromErr(err) + } } } - return nil } @@ -178,29 +178,43 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { d.SetId("") return nil - //return diag.Errorf("failed to get login policy: %v", err) } - policy := resp.Policy set := map[string]interface{}{ - allowUsernamePasswordVar: policy.GetAllowUsernamePassword(), - allowRegisterVar: policy.GetAllowRegister(), - allowExternalIDPVar: policy.GetAllowExternalIdp(), - forceMFAVar: policy.GetForceMfa(), - passwordlessTypeVar: policy.GetPasswordlessType().String(), - hidePasswordResetVar: policy.GetHidePasswordReset(), - passwordCheckLifetimeVar: policy.GetPasswordCheckLifetime().AsDuration().String(), - externalLoginCheckLifetimeVar: policy.GetExternalLoginCheckLifetime().AsDuration().String(), - mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), - secondFactorCheckLifetimeVar: policy.GetSecondFactorCheckLifetime().AsDuration().String(), - multiFactorCheckLifetimeVar: policy.GetMultiFactorCheckLifetime().AsDuration().String(), - } + allowUsernamePasswordVar: resp.Policy.GetAllowUsernamePassword(), + allowRegisterVar: resp.Policy.GetAllowRegister(), + allowExternalIDPVar: resp.Policy.GetAllowExternalIdp(), + forceMFAVar: resp.Policy.GetForceMfa(), + passwordlessTypeVar: resp.Policy.GetPasswordlessType().String(), + hidePasswordResetVar: resp.Policy.GetHidePasswordReset(), + passwordCheckLifetimeVar: resp.Policy.GetPasswordCheckLifetime().AsDuration().String(), + externalLoginCheckLifetimeVar: resp.Policy.GetExternalLoginCheckLifetime().AsDuration().String(), + mfaInitSkipLifetimeVar: resp.Policy.GetMfaInitSkipLifetime().AsDuration().String(), + secondFactorCheckLifetimeVar: resp.Policy.GetSecondFactorCheckLifetime().AsDuration().String(), + multiFactorCheckLifetimeVar: resp.Policy.GetMultiFactorCheckLifetime().AsDuration().String(), + } + + secondFactors := &schema.Set{} + for _, factor := range resp.Policy.SecondFactors { + secondFactors.Add(policy.SecondFactorType_name[int32(factor.Number())]) + } + set[secondFactorsVar] = secondFactors + multiFactors := &schema.Set{} + for _, factor := range resp.Policy.MultiFactors { + multiFactors.Add(policy.MultiFactorType_name[int32(factor.Number())]) + } + set[multiFactorsVar] = multiFactors + idps := &schema.Set{} + for _, idp := range resp.Policy.Idps { + idps.Add(idp.IdpId) + } + set[idpsVar] = idps for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of login policy: %v", k, err) } } - d.SetId(policy.GetDetails().GetResourceOwner()) + d.SetId(resp.Policy.GetDetails().GetResourceOwner()) return nil } From bb37b078ae5b82245ac7345225e0d6647774087b Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 29 Nov 2022 13:14:53 +0100 Subject: [PATCH 027/260] fix: delete changed checks on zitadel side --- docs/resources/application_oidc.md | 2 +- docs/resources/human_user.md | 2 +- docs/resources/org_idp_jwt.md | 2 +- docs/resources/trigger_actions.md | 2 +- zitadel/v2/app_key/resource.go | 2 +- zitadel/v2/application_api/funcs.go | 37 ++++------ zitadel/v2/application_api/resource.go | 2 +- zitadel/v2/application_oidc/funcs.go | 85 +++++++---------------- zitadel/v2/application_oidc/resource.go | 12 ++-- zitadel/v2/helper/helper.go | 16 ++--- zitadel/v2/human_user/funcs.go | 92 +++++++++---------------- zitadel/v2/human_user/resource.go | 2 +- zitadel/v2/login_policy/funcs.go | 86 +++++++---------------- zitadel/v2/machine_key/resource.go | 2 +- zitadel/v2/machine_user/funcs.go | 14 +--- zitadel/v2/org_idp_jwt/funcs.go | 62 +++++------------ zitadel/v2/org_idp_jwt/resource.go | 2 +- zitadel/v2/org_idp_oidc/funcs.go | 76 +++++++------------- zitadel/v2/org_idp_oidc/resource.go | 2 +- zitadel/v2/project/funcs.go | 3 +- zitadel/v2/project/resource.go | 2 +- zitadel/v2/sms_provider_twilio/funcs.go | 23 ++----- zitadel/v2/smtp_config/funcs.go | 35 +++------- zitadel/v2/trigger_actions/resource.go | 4 +- 24 files changed, 179 insertions(+), 388 deletions(-) diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 98d905c3..b8a569b1 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -58,7 +58,7 @@ resource zitadel_application_oidc application_oidc_min { - `org_id` (String) orgID of the application - `project_id` (String) ID of the project - `redirect_uris` (List of String) RedirectURIs -- `response_types` (List of String) Response type, supported values: OIDC_APP_TYPE_NATIVE, OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT +- `response_types` (List of String) Response type, supported values: OIDC_RESPONSE_TYPE_CODE, OIDC_RESPONSE_TYPE_ID_TOKEN, OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN ### Optional diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 2ef6c5ea..65ef9d7c 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -56,7 +56,7 @@ resource zitadel_human_user human_user_min { ### Optional - `display_name` (String) Display name of the user -- `gender` (String) Gender of the user, supported values: GENDER_DIVERSE, GENDER_UNSPECIFIED, GENDER_FEMALE, GENDER_MALE +- `gender` (String) Gender of the user, supported values: GENDER_UNSPECIFIED, GENDER_FEMALE, GENDER_MALE, GENDER_DIVERSE - `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 011eca9d..23d0cd85 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -38,7 +38,7 @@ resource zitadel_org_idp_jwt jwt_idp { - `keys_endpoint` (String) the endpoint to the key (JWK) which are used to sign the JWT with - `name` (String) Name of the IDP - `org_id` (String) ID of the organization -- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_GOOGLE, STYLING_TYPE_UNSPECIFIED +- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE ### Read-Only diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index 3f39e004..c58ed7fa 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -30,7 +30,7 @@ resource zitadel_trigger_actions trigger_actions { - `action_ids` (Set of String) IDs of the triggered actions - `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_UNSPECIFIED, FLOW_TYPE_EXTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION ### Read-Only diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index b497d489..139662ba 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -34,7 +34,7 @@ func GetResource() *schema.Resource { keyTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the app key" + helper.DescriptionEnumValuesList(authn.KeyType_value), + Description: "Type of the app key" + helper.DescriptionEnumValuesList(authn.KeyType_name), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index ea2c7b3c..8a6c8509 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -51,34 +51,25 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } projectID := d.Get(projectIDVar).(string) - apiApp, err := getApp(ctx, client, projectID, d.Id()) - if d.HasChange(nameVar) { - appName := d.Get(nameVar).(string) - if apiApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ - ProjectId: projectID, - AppId: d.Id(), - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) - } + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: d.Id(), + Name: d.Get(nameVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) } } if d.HasChanges(authMethodTypeVar) { - apiConfig := apiApp.GetApiConfig() - authMethod := d.Get(authMethodTypeVar).(string) - if apiConfig.GetAuthMethodType().String() != authMethod { - _, err = client.UpdateAPIAppConfig(ctx, &management.UpdateAPIAppConfigRequest{ - ProjectId: projectID, - AppId: d.Id(), - AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[authMethod]), - }) - if err != nil { - return diag.Errorf("failed to update applicationAPI: %v", err) - } + _, err = client.UpdateAPIAppConfig(ctx, &management.UpdateAPIAppConfigRequest{ + ProjectId: projectID, + AppId: d.Id(), + AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[d.Get(authMethodTypeVar).(string)]), + }) + if err != nil { + return diag.Errorf("failed to update applicationAPI: %v", err) } } return nil diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index bed39031..2cb75947 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -33,7 +33,7 @@ func GetResource() *schema.Resource { authMethodTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Auth method type" + helper.DescriptionEnumValuesList(app.APIAuthMethodType_value), + Description: "Auth method type" + helper.DescriptionEnumValuesList(app.APIAuthMethodType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.APIAuthMethodType_value) }, diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index 598ee1d9..befec7e6 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -3,7 +3,6 @@ package application_oidc import ( "context" "fmt" - "reflect" "time" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -54,22 +53,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } projectID := d.Get(projectIDVar).(string) - oidcApp, err := getApp(ctx, client, projectID, d.Id()) - if err != nil { - return diag.FromErr(err) - } if d.HasChange(nameVar) { - appName := d.Get(nameVar).(string) - if oidcApp.GetName() != appName { - _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ - ProjectId: projectID, - AppId: d.Id(), - Name: appName, - }) - if err != nil { - return diag.Errorf("failed to update application: %v", err) - } + _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ + ProjectId: projectID, + AppId: d.Id(), + Name: d.Get(nameVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update application: %v", err) } } @@ -98,50 +90,25 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - oidcConfig := oidcApp.GetOidcConfig() - redirecURIs := interfaceToStringSlice(d.Get(redirectURIsVar)) - appType := d.Get(appTypeVar).(string) - authMethodType := d.Get(authMethodTypeVar).(string) - postLogoutRedirectURIs := interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)) - devMode := d.Get(devModeVar).(bool) - accessTokenType := d.Get(accessTokenTypeVar).(string) - accessTokenRoleAssertion := d.Get(accessTokenRoleAssertionVar).(bool) - idTokenRoleAssertion := d.Get(idTokenRoleAssertionVar).(bool) - idTokenUserinfoAssertion := d.Get(idTokenUserinfoAssertionVar).(bool) - clockSkew := durationpb.New(dur) - additionalOrigins := interfaceToStringSlice(d.Get(additionalOriginsVar)) - - if !reflect.DeepEqual(redirecURIs, oidcConfig.GetRedirectUris()) || - !reflect.DeepEqual(respTypes, oidcConfig.GetResponseTypes()) || - !reflect.DeepEqual(grantTypes, oidcConfig.GetGrantTypes()) || - appType != oidcConfig.AppType.String() || - authMethodType != oidcConfig.AuthMethodType.String() || - !reflect.DeepEqual(postLogoutRedirectURIs, oidcConfig.GetPostLogoutRedirectUris()) || - devMode != oidcConfig.DevMode || - accessTokenType != oidcConfig.AccessTokenType.String() || - accessTokenRoleAssertion != oidcConfig.AccessTokenRoleAssertion || - clockSkew.String() != oidcConfig.ClockSkew.String() || - !reflect.DeepEqual(additionalOrigins, oidcConfig.GetAdditionalOrigins()) { - - _, err = client.UpdateOIDCAppConfig(ctx, &management.UpdateOIDCAppConfigRequest{ - ProjectId: projectID, - AppId: d.Id(), - RedirectUris: redirecURIs, - ResponseTypes: respTypes, - GrantTypes: grantTypes, - AppType: app.OIDCAppType(app.OIDCAppType_value[appType]), - AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[authMethodType]), - PostLogoutRedirectUris: postLogoutRedirectURIs, - DevMode: devMode, - AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[accessTokenType]), - AccessTokenRoleAssertion: accessTokenRoleAssertion, - IdTokenRoleAssertion: idTokenRoleAssertion, - IdTokenUserinfoAssertion: idTokenUserinfoAssertion, - AdditionalOrigins: additionalOrigins, - }) - if err != nil { - return diag.Errorf("failed to update applicationOIDC: %v", err) - } + _, err = client.UpdateOIDCAppConfig(ctx, &management.UpdateOIDCAppConfigRequest{ + ProjectId: projectID, + AppId: d.Id(), + RedirectUris: interfaceToStringSlice(d.Get(redirectURIsVar)), + ResponseTypes: respTypes, + GrantTypes: grantTypes, + AppType: app.OIDCAppType(app.OIDCAppType_value[d.Get(appTypeVar).(string)]), + AuthMethodType: app.OIDCAuthMethodType(app.OIDCAuthMethodType_value[d.Get(authMethodTypeVar).(string)]), + PostLogoutRedirectUris: interfaceToStringSlice(d.Get(postLogoutRedirectURIsVar)), + DevMode: d.Get(devModeVar).(bool), + AccessTokenType: app.OIDCTokenType(app.OIDCTokenType_value[d.Get(accessTokenTypeVar).(string)]), + AccessTokenRoleAssertion: d.Get(accessTokenRoleAssertionVar).(bool), + IdTokenRoleAssertion: d.Get(idTokenRoleAssertionVar).(bool), + IdTokenUserinfoAssertion: d.Get(idTokenUserinfoAssertionVar).(bool), + AdditionalOrigins: interfaceToStringSlice(d.Get(additionalOriginsVar)), + ClockSkew: durationpb.New(dur), + }) + if err != nil { + return diag.Errorf("failed to update applicationOIDC: %v", err) } } return nil diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index db3b1f92..6e1c1455 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -44,7 +44,7 @@ func GetResource() *schema.Resource { Type: schema.TypeString, }, Required: true, - Description: "Response type" + helper.DescriptionEnumValuesList(app.OIDCAppType_value), + Description: "Response type" + helper.DescriptionEnumValuesList(app.OIDCResponseType_name), /* Not yet supported ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return enumValuesValidation(applicationAuthMethodTypeVar, value, app.OIDCResponseType_value) @@ -56,7 +56,7 @@ func GetResource() *schema.Resource { Type: schema.TypeString, }, Required: true, - Description: "Grant types" + helper.DescriptionEnumValuesList(app.OIDCGrantType_value), + Description: "Grant types" + helper.DescriptionEnumValuesList(app.OIDCGrantType_name), /* Not yet supported ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return enumValuesValidation(applicationGrantTypesVar, value, app.OIDCGrantType_value) @@ -65,7 +65,7 @@ func GetResource() *schema.Resource { appTypeVar: { Type: schema.TypeString, Optional: true, - Description: "App type" + helper.DescriptionEnumValuesList(app.OIDCAppType_value), + Description: "App type" + helper.DescriptionEnumValuesList(app.OIDCAppType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(appTypeVar, value, app.OIDCAppType_value) }, @@ -74,7 +74,7 @@ func GetResource() *schema.Resource { authMethodTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Auth method type" + helper.DescriptionEnumValuesList(app.OIDCAuthMethodType_value), + Description: "Auth method type" + helper.DescriptionEnumValuesList(app.OIDCAuthMethodType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(authMethodTypeVar, value, app.OIDCAuthMethodType_value) }, @@ -91,7 +91,7 @@ func GetResource() *schema.Resource { versionVar: { Type: schema.TypeString, Optional: true, - Description: "Version" + helper.DescriptionEnumValuesList(app.OIDCVersion_value), + Description: "Version" + helper.DescriptionEnumValuesList(app.OIDCVersion_name), Default: app.OIDCVersion_name[0], }, devModeVar: { @@ -102,7 +102,7 @@ func GetResource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Access token type" + helper.DescriptionEnumValuesList(app.OIDCTokenType_value), + Description: "Access token type" + helper.DescriptionEnumValuesList(app.OIDCTokenType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(accessTokenTypeVar, value, app.OIDCTokenType_value) }, diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index c5fc3506..b967f538 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -37,14 +37,14 @@ func SetToStringSlice(set *schema.Set) []string { return slice } -func GetAddAndDelete(current []Stringify, desired []string) ([]string, []string) { +func GetAddAndDelete(current []string, desired []string) ([]string, []string) { addSlice := make([]string, 0) deleteSlice := make([]string, 0) for _, desiredItem := range desired { found := false for _, currentItem := range current { - if desiredItem == currentItem.String() { + if desiredItem == currentItem { found = true } } @@ -56,12 +56,12 @@ func GetAddAndDelete(current []Stringify, desired []string) ([]string, []string) for _, currentItem := range current { found := false for _, desiredItem := range desired { - if desiredItem == currentItem.String() { + if desiredItem == currentItem { found = true } } if !found { - deleteSlice = append(deleteSlice, currentItem.String()) + deleteSlice = append(deleteSlice, currentItem) } } @@ -107,13 +107,11 @@ func GetID(d *schema.ResourceData, idVar string) string { return idStr } -func DescriptionEnumValuesList(enum map[string]int32) string { +func DescriptionEnumValuesList(enum map[int32]string) string { str := ", supported values: " values := make([]string, len(enum)) - i := 0 - for k := range enum { - values[i] = k - i++ + for i := 0; i < len(enum); i++ { + values[i] = enum[int32(i)] } str += strings.Join(values, ", ") return str diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index e9f7832a..ea05bdbd 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -113,80 +113,50 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - currentUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - return diag.FromErr(err) - } - if d.HasChange(userNameVar) { - username := d.Get(userNameVar).(string) - if currentUser.GetUser().GetUserName() != username { - _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ - UserId: d.Id(), - UserName: username, - }) - if err != nil { - return diag.Errorf("failed to update username: %v", err) - } + _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ + UserId: d.Id(), + UserName: d.Get(userNameVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update username: %v", err) } } - currentHuman := currentUser.GetUser().GetHuman() if d.HasChanges(firstNameVar, lastNameVar, nickNameVar, displayNameVar, preferredLanguageVar, genderVar) { - nickname := d.Get(nickNameVar) - displayname := d.Get(displayNameVar) - prefLang := d.Get(preferredLanguageVar) - gender := d.Get(genderVar) - - if currentHuman.GetProfile().GetFirstName() != d.Get(firstNameVar).(string) || - currentHuman.GetProfile().GetLastName() != d.Get(lastNameVar).(string) || - (nickname != nil && currentHuman.GetProfile().GetNickName() != nickname.(string)) || - (displayname != nil && currentHuman.GetProfile().GetDisplayName() != displayname.(string)) || - (prefLang != nil && currentHuman.GetProfile().GetPreferredLanguage() != prefLang.(string)) || - (gender != nil && currentHuman.GetProfile().GetGender().String() != gender.(string)) { - - _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ - UserId: d.Id(), - FirstName: d.Get(firstNameVar).(string), - LastName: d.Get(lastNameVar).(string), - NickName: d.Get(nickNameVar).(string), - DisplayName: d.Get(displayNameVar).(string), - PreferredLanguage: d.Get(preferredLanguageVar).(string), - Gender: user.Gender(user.Gender_value[gender.(string)]), - }) - if err != nil { - return diag.Errorf("failed to update human profile: %v", err) - } + _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ + UserId: d.Id(), + FirstName: d.Get(firstNameVar).(string), + LastName: d.Get(lastNameVar).(string), + NickName: d.Get(nickNameVar).(string), + DisplayName: d.Get(displayNameVar).(string), + PreferredLanguage: d.Get(preferredLanguageVar).(string), + Gender: user.Gender(user.Gender_value[d.Get(genderVar).(string)]), + }) + if err != nil { + return diag.Errorf("failed to update human profile: %v", err) } } if d.HasChanges(emailVar, isEmailVerifiedVar) { - email := d.Get(emailVar) - emailVerfied := d.Get(isEmailVerifiedVar) - if currentHuman.GetEmail().GetEmail() != email.(string) || currentHuman.GetEmail().GetIsEmailVerified() != emailVerfied.(bool) { - _, err = client.UpdateHumanEmail(ctx, &management.UpdateHumanEmailRequest{ - UserId: d.Id(), - Email: email.(string), - IsEmailVerified: emailVerfied.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human email: %v", err) - } + _, err = client.UpdateHumanEmail(ctx, &management.UpdateHumanEmailRequest{ + UserId: d.Id(), + Email: d.Get(emailVar).(string), + IsEmailVerified: d.Get(isEmailVerifiedVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update human email: %v", err) } } if d.HasChanges(phoneVar, isPhoneVerifiedVar) { - phone := d.Get(phoneVar) - phoneVerified := d.Get(isPhoneVerifiedVar) - if currentHuman.GetPhone().GetPhone() != phone.(string) || currentHuman.GetPhone().GetIsPhoneVerified() != phoneVerified.(bool) { - _, err = client.UpdateHumanPhone(ctx, &management.UpdateHumanPhoneRequest{ - UserId: d.Id(), - Phone: phone.(string), - IsPhoneVerified: phoneVerified.(bool), - }) - if err != nil { - return diag.Errorf("failed to update human phone: %v", err) - } + _, err = client.UpdateHumanPhone(ctx, &management.UpdateHumanPhoneRequest{ + UserId: d.Id(), + Phone: d.Get(phoneVar).(string), + IsPhoneVerified: d.Get(isPhoneVerifiedVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update human phone: %v", err) } } return nil diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index d2f2e2a7..ea83f64c 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -82,7 +82,7 @@ func GetResource() *schema.Resource { genderVar: { Type: schema.TypeString, Optional: true, - Description: "Gender of the user" + helper.DescriptionEnumValuesList(user.Gender_value), + Description: "Gender of the user" + helper.DescriptionEnumValuesList(user.Gender_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(genderVar, value.(string), user.Gender_value) }, diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index f548999c..e8c39b56 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -50,11 +50,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - current, err := client.GetLoginPolicy(ctx, &management.GetLoginPolicyRequest{}) - if err != nil { - return diag.FromErr(err) - } - d.SetId(org) if d.HasChanges( allowUsernamePasswordVar, @@ -91,55 +86,29 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - - allowUsernamePassword := d.Get(allowUsernamePasswordVar).(bool) - allowRegister := d.Get(allowRegisterVar).(bool) - allowExternalIdp := d.Get(allowExternalIDPVar).(bool) - forceMfa := d.Get(forceMFAVar).(bool) - passwordlessType := policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]) - hidePasswordReset := d.Get(hidePasswordResetVar).(bool) - ignoreUnkownUsernames := d.Get(ignoreUnknownUsernamesVar).(bool) - defaultRedirectUri := d.Get(defaultRedirectURIVar).(string) - currentPolicy := current.GetPolicy() - - if currentPolicy.GetAllowUsernamePassword() != allowUsernamePassword || - currentPolicy.GetAllowRegister() != allowRegister || - currentPolicy.GetAllowExternalIdp() != allowExternalIdp || - currentPolicy.GetForceMfa() != forceMfa || - currentPolicy.GetPasswordlessType() != passwordlessType || - currentPolicy.GetHidePasswordReset() != hidePasswordReset || - currentPolicy.GetIgnoreUnknownUsernames() != ignoreUnkownUsernames || - currentPolicy.GetDefaultRedirectUri() != defaultRedirectUri { - - _, err = client.UpdateCustomLoginPolicy(ctx, &management.UpdateCustomLoginPolicyRequest{ - AllowUsernamePassword: allowUsernamePassword, - AllowRegister: allowRegister, - AllowExternalIdp: allowExternalIdp, - ForceMfa: forceMfa, - PasswordlessType: passwordlessType, - HidePasswordReset: hidePasswordReset, - IgnoreUnknownUsernames: ignoreUnkownUsernames, - DefaultRedirectUri: defaultRedirectUri, - PasswordCheckLifetime: durationpb.New(passwordCheckLT), - ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), - MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), - SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), - MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), - }) - if err != nil { - return diag.Errorf("failed to update login policy: %v", err) - } + _, err = client.UpdateCustomLoginPolicy(ctx, &management.UpdateCustomLoginPolicyRequest{ + AllowUsernamePassword: d.Get(allowUsernamePasswordVar).(bool), + AllowRegister: d.Get(allowRegisterVar).(bool), + AllowExternalIdp: d.Get(allowExternalIDPVar).(bool), + ForceMfa: d.Get(forceMFAVar).(bool), + PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), + HidePasswordReset: d.Get(hidePasswordResetVar).(bool), + IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), + DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), + PasswordCheckLifetime: durationpb.New(passwordCheckLT), + ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), + MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), + SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), + MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + }) + if err != nil { + return diag.Errorf("failed to update login policy: %v", err) } } if d.HasChange(secondFactorsVar) { - secondFactors := helper.GetOkSetToStringSlice(d, secondFactorsVar) - currentSecondFactors := make([]helper.Stringify, 0) - - for _, secondFactor := range current.GetPolicy().GetSecondFactors() { - currentSecondFactors = append(currentSecondFactors, secondFactor) - } - addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + o, n := d.GetChange(secondFactorsVar) + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) for _, factor := range addSecondFactor { if _, err := client.AddSecondFactorToLoginPolicy(ctx, &management.AddSecondFactorToLoginPolicyRequest{ @@ -158,13 +127,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(multiFactorsVar) { - multiFactors := helper.GetOkSetToStringSlice(d, multiFactorsVar) - currentMultiFactors := make([]helper.Stringify, 0) + o, n := d.GetChange(multiFactorsVar) + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) - for _, multiFactor := range current.GetPolicy().GetMultiFactors() { - currentMultiFactors = append(currentMultiFactors, multiFactor) - } - addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) for _, factor := range addMultiFactor { if _, err := client.AddMultiFactorToLoginPolicy(ctx, &management.AddMultiFactorToLoginPolicyRequest{ Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), @@ -182,13 +147,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(idpsVar) { - idps := helper.GetOkSetToStringSlice(d, idpsVar) - currentIdps := make([]helper.Stringify, 0) + o, n := d.GetChange(idpsVar) + addIdps, deleteIdps := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) - for _, currentIdp := range current.GetPolicy().GetIdps() { - currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) - } - addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) for _, addIdp := range addIdps { var ownertype idp.IDPOwnerType _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) @@ -207,7 +168,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } } - return nil } diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index 2df251cc..72c1b339 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -28,7 +28,7 @@ func GetResource() *schema.Resource { keyTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the machine key" + helper.DescriptionEnumValuesList(authn.KeyType_value), + Description: "Type of the machine key" + helper.DescriptionEnumValuesList(authn.KeyType_name), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 1da37f94..615058aa 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -71,24 +71,17 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - currentUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: d.Id()}) - if err != nil { - return diag.FromErr(err) - } - - username := d.Get(userNameVar).(string) - if currentUser.GetUser().GetUserName() != username { + if d.HasChange(userNameVar) { _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ UserId: d.Id(), - UserName: username, + UserName: d.Get(userNameVar).(string), }) if err != nil { return diag.Errorf("failed to update username: %v", err) } } - currentMachine := currentUser.GetUser().GetMachine() - if currentMachine.GetName() != d.Get(nameVar).(string) || currentMachine.GetDescription() != d.Get(descriptionVar).(string) { + if d.HasChanges(nameVar, descriptionVar) { _, err := client.UpdateMachine(ctx, &management.UpdateMachineRequest{ UserId: d.Id(), Name: d.Get(nameVar).(string), @@ -98,7 +91,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to update machine user: %v", err) } } - return nil } diff --git a/zitadel/v2/org_idp_jwt/funcs.go b/zitadel/v2/org_idp_jwt/funcs.go index 994c4042..f73c25f0 100644 --- a/zitadel/v2/org_idp_jwt/funcs.go +++ b/zitadel/v2/org_idp_jwt/funcs.go @@ -47,10 +47,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - stylingType := d.Get(stylingTypeVar) resp, err := client.AddOrgJWTIDP(ctx, &management.AddOrgJWTIDPRequest{ Name: d.Get(nameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), JwtEndpoint: d.Get(jwtEndpointVar).(string), Issuer: d.Get(issuerVar).(string), KeysEndpoint: d.Get(keysEndpointVar).(string), @@ -77,53 +76,28 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: d.Get("id").(string)}) - if err != nil { - return diag.Errorf("failed to read jwt idp: %v", err) - } - d.SetId(resp.GetIdp().GetId()) - if d.HasChanges(nameVar, stylingTypeVar, autoRegisterVar) { - name := d.Get(nameVar).(string) - stylingType := d.Get(stylingTypeVar).(string) - autoRegister := d.Get(autoRegisterVar).(bool) - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ - IdpId: d.Id(), - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp: %v", err) - } + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: d.Id(), + Name: d.Get(nameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), + AutoRegister: d.Get(autoRegisterVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update jwt idp: %v", err) } } if d.HasChanges(jwtEndpointVar, issuerVar, keysEndpointVar, headerNameVar) { - jwt := resp.GetIdp().GetJwtConfig() - jwtEndpoint := d.Get(jwtEndpointVar).(string) - issuer := d.Get(issuerVar).(string) - keysEndpoint := d.Get(keysEndpointVar).(string) - headerName := d.Get(headerNameVar).(string) - - if jwt.GetJwtEndpoint() != jwtEndpoint || - jwt.GetIssuer() != issuer || - jwt.GetKeysEndpoint() != keysEndpoint || - jwt.GetHeaderName() != headerName { - - _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ - IdpId: d.Id(), - JwtEndpoint: jwtEndpoint, - Issuer: issuer, - KeysEndpoint: keysEndpoint, - HeaderName: headerName, - }) - if err != nil { - return diag.Errorf("failed to update jwt idp config: %v", err) - } + _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ + IdpId: d.Id(), + JwtEndpoint: d.Get(jwtEndpointVar).(string), + Issuer: d.Get(issuerVar).(string), + KeysEndpoint: d.Get(keysEndpointVar).(string), + HeaderName: d.Get(headerNameVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update jwt idp config: %v", err) } } return nil diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index c8a00ae7..1d295089 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -27,7 +27,7 @@ func GetResource() *schema.Resource { stylingTypeVar: { Type: schema.TypeString, Required: true, - Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_value), + Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) }, diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index b8207409..f949e2b4 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -2,7 +2,6 @@ package org_idp_oidc import ( "context" - "reflect" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -48,18 +47,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - stylingType := d.Get(stylingTypeVar) - displayNameMapping := d.Get(displayNameMappingVar).(string) - usernameMapping := d.Get(usernameMappingVar).(string) resp, err := client.AddOrgOIDCIDP(ctx, &management.AddOrgOIDCIDPRequest{ Name: d.Get(nameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType.(string)]), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), ClientId: d.Get(clientIDVar).(string), ClientSecret: d.Get(clientSecretVar).(string), Issuer: d.Get(issuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, scopesVar), - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(displayNameMappingVar).(string)]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), AutoRegister: d.Get(autoRegisterVar).(bool), }) if err != nil { @@ -83,58 +79,32 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: d.Id()}) - if err != nil { - return diag.Errorf("failed to read oidc idp: %v", err) - } - d.SetId(resp.GetIdp().GetId()) - if d.HasChanges(nameVar, stylingTypeVar, autoRegisterVar) { - name := d.Get(nameVar).(string) - stylingType := d.Get(stylingTypeVar).(string) - autoRegister := d.Get(autoRegisterVar).(bool) - if resp.GetIdp().GetName() != name || - resp.GetIdp().GetStylingType().String() != stylingType || - resp.GetIdp().GetAutoRegister() != autoRegister { - _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ - IdpId: d.Id(), - Name: name, - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[stylingType]), - AutoRegister: autoRegister, - }) - if err != nil { - return diag.Errorf("failed to update oidc idp: %v", err) - } + _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ + IdpId: d.Id(), + Name: d.Get(nameVar).(string), + StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), + AutoRegister: d.Get(autoRegisterVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update oidc idp: %v", err) } } if d.HasChanges(clientIDVar, clientSecretVar, issuerVar, displayNameMappingVar, usernameMappingVar, scopesVar) { - oidc := resp.GetIdp().GetOidcConfig() - clientID := d.Get(clientIDVar).(string) - clientSecret := d.Get(clientSecretVar).(string) - issuer := d.Get(issuerVar).(string) - displayNameMapping := d.Get(displayNameMappingVar).(string) - usernameMapping := d.Get(usernameMappingVar).(string) - scopes := helper.GetOkSetToStringSlice(d, scopesVar) - - if oidc.GetClientId() != clientID || - oidc.GetIssuer() != issuer || - !reflect.DeepEqual(oidc.GetScopes(), scopes) || - oidc.GetDisplayNameMapping().String() != displayNameMapping || - oidc.GetUsernameMapping().String() != usernameMapping { - _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ - IdpId: d.Id(), - ClientId: clientID, - ClientSecret: clientSecret, - Issuer: issuer, - Scopes: scopes, - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[displayNameMapping]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[usernameMapping]), - }) - if err != nil { - return diag.Errorf("failed to update oidc idp config: %v", err) - } + _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ + IdpId: d.Id(), + ClientId: d.Get(clientIDVar).(string), + ClientSecret: d.Get(clientSecretVar).(string), + Issuer: d.Get(issuerVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, scopesVar), + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(displayNameMappingVar).(string)]), + UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), + }) + if err != nil { + return diag.Errorf("failed to update oidc idp config: %v", err) } + } return nil } diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index 19358fc8..dccef37d 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -27,7 +27,7 @@ func GetResource() *schema.Resource { stylingTypeVar: { Type: schema.TypeString, Required: true, - Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_value), + Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) }, diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go index 652819eb..7a31f8b9 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/v2/project/funcs.go @@ -47,14 +47,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - plSetting := d.Get(privateLabelingSettingVar).(string) _, err = client.UpdateProject(ctx, &management.UpdateProjectRequest{ Id: d.Id(), Name: d.Get(nameVar).(string), ProjectRoleCheck: d.Get(roleCheckVar).(bool), ProjectRoleAssertion: d.Get(roleAssertionVar).(bool), HasProjectCheck: d.Get(hasProjectCheckVar).(bool), - PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[plSetting]), + PrivateLabelingSetting: project.PrivateLabelingSetting(project.PrivateLabelingSetting_value[d.Get(privateLabelingSettingVar).(string)]), }) if err != nil { return diag.Errorf("failed to update project: %v", err) diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index b3fb1392..caa867d6 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -50,7 +50,7 @@ func GetResource() *schema.Resource { privateLabelingSettingVar: { Type: schema.TypeString, Optional: true, - Description: "Defines from where the private labeling should be triggered" + helper.DescriptionEnumValuesList(project.PrivateLabelingSetting_value), + Description: "Defines from where the private labeling should be triggered" + helper.DescriptionEnumValuesList(project.PrivateLabelingSetting_name), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(privateLabelingSettingVar, value, project.PrivateLabelingSetting_value) }, diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go index de57aef3..412a2123 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -71,24 +71,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges(senderNumberVar, sidVar) { - sms, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{}) + _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ + Id: d.Id(), + Sid: d.Get(sidVar).(string), + SenderNumber: d.Get(senderNumberVar).(string), + }) if err != nil { - return diag.FromErr(err) - } - - sid := d.Get(sidVar).(string) - senderNumber := d.Get(senderNumberVar).(string) - twilio := sms.Config.GetTwilio() - if twilio.Sid != sid || - twilio.SenderNumber != senderNumber { - _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ - Id: d.Id(), - Sid: sid, - SenderNumber: senderNumber, - }) - if err != nil { - return diag.Errorf("failed to update sms provider twilio: %v", err) - } + return diag.Errorf("failed to update sms provider twilio: %v", err) } } diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index 403b832e..d6f7ed1c 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -76,34 +76,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges(senderAddressVar, senderNameVar, tlsVar, hostVar, userVar) { - smtp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) + _, err = client.UpdateSMTPConfig(ctx, &admin.UpdateSMTPConfigRequest{ + SenderAddress: d.Get(senderAddressVar).(string), + SenderName: d.Get(senderNameVar).(string), + Host: d.Get(hostVar).(string), + Tls: d.Get(tlsVar).(bool), + User: d.Get(userVar).(string), + }) if err != nil { - return diag.FromErr(err) - } - - senderAddress := d.Get(senderAddressVar).(string) - senderName := d.Get(senderNameVar).(string) - tls := d.Get(tlsVar).(bool) - host := d.Get(hostVar).(string) - user := d.Get(userVar).(string) - - if smtp.SmtpConfig.SenderName != senderName || - smtp.SmtpConfig.SenderAddress != senderAddress || - smtp.SmtpConfig.Tls != tls || - smtp.SmtpConfig.Host != host || - smtp.SmtpConfig.User != user { - - req := &admin.UpdateSMTPConfigRequest{ - SenderAddress: senderAddress, - SenderName: senderName, - Host: host, - Tls: tls, - User: user, - } - _, err = client.UpdateSMTPConfig(ctx, req) - if err != nil { - return diag.Errorf("failed to update smtp config: %v", err) - } + return diag.Errorf("failed to update smtp config: %v", err) } } diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 75d06d4a..84838b72 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -22,7 +22,7 @@ func GetResource() *schema.Resource { flowTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(action.FlowType_value), + Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(action.FlowType_name), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(flowTypeVar, value, action.FlowType_value) @@ -31,7 +31,7 @@ func GetResource() *schema.Resource { triggerTypeVar: { Type: schema.TypeString, Required: true, - Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(action.TriggerType_value), + Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(action.TriggerType_name), ForceNew: true, ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(triggerTypeVar, value, action.TriggerType_value) From 0aed58cf90cfa350d209ac4a6d326836fdbdfedd Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 8 Dec 2022 14:26:54 +0100 Subject: [PATCH 028/260] fix: some code fixes for policies --- zitadel/v2/default_login_policy/funcs.go | 32 +++------- zitadel/v2/label_policy/funcs.go | 60 +++++++++++-------- zitadel/v2/lockout_policy/funcs.go | 4 +- zitadel/v2/login_policy/funcs.go | 1 - .../v2/password_complexity_policy/funcs.go | 1 - zitadel/v2/privacy_policy/funcs.go | 1 - 6 files changed, 43 insertions(+), 56 deletions(-) diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index b7567e91..ceb623b0 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -32,11 +32,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - current, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) - if err != nil { - return diag.FromErr(err) - } - if d.HasChanges(passwordCheckLifetimeVar, externalLoginCheckLifetimeVar, mfaInitSkipLifetimeVar, @@ -71,7 +66,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - resp, err := client.UpdateLoginPolicy(ctx, &admin.UpdateLoginPolicyRequest{ AllowUsernamePassword: d.Get(allowUsernamePasswordVar).(bool), AllowRegister: d.Get(allowRegisterVar).(bool), @@ -94,12 +88,8 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(secondFactorsVar) { - secondFactors := helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set)) - currentSecondFactors := make([]helper.Stringify, 0) - for _, secondFactor := range current.GetPolicy().GetSecondFactors() { - currentSecondFactors = append(currentSecondFactors, secondFactor) - } - addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(currentSecondFactors, secondFactors) + o, n := d.GetChange(secondFactorsVar) + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) for _, factor := range addSecondFactor { if _, err := client.AddSecondFactorToLoginPolicy(ctx, &admin.AddSecondFactorToLoginPolicyRequest{ @@ -118,12 +108,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(multiFactorsVar) { - multiFactors := helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set)) - currentMultiFactors := make([]helper.Stringify, 0) - for _, multiFactor := range current.GetPolicy().GetMultiFactors() { - currentMultiFactors = append(currentMultiFactors, multiFactor) - } - addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(currentMultiFactors, multiFactors) + o, n := d.GetChange(multiFactorsVar) + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) + for _, factor := range addMultiFactor { if _, err := client.AddMultiFactorToLoginPolicy(ctx, &admin.AddMultiFactorToLoginPolicyRequest{ Type: policy.MultiFactorType(policy.MultiFactorType_value[factor]), @@ -141,12 +128,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(idpsVar) { - idps := helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set)) - currentIdps := make([]helper.Stringify, 0) - for _, currentIdp := range current.GetPolicy().GetIdps() { - currentIdps = append(currentIdps, &helper.Stringified{currentIdp.IdpId}) - } - addIdps, deleteIdps := helper.GetAddAndDelete(currentIdps, idps) + o, n := d.GetChange(idpsVar) + addIdps, deleteIdps := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) + for _, addIdp := range addIdps { if _, err := client.AddIDPToLoginPolicy(ctx, &admin.AddIDPToLoginPolicyRequest{IdpId: addIdp}); err != nil { return diag.FromErr(err) diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index 201f2d9b..2193bd61 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -46,27 +46,38 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - _, err = client.UpdateCustomLabelPolicy(ctx, &management.UpdateCustomLabelPolicyRequest{ - PrimaryColor: d.Get(primaryColorVar).(string), - HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), - WarnColor: d.Get(warnColorVar).(string), - BackgroundColor: d.Get(backgroundColorVar).(string), - FontColor: d.Get(fontColorVar).(string), - PrimaryColorDark: d.Get(primaryColorDarkVar).(string), - BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), - WarnColorDark: d.Get(warnColorDarkVar).(string), - FontColorDark: d.Get(fontColorDarkVar).(string), - DisableWatermark: d.Get(disableWatermarkVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update label policy: %v", err) + if d.HasChanges( + primaryColorVar, + hideLoginNameSuffixVar, + warnColorVar, + backgroundColorVar, + fontColorVar, + primaryColorDarkVar, + backgroundColorDarkVar, + warnColorDarkVar, + fontColorDarkVar, + disableWatermarkVar, + ) { + resp, err := client.UpdateCustomLabelPolicy(ctx, &management.UpdateCustomLabelPolicyRequest{ + PrimaryColor: d.Get(primaryColorVar).(string), + HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), + WarnColor: d.Get(warnColorVar).(string), + BackgroundColor: d.Get(backgroundColorVar).(string), + FontColor: d.Get(fontColorVar).(string), + PrimaryColorDark: d.Get(primaryColorDarkVar).(string), + BackgroundColorDark: d.Get(backgroundColorDarkVar).(string), + WarnColorDark: d.Get(warnColorDarkVar).(string), + FontColorDark: d.Get(fontColorDarkVar).(string), + DisableWatermark: d.Get(disableWatermarkVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update label policy: %v", err) + } + d.SetId(resp.Details.ResourceOwner) } - d.SetId(org) - active := d.Get(setActiveVar) - if active != nil { - activeBool := active.(bool) - if activeBool { + if d.HasChange(setActiveVar) { + if d.Get(setActiveVar).(bool) { if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate label policy: %v", err) } @@ -106,15 +117,12 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } d.SetId(org) - active := d.Get(setActiveVar) - if active != nil { - activeBool := active.(bool) - if activeBool { - if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { - return diag.Errorf("failed to activate label policy: %v", err) - } + if d.Get(setActiveVar).(bool) { + if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { + return diag.Errorf("failed to activate label policy: %v", err) } } + return nil } diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go index 759f8baa..c73bf70b 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/v2/lockout_policy/funcs.go @@ -40,8 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) - client, err := helper.GetManagementClient(clientinfo, org) + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -52,7 +51,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to update lockout policy: %v", err) } - d.SetId(org) return nil } diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index e8c39b56..809f6c36 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -50,7 +50,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - d.SetId(org) if d.HasChanges( allowUsernamePasswordVar, allowRegisterVar, diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go index cbe7e01e..c02bbae7 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -56,7 +56,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to update password complexity policy: %v", err) } - d.SetId(org) return nil } diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index 671455d4..d9f711ea 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -54,7 +54,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to update privacy policy: %v", err) } - d.SetId(org) return nil } From 9da37ca8c8170def509541007c1b41c65142fe78 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 8 Dec 2022 16:31:03 +0100 Subject: [PATCH 029/260] fix: check for not found error in read functions and some review changes --- zitadel/v2/action/funcs.go | 3 +-- zitadel/v2/app_key/funcs.go | 5 ++++- zitadel/v2/application_api/funcs.go | 19 ++++++------------ zitadel/v2/application_oidc/funcs.go | 20 ++++++------------- zitadel/v2/default_domain_policy/funcs.go | 6 ++++-- zitadel/v2/default_label_policy/funcs.go | 5 ++++- zitadel/v2/default_lockout_policy/funcs.go | 7 +++++-- zitadel/v2/default_lockout_policy/resource.go | 2 +- zitadel/v2/default_login_policy/funcs.go | 5 ++++- zitadel/v2/default_login_policy/resource.go | 2 +- .../funcs.go | 5 ++++- zitadel/v2/default_privacy_policy/funcs.go | 5 ++++- zitadel/v2/domain/funcs.go | 3 +-- zitadel/v2/domain_policy/funcs.go | 5 ++++- zitadel/v2/helper/client.go | 9 +++++++++ zitadel/v2/human_user/funcs.go | 5 ++++- zitadel/v2/label_policy/funcs.go | 5 ++++- zitadel/v2/lockout_policy/funcs.go | 5 ++++- zitadel/v2/login_policy/funcs.go | 5 ++++- zitadel/v2/machine_key/funcs.go | 7 +++++-- zitadel/v2/machine_user/funcs.go | 5 ++++- zitadel/v2/org_idp_jwt/funcs.go | 5 ++++- zitadel/v2/org_idp_oidc/funcs.go | 5 ++++- zitadel/v2/org_member/funcs.go | 3 +-- .../v2/password_complexity_policy/funcs.go | 5 ++++- zitadel/v2/pat/funcs.go | 7 +++++-- zitadel/v2/privacy_policy/funcs.go | 5 ++++- zitadel/v2/project/funcs.go | 5 ++++- zitadel/v2/project_grant/funcs.go | 5 ++++- zitadel/v2/project_grant_member/funcs.go | 3 +-- zitadel/v2/project_member/funcs.go | 3 +-- zitadel/v2/sms_provider_twilio/funcs.go | 6 +++++- zitadel/v2/smtp_config/funcs.go | 6 +++++- zitadel/v2/user_grant/funcs.go | 3 +-- 34 files changed, 126 insertions(+), 68 deletions(-) diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go index 0b2e4af8..f9496533 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/v2/action/funcs.go @@ -121,8 +121,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list actions") } if len(resp.Result) == 1 { diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/app_key/funcs.go index 4015b135..830acff7 100644 --- a/zitadel/v2/app_key/funcs.go +++ b/zitadel/v2/app_key/funcs.go @@ -98,10 +98,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn AppId: appID, KeyId: d.Id(), }) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get app key") + } d.SetId(resp.GetKey().GetId()) set := map[string]interface{}{ diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index 8a6c8509..b6fb8269 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -2,12 +2,10 @@ package application_api import ( "context" - "fmt" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" @@ -123,12 +121,16 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - app, err := getApp(ctx, client, d.Get(projectIDVar).(string), helper.GetID(d, appIDVar)) - if err != nil { + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, appIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get application api") + } + app := resp.GetApp() api := app.GetApiConfig() set := map[string]interface{}{ orgIDVar: app.GetDetails().GetResourceOwner(), @@ -143,12 +145,3 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(app.GetId()) return nil } - -func getApp(ctx context.Context, client *management2.Client, projectID string, appID string) (*app.App, error) { - resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: projectID, AppId: appID}) - if err != nil { - return nil, fmt.Errorf("failed to read applicationAPI: %v", err) - } - - return resp.GetApp(), err -} diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index befec7e6..15eb9c34 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -2,13 +2,11 @@ package application_oidc import ( "context" - "fmt" "time" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - management2 "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" @@ -190,13 +188,16 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) - oidcApp, err := getApp(ctx, client, projectID, helper.GetID(d, appIDVar)) - if err != nil { + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, appIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get application oidc") + } + oidcApp := resp.GetApp() oidc := oidcApp.GetOidcConfig() grantTypes := make([]string, 0) for _, grantType := range oidc.GetGrantTypes() { @@ -246,12 +247,3 @@ func interfaceToStringSlice(in interface{}) []string { } return ret } - -func getApp(ctx context.Context, client *management2.Client, projectID string, appID string) (*app.App, error) { - resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: projectID, AppId: appID}) - if err != nil { - return nil, fmt.Errorf("failed to read project: %v", err) - } - - return resp.GetApp(), err -} diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index d5e7c985..c2aa2014 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -55,11 +55,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetDomainPolicy(ctx, &admin.GetDomainPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } - + if err != nil { + return diag.Errorf("failed to get default domain policy") + } policy := resp.Policy set := map[string]interface{}{ userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 368367b5..4cc5c058 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -83,10 +83,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetLabelPolicy(ctx, &admin.GetLabelPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get default label policy") + } policy := resp.Policy set := map[string]interface{}{ diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index 12760576..ce18b739 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -30,7 +30,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ - MaxPasswordAttempts: d.Get(maxPasswordAttemptsVar).(uint32), + MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), }) if err != nil { return diag.Errorf("failed to update default lockout policy: %v", err) @@ -53,10 +53,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetLockoutPolicy(ctx, &admin.GetLockoutPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get default lockout policy") + } policy := resp.Policy set := map[string]interface{}{ diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/v2/default_lockout_policy/resource.go index aa6ead9a..ef03d14a 100644 --- a/zitadel/v2/default_lockout_policy/resource.go +++ b/zitadel/v2/default_lockout_policy/resource.go @@ -11,7 +11,7 @@ func GetResource() *schema.Resource { maxPasswordAttemptsVar: { Type: schema.TypeInt, Required: true, - Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset.", + Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correctly or the password is reset.", }, }, DeleteContext: delete, diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index ceb623b0..01cdc5a4 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -159,10 +159,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get default login policy") + } set := map[string]interface{}{ allowUsernamePasswordVar: resp.Policy.GetAllowUsernamePassword(), diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 84c8f535..3c913272 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -94,7 +94,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed idps to login or register", }, }, diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go index 4afd1581..d6cd96f1 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -57,10 +57,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetPasswordComplexityPolicy(ctx, &admin.GetPasswordComplexityPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get default password complexity policy") + } policy := resp.Policy set := map[string]interface{}{ diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index b8c4fe75..f3b1291d 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -55,10 +55,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetPrivacyPolicy(ctx, &admin.GetPrivacyPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to default privacy policy") + } policy := resp.Policy set := map[string]interface{}{ diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index f030bb81..42d73489 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -84,8 +84,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list domains") } if len(resp.Result) == 1 { diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 9f3a730b..0ffe638c 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -104,10 +104,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetDomainPolicy(ctx, &management.GetDomainPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get domain policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index c9d75064..53765235 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -9,6 +9,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/middleware" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) const ( @@ -91,3 +93,10 @@ func GetManagementClient(info *ClientInfo, orgID string) (*management.Client, er } return client, nil } + +func IgnoreIfNotFoundError(err error) error { + if code := status.Code(err); code == codes.NotFound { + return nil + } + return err +} diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index ea05bdbd..53bef6a5 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -176,10 +176,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get user") + } user := respUser.GetUser() set := map[string]interface{}{ diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index 2193bd61..fbaafb7d 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -141,10 +141,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetPreviewLabelPolicy(ctx, &management.GetPreviewLabelPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get label policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go index c73bf70b..cf4d043d 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/v2/lockout_policy/funcs.go @@ -93,10 +93,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetLockoutPolicy(ctx, &management.GetLockoutPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get lockout policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 809f6c36..c76b8c73 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -271,10 +271,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetLoginPolicy(ctx, &management.GetLoginPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get login policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go index 6c063a78..746bbe9b 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/v2/machine_key/funcs.go @@ -94,12 +94,15 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn UserId: userID, KeyId: d.Id(), }) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } - d.SetId(resp.GetKey().GetId()) + if err != nil { + return diag.Errorf("failed to get machine key") + } + d.SetId(resp.GetKey().GetId()) set := map[string]interface{}{ expirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), userIDVar: userID, diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 615058aa..2fa45eea 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -108,10 +108,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get user") + } user := respUser.GetUser() set := map[string]interface{}{ diff --git a/zitadel/v2/org_idp_jwt/funcs.go b/zitadel/v2/org_idp_jwt/funcs.go index f73c25f0..2c5772e3 100644 --- a/zitadel/v2/org_idp_jwt/funcs.go +++ b/zitadel/v2/org_idp_jwt/funcs.go @@ -117,10 +117,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: helper.GetID(d, idpIDVar)}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get org idp jwt") + } idp := resp.GetIdp() jwt := idp.GetJwtConfig() diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index f949e2b4..5683b382 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -123,10 +123,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: helper.GetID(d, idpIDVar)}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get org idp oidc") + } idp := resp.GetIdp() oidc := idp.GetOidcConfig() diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index 3e8eb4bd..53d4bed9 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -108,8 +108,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }}, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list org members") } if len(resp.Result) == 1 { diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go index c02bbae7..e4d5b0b4 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -102,10 +102,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetPasswordComplexityPolicy(ctx, &management.GetPasswordComplexityPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get password complexity policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go index 9107039c..93d71f98 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/v2/pat/funcs.go @@ -91,10 +91,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn UserId: userID, TokenId: d.Id(), }) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get pat") + } set := map[string]interface{}{ expirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), @@ -103,7 +106,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } for k, v := range set { if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of project: %v", k, err) + return diag.Errorf("failed to set %s of pat: %v", k, err) } } d.SetId(resp.GetToken().GetId()) diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index d9f711ea..ee270b41 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -98,10 +98,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetPrivacyPolicy(ctx, &management.GetPrivacyPolicyRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get privacy policy") + } policy := resp.Policy if policy.GetIsDefault() == true { diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go index 7a31f8b9..cc0f99b4 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/v2/project/funcs.go @@ -104,10 +104,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetProjectByID(ctx, &management.GetProjectByIDRequest{Id: helper.GetID(d, projectIDVar)}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get project") + } project := resp.GetProject() set := map[string]interface{}{ diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go index 9760e9a7..42684684 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/v2/project_grant/funcs.go @@ -97,10 +97,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetProjectGrantByID(ctx, &management.GetProjectGrantByIDRequest{ProjectId: d.Get(projectIDVar).(string), GrantId: d.Id()}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get projectgrant") + } projectGrant := resp.GetProjectGrant() set := map[string]interface{}{ diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index d0bd3741..a990ea83 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -119,8 +119,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }}, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list projectgrantmembers") } if len(resp.Result) == 1 { diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go index 82c2f04b..087f41bb 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/v2/project_member/funcs.go @@ -113,8 +113,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }}, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list projectmembers") } if len(resp.Result) == 1 { diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go index 412a2123..7aaf739a 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -110,10 +110,14 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn resp, err := client.GetSMSProvider(ctx, &admin.GetSMSProviderRequest{ Id: d.Id(), }) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get sms provider twilio") + } + set := map[string]interface{}{ sidVar: resp.GetConfig().GetTwilio().GetSid(), senderNumberVar: resp.GetConfig().GetTwilio().GetSenderNumber(), diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index d6f7ed1c..4703950b 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -114,10 +114,14 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } resp, err := client.GetSMTPConfig(ctx, &admin.GetSMTPConfigRequest{}) - if err != nil { + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } + if err != nil { + return diag.Errorf("failed to get smtp config") + } + set := map[string]interface{}{ senderAddressVar: resp.GetSmtpConfig().GetSenderAddress(), senderNameVar: resp.GetSmtpConfig().GetSenderName(), diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/v2/user_grant/funcs.go index 0fbfa3d1..8a5b1c3b 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/v2/user_grant/funcs.go @@ -127,8 +127,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn Queries: queries, }) if err != nil { - d.SetId("") - return nil + return diag.Errorf("failed to list usergrants") } if len(grants.GetResult()) == 1 { From b9826abd0b8ea42c8a2ac97d15c1c9bbae9d3b60 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 8 Dec 2022 16:40:22 +0100 Subject: [PATCH 030/260] docs: generate docs --- docs/resources/default_lockout_policy.md | 2 +- docs/resources/default_login_policy.md | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md index 9b6b3678..cea2f992 100644 --- a/docs/resources/default_lockout_policy.md +++ b/docs/resources/default_lockout_policy.md @@ -22,7 +22,7 @@ resource zitadel_default_lockout_policy lockout_policy { ### Required -- `max_password_attempts` (Number) Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correct or the password is reset. +- `max_password_attempts` (Number) Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correctly or the password is reset. ### Read-Only diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 13635112..3dc1cbf7 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -42,7 +42,6 @@ resource zitadel_default_login_policy login_policy { - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen -- `idps` (Set of String) allowed idps to login or register - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) - `multi_factor_check_lifetime` (String) @@ -53,6 +52,10 @@ resource zitadel_default_login_policy login_policy { - `second_factors` (Set of String) allowed second factors - `user_login` (Boolean) defines if a user is allowed to login with his username and password +### Optional + +- `idps` (Set of String) allowed idps to login or register + ### Read-Only - `id` (String) The ID of this resource. \ No newline at end of file From b75da644848897c413823210eae48fa2d2076006 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 8 Dec 2022 17:18:59 +0100 Subject: [PATCH 031/260] fix: optional attributes --- docs/resources/default_login_policy.md | 4 +- zitadel/v2/default_login_policy/funcs.go | 44 +++++++++++++++------ zitadel/v2/default_login_policy/resource.go | 4 +- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 3dc1cbf7..8675dd32 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -45,16 +45,16 @@ resource zitadel_default_login_policy login_policy { - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) - `multi_factor_check_lifetime` (String) -- `multi_factors` (Set of String) allowed multi factors - `password_check_lifetime` (String) - `passwordless_type` (String) defines if passwordless is allowed for users - `second_factor_check_lifetime` (String) -- `second_factors` (Set of String) allowed second factors - `user_login` (Boolean) defines if a user is allowed to login with his username and password ### Optional - `idps` (Set of String) allowed idps to login or register +- `multi_factors` (Set of String) allowed multi factors +- `second_factors` (Set of String) allowed second factors ### Read-Only diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 01cdc5a4..83431216 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -181,21 +181,41 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn multiFactorCheckLifetimeVar: resp.Policy.GetMultiFactorCheckLifetime().AsDuration().String(), } - secondFactors := &schema.Set{} - for _, factor := range resp.Policy.SecondFactors { - secondFactors.Add(policy.SecondFactorType_name[int32(factor.Number())]) + respSecond, err := client.ListLoginPolicySecondFactors(ctx, &admin.ListLoginPolicySecondFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy secondfactors: %v", err) + } + if len(respSecond.GetResult()) > 0 { + factors := make([]string, 0) + for _, item := range respSecond.GetResult() { + factors = append(factors, item.String()) + } + set[secondFactorsVar] = factors } - set[secondFactorsVar] = secondFactors - multiFactors := &schema.Set{} - for _, factor := range resp.Policy.MultiFactors { - multiFactors.Add(policy.MultiFactorType_name[int32(factor.Number())]) + + respMulti, err := client.ListLoginPolicyMultiFactors(ctx, &admin.ListLoginPolicyMultiFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy multifactors: %v", err) } - set[multiFactorsVar] = multiFactors - idps := &schema.Set{} - for _, idp := range resp.Policy.Idps { - idps.Add(idp.IdpId) + if len(respMulti.GetResult()) > 0 { + factors := make([]string, 0) + for _, item := range respMulti.GetResult() { + factors = append(factors, item.String()) + } + set[multiFactorsVar] = factors + } + + respIDPs, err := client.ListLoginPolicyIDPs(ctx, &admin.ListLoginPolicyIDPsRequest{}) + if err != nil { + return diag.Errorf("failed to get login policy idps: %v", err) + } + if len(respIDPs.GetResult()) > 0 { + idps := make([]string, 0) + for _, idpItem := range respIDPs.GetResult() { + idps = append(idps, idpItem.IdpId) + } + set[idpsVar] = idps } - set[idpsVar] = idps for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 3c913272..d3416f02 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -78,7 +78,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed second factors", }, multiFactorsVar: { @@ -86,7 +86,7 @@ func GetResource() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "allowed multi factors", }, idpsVar: { From 48246b2df7acb53c04a3c5774a56934ce31ee797 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 9 Dec 2022 17:37:13 +0100 Subject: [PATCH 032/260] fix: several additional checks for grpc errors from zitadel --- docs/resources/application_api.md | 12 +---- docs/resources/application_oidc.md | 16 +------ .../provider/resources/application_api.tf | 12 +---- .../provider/resources/application_oidc.tf | 16 +------ examples/provider/resources/human_user.tf | 11 +---- examples/provider/resources/login_policy.tf | 23 +--------- examples/provider/resources/machine_key.tf | 10 +---- examples/provider/resources/project.tf | 10 +---- examples/provider/resources/project_grant.tf | 10 +---- examples/provider/resources/smtp_config.tf | 8 +--- examples/provider/resources/user_grant.tf | 10 +---- go.mod | 22 +++++----- go.sum | 31 +++++++++++++ zitadel/v2/action/funcs.go | 4 ++ .../resource.go | 3 +- zitadel/v2/default_domain_policy/funcs.go | 6 ++- .../v2/default_init_message_text/resource.go | 3 +- zitadel/v2/default_label_policy/funcs.go | 6 ++- zitadel/v2/default_lockout_policy/funcs.go | 6 ++- zitadel/v2/default_login_policy/funcs.go | 44 ++++++++++++++----- .../funcs.go | 6 ++- .../resource.go | 3 +- .../resource.go | 3 +- zitadel/v2/default_privacy_policy/funcs.go | 6 ++- .../resource.go | 3 +- .../resource.go | 3 +- zitadel/v2/domain/funcs.go | 4 ++ .../domain_claimed_message_text/resource.go | 3 +- zitadel/v2/helper/client.go | 17 ++++++- zitadel/v2/init_message_text/resource.go | 3 +- zitadel/v2/login_texts/resource.go | 3 +- zitadel/v2/org/funcs.go | 10 +---- zitadel/v2/org_member/funcs.go | 4 ++ .../password_reset_message_text/resource.go | 3 +- .../resource.go | 3 +- zitadel/v2/project_grant_member/funcs.go | 4 ++ zitadel/v2/project_member/funcs.go | 4 ++ zitadel/v2/trigger_actions/funcs.go | 15 +++---- zitadel/v2/trigger_actions/resource.go | 15 +------ .../v2/verify_email_message_text/resource.go | 3 +- .../v2/verify_phone_message_text/resource.go | 3 +- 41 files changed, 171 insertions(+), 210 deletions(-) diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 54b2df36..d5b423ee 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -12,22 +12,14 @@ Resource representing an API application belonging to a project, with all config ## Example Usage ```terraform -resource zitadel_application_api application_api_full { +resource zitadel_application_api application_api { depends_on = [zitadel_org.org, zitadel_project.project] org_id = zitadel_org.org.id project_id = zitadel_project.project.id - name = "applicationapifull" + name = "applicationapi" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } - -resource zitadel_application_api application_api_min { - depends_on = [zitadel_org.org, zitadel_project.project] - - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - name = "applicationapimin" -} ``` diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index b8a569b1..449fcc08 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -12,13 +12,13 @@ Resource representing an OIDC application belonging to a project, with all confi ## Example Usage ```terraform -resource zitadel_application_oidc application_oidc_full { +resource zitadel_application_oidc application_oidc{ depends_on = [zitadel_org.org, zitadel_project.project] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - name = "applicationoidcfull" + name = "applicationoidc" redirect_uris = ["https://localhost.com"] response_types = ["OIDC_RESPONSE_TYPE_CODE"] grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] @@ -34,18 +34,6 @@ resource zitadel_application_oidc application_oidc_full { id_token_userinfo_assertion = false additional_origins = [] } - -resource zitadel_application_oidc application_oidc_min { - depends_on = [zitadel_org.org, zitadel_project.project] - - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - - name = "applicationoidcmin" - redirect_uris = ["https://localhost.com"] - response_types = ["OIDC_RESPONSE_TYPE_CODE"] - grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] -} ``` diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index 36c5b14f..de9cea54 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -1,16 +1,8 @@ -resource zitadel_application_api application_api_full { +resource zitadel_application_api application_api { depends_on = [zitadel_org.org, zitadel_project.project] org_id = zitadel_org.org.id project_id = zitadel_project.project.id - name = "applicationapifull" + name = "applicationapi" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } - -resource zitadel_application_api application_api_min { - depends_on = [zitadel_org.org, zitadel_project.project] - - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - name = "applicationapimin" -} \ No newline at end of file diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index 7314b792..c972328c 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,10 +1,10 @@ -resource zitadel_application_oidc application_oidc_full { +resource zitadel_application_oidc application_oidc{ depends_on = [zitadel_org.org, zitadel_project.project] project_id = zitadel_project.project.id org_id = zitadel_org.org.id - name = "applicationoidcfull" + name = "applicationoidc" redirect_uris = ["https://localhost.com"] response_types = ["OIDC_RESPONSE_TYPE_CODE"] grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] @@ -20,15 +20,3 @@ resource zitadel_application_oidc application_oidc_full { id_token_userinfo_assertion = false additional_origins = [] } - -resource zitadel_application_oidc application_oidc_min { - depends_on = [zitadel_org.org, zitadel_project.project] - - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - - name = "applicationoidcmin" - redirect_uris = ["https://localhost.com"] - response_types = ["OIDC_RESPONSE_TYPE_CODE"] - grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] -} \ No newline at end of file diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 980c575b..7df5a9ae 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,4 +1,4 @@ -resource zitadel_human_user human_user_full { +resource zitadel_human_user human_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id @@ -15,12 +15,3 @@ resource zitadel_human_user human_user_full { is_email_verified = true initial_password = "Password1!" } - -resource zitadel_human_user human_user_min { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id - user_name = "humanmin@localhost.com" - first_name = "firstname" - last_name = "lastname" -} \ No newline at end of file diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index 252f1f2f..a18054eb 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -1,5 +1,5 @@ resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] + depends_on = [zitadel_org.org, zitadel_org_idp_jwt.jwt_idp, zitadel_org_idp_oidc.oidc_idp] org_id = zitadel_org.org.id user_login = true @@ -17,24 +17,5 @@ resource zitadel_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] + idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] } - -resource zitadel_login_policy login_policy_min { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id - user_login = true - allow_register = true - allow_external_idp = true - force_mfa = false - passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" - hide_password_reset = "false" - password_check_lifetime = "240h0m0s" - external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" - second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = true - default_redirect_uri = "localhost:8080" -} \ No newline at end of file diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 3da3e684..59e1449e 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,4 +1,4 @@ -resource zitadel_machine_key machine_key_full { +resource zitadel_machine_key machine_key { depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id @@ -6,11 +6,3 @@ resource zitadel_machine_key machine_key_full { key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } - -resource zitadel_machine_key machine_key_min { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id - key_type = "KEY_TYPE_JSON" -} \ No newline at end of file diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 160e79cb..42b0b884 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,5 +1,5 @@ -resource zitadel_project project_full { +resource zitadel_project project { depends_on = [zitadel_org.org] name = "projectname" @@ -9,11 +9,3 @@ resource zitadel_project project_full { has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } - -resource zitadel_project project_min { - depends_on = [zitadel_org.org] - - name = "projectname" - org_id = zitadel_org.org.id - private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" -} \ No newline at end of file diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 2ee2a887..e1e7982a 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,4 +1,4 @@ -resource zitadel_project_grant project_grant_full { +resource zitadel_project_grant project_grant { depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] org_id = zitadel_org.org.id @@ -6,11 +6,3 @@ resource zitadel_project_grant project_grant_full { granted_org_id = zitadel_org.grantedorg.id role_keys = [zitadel_project_role.project_role.role_key] } - -resource zitadel_project_grant project_grant_min { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] - - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - granted_org_id = zitadel_org.grantedorg.id -} \ No newline at end of file diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf index 9a37c614..7f81a237 100644 --- a/examples/provider/resources/smtp_config.tf +++ b/examples/provider/resources/smtp_config.tf @@ -1,4 +1,4 @@ -resource zitadel_smtp_config smtp_full { +resource zitadel_smtp_config smtp { sender_address = "address" sender_name = "no-reply" tls = true @@ -6,9 +6,3 @@ resource zitadel_smtp_config smtp_full { user = "user" password = "password" } - -resource zitadel_smtp_config smtp_min { - sender_address = "address" - sender_name = "no-reply" - host = "localhost:25" -} \ No newline at end of file diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 8d2d0a24..4162c7c9 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,4 +1,4 @@ -resource zitadel_user_grant user_grant_full { +resource zitadel_user_grant user_grant { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id @@ -6,11 +6,3 @@ resource zitadel_user_grant user_grant_full { role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id } - -resource zitadel_user_grant user_grant_min { - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] - - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - user_id = zitadel_human_user.granted_human_user.id -} \ No newline at end of file diff --git a/go.mod b/go.mod index 20cb7e87..721ac1f0 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/zitadel/terraform-provider-zitadel go 1.19 require ( - github.com/envoyproxy/protoc-gen-validate v0.6.7 + github.com/envoyproxy/protoc-gen-validate v0.9.0 github.com/gogo/protobuf v1.3.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-framework v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.1 github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 - github.com/zitadel/oidc v1.7.0 - github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 + github.com/zitadel/oidc v1.11.0 + github.com/zitadel/zitadel-go/v2 v2.0.2 google.golang.org/protobuf v1.28.1 ) @@ -50,14 +50,14 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.12.1 // indirect - golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect - golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect - golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect - golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/crypto v0.1.0 // indirect + golang.org/x/net v0.2.0 // indirect + golang.org/x/oauth2 v0.2.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/text v0.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 // indirect - google.golang.org/grpc v1.50.1 // indirect + google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect + google.golang.org/grpc v1.51.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index aec96966..02696a92 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.7 h1:qcZcULcd/abmQg6dwigimCNEyi4gg31M/xaciQlDml8= github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= +github.com/envoyproxy/protoc-gen-validate v0.9.0 h1:wyv+mWIshClA4g6hTlKD9xb6fiNAnDu3+8qYf7KSuSE= +github.com/envoyproxy/protoc-gen-validate v0.9.0/go.mod h1:aUb/JIPT9p8VQ1hMxCrB3/NZSvKoF7fPIE1ULgCIVz0= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= @@ -207,6 +209,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 h1:BqHID5W5qnMkug0Z8UmL8tN0gAy4jQ+B4WFt8cCgluU= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2/go.mod h1:ZbS3MZTZq/apAfAEHGoB5HbsQQstoqP92SjAqtQ9zeg= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= 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-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -314,6 +318,7 @@ github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -323,6 +328,8 @@ 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 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -335,6 +342,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de 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.3.5/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.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= @@ -346,8 +354,12 @@ github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRK github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.7.0 h1:Hy24siGCg2ciQmicF6zkGpCFOQir0zOBK63CZPS3ZKM= github.com/zitadel/oidc v1.7.0/go.mod h1:lbT3Wd/8MujrbLWdVm6Ll6VJjmAUfzW9SscvB4GwLTQ= +github.com/zitadel/oidc v1.11.0 h1:goYglsHfCfWI+ZxqFm2ovU7x0FgM49rAYJSRjNxZ6ys= +github.com/zitadel/oidc v1.11.0/go.mod h1:xgd+BAAz+QIIP8/iRz0pydZOsq8njEeRrcJJ+oP2GoY= github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 h1:EeRJNEAlBeP0nUJ5H2SMfk+wngbowwtSMRub+/7cGxI= github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= +github.com/zitadel/zitadel-go/v2 v2.0.2 h1:mY3MfVeyS0/hI7jez80+rQlVthL4mfOKWSimNoyymKs= +github.com/zitadel/zitadel-go/v2 v2.0.2/go.mod h1:G9Y6rCYGP72J3EoB3AH7lMf5SP9WwGSb5j4RebElLGo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -370,6 +382,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5U golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -406,6 +420,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -453,6 +468,9 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -475,6 +493,8 @@ golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY= golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= +golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -487,6 +507,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/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/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -554,6 +575,9 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.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/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -566,6 +590,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -622,6 +648,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -757,6 +784,8 @@ google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljW google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 h1:sRT5xdTkj1Kbk30qbYC7VyMj73N5pZYsw6v+Nrzdhno= google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= +google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= +google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -791,6 +820,8 @@ google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go index f9496533..ae03f64b 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/v2/action/funcs.go @@ -120,6 +120,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }}, }, }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { return diag.Errorf("failed to list actions") } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource.go b/zitadel/v2/default_domain_claimed_message_text/resource.go index df73eded..a5645fd0 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultDomainClaimedMessageTextResource) Read(ctx context.Context, req zResp, err := client.GetCustomDomainClaimedMessageText(ctx, &admin.GetCustomDomainClaimedMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index c2aa2014..deecd22d 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -34,10 +34,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default domain policy: %v", err) } - d.SetId(resp.GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } return nil } diff --git a/zitadel/v2/default_init_message_text/resource.go b/zitadel/v2/default_init_message_text/resource.go index c78151f0..213ba65b 100644 --- a/zitadel/v2/default_init_message_text/resource.go +++ b/zitadel/v2/default_init_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultInitMessageTextResource) Read(ctx context.Context, req resource. zResp, err := client.GetCustomInitMessageText(ctx, &admin.GetCustomInitMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 4cc5c058..1e0d6ff1 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -53,10 +53,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia FontColorDark: d.Get(fontColorDarkVar).(string), DisableWatermark: d.Get(disableWatermarkVar).(bool), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default label policy: %v", err) } - d.SetId(resp.Details.ResourceOwner) + if resp != nil { + d.SetId(resp.Details.ResourceOwner) + } } if d.HasChange(setActiveVar) { diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index ce18b739..002a3e7f 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -32,10 +32,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default lockout policy: %v", err) } - d.SetId(resp.GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } return nil } diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 83431216..00fd2a4f 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -81,35 +81,51 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update login policy: %v", err) } - d.SetId(resp.GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } } if d.HasChange(secondFactorsVar) { - o, n := d.GetChange(secondFactorsVar) - addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) + o, err := client.ListLoginPolicySecondFactors(ctx, &admin.ListLoginPolicySecondFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get default login policy second factors: %v", err) + } + factors := make([]string, len(o.GetResult())) + for i, factor := range o.GetResult() { + factors[i] = policy.SecondFactorType_name[int32(factor.Number())] + } + addSecondFactor, deleteSecondFactors := helper.GetAddAndDelete(factors, helper.SetToStringSlice(d.Get(secondFactorsVar).(*schema.Set))) for _, factor := range addSecondFactor { if _, err := client.AddSecondFactorToLoginPolicy(ctx, &admin.AddSecondFactorToLoginPolicyRequest{ Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { + }); helper.IgnoreAlreadyExistsError(err) != nil { return diag.FromErr(err) } } for _, factor := range deleteSecondFactors { if _, err := client.RemoveSecondFactorFromLoginPolicy(ctx, &admin.RemoveSecondFactorFromLoginPolicyRequest{ Type: policy.SecondFactorType(policy.SecondFactorType_value[factor]), - }); err != nil { + }); helper.IgnoreAlreadyExistsError(err) != nil { return diag.FromErr(err) } } } if d.HasChange(multiFactorsVar) { - o, n := d.GetChange(multiFactorsVar) - addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) + o, err := client.ListLoginPolicyMultiFactors(ctx, &admin.ListLoginPolicyMultiFactorsRequest{}) + if err != nil { + return diag.Errorf("failed to get default login policy multi factors: %v", err) + } + factors := make([]string, len(o.GetResult())) + for i, factor := range o.GetResult() { + factors[i] = policy.MultiFactorType_name[int32(factor.Number())] + } + addMultiFactor, deleteMultiFactors := helper.GetAddAndDelete(factors, helper.SetToStringSlice(d.Get(multiFactorsVar).(*schema.Set))) for _, factor := range addMultiFactor { if _, err := client.AddMultiFactorToLoginPolicy(ctx, &admin.AddMultiFactorToLoginPolicyRequest{ @@ -128,8 +144,16 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChange(idpsVar) { - o, n := d.GetChange(idpsVar) - addIdps, deleteIdps := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) + o, err := client.ListLoginPolicyIDPs(ctx, &admin.ListLoginPolicyIDPsRequest{}) + if err != nil { + return diag.Errorf("failed to get default login policy idps: %v", err) + } + + idps := make([]string, len(o.GetResult())) + for i, idp := range o.GetResult() { + idps[i] = idp.IdpId + } + addIdps, deleteIdps := helper.GetAddAndDelete(idps, helper.SetToStringSlice(d.Get(idpsVar).(*schema.Set))) for _, addIdp := range addIdps { if _, err := client.AddIDPToLoginPolicy(ctx, &admin.AddIDPToLoginPolicyRequest{IdpId: addIdp}); err != nil { diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go index d6cd96f1..cb64ced5 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -36,10 +36,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia HasNumber: d.Get(hasNumberVar).(bool), HasSymbol: d.Get(hasSymbolVar).(bool), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default password complexity policy: %v", err) } - d.SetId(resp.GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } return nil } diff --git a/zitadel/v2/default_password_reset_message_text/resource.go b/zitadel/v2/default_password_reset_message_text/resource.go index dbcd4d5f..56c6646a 100644 --- a/zitadel/v2/default_password_reset_message_text/resource.go +++ b/zitadel/v2/default_password_reset_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultPasswordResetMessageTextResource) Read(ctx context.Context, req zResp, err := client.GetCustomPasswordResetMessageText(ctx, &admin.GetCustomPasswordResetMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource.go b/zitadel/v2/default_passwordless_registration_message_text/resource.go index 7647ee4b..3e18738d 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultPasswordlessRegistrationMessageTextResource) Read(ctx context.Co zResp, err := client.GetCustomPasswordlessRegistrationMessageText(ctx, &admin.GetCustomPasswordlessRegistrationMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index f3b1291d..31262a1c 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -34,10 +34,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia PrivacyLink: d.Get(privacyLinkVar).(string), HelpLink: d.Get(helpLinkVar).(string), }) - if err != nil { + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default privacy policy: %v", err) } - d.SetId(resp.GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } return nil } diff --git a/zitadel/v2/default_verify_email_message_text/resource.go b/zitadel/v2/default_verify_email_message_text/resource.go index 724f00a2..71986450 100644 --- a/zitadel/v2/default_verify_email_message_text/resource.go +++ b/zitadel/v2/default_verify_email_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultVerifyEmailMessageTextResource) Read(ctx context.Context, req re zResp, err := client.GetCustomVerifyEmailMessageText(ctx, &admin.GetCustomVerifyEmailMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/default_verify_phone_message_text/resource.go b/zitadel/v2/default_verify_phone_message_text/resource.go index b85802de..7b99702b 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource.go +++ b/zitadel/v2/default_verify_phone_message_text/resource.go @@ -121,11 +121,10 @@ func (r *defaultVerifyPhoneMessageTextResource) Read(ctx context.Context, req re zResp, err := client.GetCustomVerifyPhoneMessageText(ctx, &admin.GetCustomVerifyPhoneMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index 42d73489..f0e45c0d 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -83,6 +83,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }, }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { return diag.Errorf("failed to list domains") } diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index 687db48d..48fc8c6e 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -121,11 +121,10 @@ func (r *domainClaimedMessageTextResource) Read(ctx context.Context, req resourc zResp, err := client.GetCustomDomainClaimedMessageText(ctx, &management.GetCustomDomainClaimedMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 2bc43030..98054e59 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -86,7 +86,22 @@ func GetManagementClient(info *ClientInfo, orgID string) (*management.Client, er } func IgnoreIfNotFoundError(err error) error { - if code := status.Code(err); code == codes.NotFound { + //permission denied included as nothing can be found then as well + if code := status.Code(err); code == codes.NotFound || code == codes.PermissionDenied { + return nil + } + return err +} + +func IgnorePreconditionError(err error) error { + if code := status.Code(err); code == codes.FailedPrecondition { + return nil + } + return err +} + +func IgnoreAlreadyExistsError(err error) error { + if code := status.Code(err); code == codes.AlreadyExists { return nil } return err diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go index 57b2f3c6..487b71a3 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/v2/init_message_text/resource.go @@ -121,11 +121,10 @@ func (r *initMessageTextResource) Read(ctx context.Context, req resource.ReadReq zResp, err := client.GetCustomInitMessageText(ctx, &management.GetCustomInitMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index 19f74b1c..66c405c7 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -121,11 +121,10 @@ func (r *loginTextsResource) Read(ctx context.Context, req resource.ReadRequest, zResp, err := client.GetCustomLoginTexts(ctx, &management.GetCustomLoginTextsRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading login texts", "No custom login texts existing") + return } resp.Diagnostics.Append(text.CopyLoginCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/org/funcs.go b/zitadel/v2/org/funcs.go index 859ce979..63dce0bb 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/v2/org/funcs.go @@ -14,15 +14,7 @@ import ( ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - /*client, ok := m.(*management.Client) - if !ok { - return diag.Errorf("failed to get client") - } - - _, err := client.DeactivateOrg(ctx, &management.DeactivateOrgRequest{}) - if err != nil { - return diag.FromErr(err) - }*/ + tflog.Info(ctx, "org delete not yet implemented") return nil } diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index 53d4bed9..c3c0c8de 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -107,6 +107,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }}, }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { return diag.Errorf("failed to list org members") } diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index 7a254618..39504b22 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -121,11 +121,10 @@ func (r *passwordResetMessageTextResource) Read(ctx context.Context, req resourc zResp, err := client.GetCustomPasswordResetMessageText(ctx, &management.GetCustomPasswordResetMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go index 8f6e8226..869cb18e 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -121,11 +121,10 @@ func (r *passwordlessRegistrationMessageTextResource) Read(ctx context.Context, zResp, err := client.GetCustomPasswordlessRegistrationMessageText(ctx, &management.GetCustomPasswordlessRegistrationMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index a990ea83..94589882 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -118,6 +118,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }}, }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { return diag.Errorf("failed to list projectgrantmembers") } diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go index 087f41bb..5fa2308e 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/v2/project_member/funcs.go @@ -112,6 +112,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn }, }}, }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { return diag.Errorf("failed to list projectmembers") } diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index 92a97f8b..89594940 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -26,11 +25,11 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[d.Get(flowTypeVar).(string)]), - TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerTypeVar).(string)]), + FlowType: d.Get(flowTypeVar).(string), + TriggerType: d.Get(triggerTypeVar).(string), ActionIds: []string{}, }) - if err != nil { + if helper.IgnoreIfNotFoundError(err) != nil { return diag.Errorf("failed to delete trigger actions: %v", err) } return nil @@ -50,8 +49,8 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[d.Get(flowTypeVar).(string)]), - TriggerType: action.TriggerType(action.TriggerType_value[d.Get(triggerTypeVar).(string)]), + FlowType: d.Get(flowTypeVar).(string), + TriggerType: d.Get(triggerTypeVar).(string), ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) if err != nil { @@ -78,8 +77,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia flowType := d.Get(flowTypeVar).(string) triggerType := d.Get(triggerTypeVar).(string) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: action.FlowType(action.FlowType_value[flowType]), - TriggerType: action.TriggerType(action.TriggerType_value[triggerType]), + FlowType: flowType, + TriggerType: triggerType, ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 84838b72..0ab0a8dc 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -1,12 +1,7 @@ package trigger_actions import ( - "github.com/hashicorp/go-cty/cty" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/action" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -22,20 +17,14 @@ func GetResource() *schema.Resource { flowTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(action.FlowType_name), + Description: "Type of the flow to which the action triggers belong", ForceNew: true, - ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(flowTypeVar, value, action.FlowType_value) - }, }, triggerTypeVar: { Type: schema.TypeString, Required: true, - Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(action.TriggerType_name), + Description: "Trigger type on when the actions get triggered", ForceNew: true, - ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(triggerTypeVar, value, action.TriggerType_value) - }, }, actionsVar: { Type: schema.TypeSet, diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index 2c2f0e07..657c2de8 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -121,11 +121,10 @@ func (r *verifyEmailMessageTextResource) Read(ctx context.Context, req resource. zResp, err := client.GetCustomVerifyEmailMessageText(ctx, &management.GetCustomVerifyEmailMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index 8802fb91..1f9f5dd3 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -121,11 +121,10 @@ func (r *verifyPhoneMessageTextResource) Read(ctx context.Context, req resource. zResp, err := client.GetCustomVerifyPhoneMessageText(ctx, &management.GetCustomVerifyPhoneMessageTextRequest{Language: language}) if err != nil { - resp.Diagnostics.AddError("failed to get client", err.Error()) return } if zResp.CustomText.IsDefault { - resp.Diagnostics.AddError("Error while reading", "No custom texts existing") + return } resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) From 62ba57b2e3600a89d3164302b87b3a962f591dcb Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 9 Dec 2022 17:37:48 +0100 Subject: [PATCH 033/260] docs: generate doc changes --- docs/resources/human_user.md | 11 +---------- docs/resources/login_policy.md | 23 ++--------------------- docs/resources/machine_key.md | 10 +--------- docs/resources/project.md | 10 +--------- docs/resources/project_grant.md | 10 +--------- docs/resources/smtp_config.md | 8 +------- docs/resources/trigger_actions.md | 4 ++-- docs/resources/user_grant.md | 10 +--------- 8 files changed, 10 insertions(+), 76 deletions(-) diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 65ef9d7c..cad1faec 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -14,7 +14,7 @@ Resource representing a human user situated under an organization, which then ca ## Example Usage ```terraform -resource zitadel_human_user human_user_full { +resource zitadel_human_user human_user { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id @@ -31,15 +31,6 @@ resource zitadel_human_user human_user_full { is_email_verified = true initial_password = "Password1!" } - -resource zitadel_human_user human_user_min { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id - user_name = "humanmin@localhost.com" - first_name = "firstname" - last_name = "lastname" -} ``` diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 518073ec..f9c10606 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -13,7 +13,7 @@ Resource representing the custom login policy of an organization. ```terraform resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org, zitadel_org_jwt_idp.jwt_idp, zitadel_org_oidc_idp.oidc_idp] + depends_on = [zitadel_org.org, zitadel_org_idp_jwt.jwt_idp, zitadel_org_idp_oidc.oidc_idp] org_id = zitadel_org.org.id user_login = true @@ -31,26 +31,7 @@ resource zitadel_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_oidc_idp.oidc_idp.id, zitadel_org_jwt_idp.jwt_idp.id] -} - -resource zitadel_login_policy login_policy_min { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id - user_login = true - allow_register = true - allow_external_idp = true - force_mfa = false - passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" - hide_password_reset = "false" - password_check_lifetime = "240h0m0s" - external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" - second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = true - default_redirect_uri = "localhost:8080" + idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] } ``` diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index 46cfd230..c356389b 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -12,7 +12,7 @@ Resource representing a machine key ## Example Usage ```terraform -resource zitadel_machine_key machine_key_full { +resource zitadel_machine_key machine_key { depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] org_id = zitadel_org.org.id @@ -20,14 +20,6 @@ resource zitadel_machine_key machine_key_full { key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } - -resource zitadel_machine_key machine_key_min { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id - key_type = "KEY_TYPE_JSON" -} ``` diff --git a/docs/resources/project.md b/docs/resources/project.md index 773c7ac8..f983bf58 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -12,7 +12,7 @@ Resource representing the project, which can then be granted to different organi ## Example Usage ```terraform -resource zitadel_project project_full { +resource zitadel_project project { depends_on = [zitadel_org.org] name = "projectname" @@ -22,14 +22,6 @@ resource zitadel_project project_full { has_project_check = true private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" } - -resource zitadel_project project_min { - depends_on = [zitadel_org.org] - - name = "projectname" - org_id = zitadel_org.org.id - private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" -} ``` diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 85b7d471..6a75e763 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -12,7 +12,7 @@ Resource representing the grant of a project to a different organization, also c ## Example Usage ```terraform -resource zitadel_project_grant project_grant_full { +resource zitadel_project_grant project_grant { depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] org_id = zitadel_org.org.id @@ -20,14 +20,6 @@ resource zitadel_project_grant project_grant_full { granted_org_id = zitadel_org.grantedorg.id role_keys = [zitadel_project_role.project_role.role_key] } - -resource zitadel_project_grant project_grant_min { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg] - - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - granted_org_id = zitadel_org.grantedorg.id -} ``` diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index e10f45be..30d8df99 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -12,7 +12,7 @@ Resource representing the SMTP configuration of an instance. ## Example Usage ```terraform -resource zitadel_smtp_config smtp_full { +resource zitadel_smtp_config smtp { sender_address = "address" sender_name = "no-reply" tls = true @@ -20,12 +20,6 @@ resource zitadel_smtp_config smtp_full { user = "user" password = "password" } - -resource zitadel_smtp_config smtp_min { - sender_address = "address" - sender_name = "no-reply" - host = "localhost:25" -} ``` diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index c58ed7fa..ffed563f 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -28,9 +28,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_UNSPECIFIED, FLOW_TYPE_EXTERNAL_AUTHENTICATION +- `flow_type` (String) Type of the flow to which the action triggers belong - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered ### Read-Only diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 9b63514a..92a603da 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -12,7 +12,7 @@ Resource representing the authorization given to a user directly, including the ## Example Usage ```terraform -resource zitadel_user_grant user_grant_full { +resource zitadel_user_grant user_grant { depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] project_id = zitadel_project.project.id @@ -20,14 +20,6 @@ resource zitadel_user_grant user_grant_full { role_keys = ["key"] user_id = zitadel_human_user.granted_human_user.id } - -resource zitadel_user_grant user_grant_min { - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] - - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id - user_id = zitadel_human_user.granted_human_user.id -} ``` From e2eb76cd3313e60722e4cdfa64b5b279c7da99d6 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 19 Dec 2022 17:03:26 +0100 Subject: [PATCH 034/260] fix: get ids for unchanged default policies and correct set attributes by import --- docs/resources/default_login_policy.md | 4 ++-- docs/resources/login_policy.md | 4 ++-- examples/provider/resources/default_login_policy.tf | 4 ++-- examples/provider/resources/login_policy.tf | 4 ++-- zitadel/v2/default_domain_policy/funcs.go | 6 ++++++ zitadel/v2/default_label_policy/funcs.go | 6 ++++++ zitadel/v2/default_lockout_policy/funcs.go | 6 ++++++ zitadel/v2/default_login_policy/funcs.go | 8 ++++++++ zitadel/v2/default_password_complexity_policy/funcs.go | 6 ++++++ zitadel/v2/default_privacy_policy/funcs.go | 6 ++++++ zitadel/v2/login_policy/funcs.go | 2 ++ 11 files changed, 48 insertions(+), 8 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 8675dd32..d50cbcb2 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -21,8 +21,8 @@ resource zitadel_default_login_policy login_policy { hide_password_reset = "false" password_check_lifetime = "240h0m0s" external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" + multi_factor_check_lifetime = "24h0m0s" + mfa_init_skip_lifetime = "720h0m0s" second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index f9c10606..91d6be0d 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -24,8 +24,8 @@ resource zitadel_login_policy login_policy { hide_password_reset = "false" password_check_lifetime = "240h0m0s" external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" + multi_factor_check_lifetime = "24h0m0s" + mfa_init_skip_lifetime = "720h0m0s" second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index b3963547..32f5da3f 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -7,8 +7,8 @@ resource zitadel_default_login_policy login_policy { hide_password_reset = "false" password_check_lifetime = "240h0m0s" external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" + multi_factor_check_lifetime = "24h0m0s" + mfa_init_skip_lifetime = "720h0m0s" second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index a18054eb..1239a26f 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -10,8 +10,8 @@ resource zitadel_login_policy login_policy { hide_password_reset = "false" password_check_lifetime = "240h0m0s" external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "720h0m0s" - mfa_init_skip_lifetime = "24h0m0s" + multi_factor_check_lifetime = "24h0m0s" + mfa_init_skip_lifetime = "720h0m0s" second_factor_check_lifetime = "24h0m0s" ignore_unknown_usernames = true default_redirect_uri = "localhost:8080" diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index deecd22d..510e3264 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -39,6 +39,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetDomainPolicy(ctx, &admin.GetDomainPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default domain policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } return nil } diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 1e0d6ff1..9f4f6576 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -58,6 +58,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.Details.ResourceOwner) + } else { + resp, err := client.GetLabelPolicy(ctx, &admin.GetLabelPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default label policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } } diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index 002a3e7f..b0fb425f 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -37,6 +37,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetLockoutPolicy(ctx, &admin.GetLockoutPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default lockout policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } return nil } diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 00fd2a4f..f081a9ba 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -86,6 +86,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default login policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } } @@ -198,6 +204,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn forceMFAVar: resp.Policy.GetForceMfa(), passwordlessTypeVar: resp.Policy.GetPasswordlessType().String(), hidePasswordResetVar: resp.Policy.GetHidePasswordReset(), + ignoreUnknownUsernamesVar: resp.Policy.GetIgnoreUnknownUsernames(), + defaultRedirectURIVar: resp.Policy.GetDefaultRedirectUri(), passwordCheckLifetimeVar: resp.Policy.GetPasswordCheckLifetime().AsDuration().String(), externalLoginCheckLifetimeVar: resp.Policy.GetExternalLoginCheckLifetime().AsDuration().String(), mfaInitSkipLifetimeVar: resp.Policy.GetMfaInitSkipLifetime().AsDuration().String(), diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go index cb64ced5..93645c0d 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -41,6 +41,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetPasswordComplexityPolicy(ctx, &admin.GetPasswordComplexityPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to get default password complexity policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } return nil } diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index 31262a1c..b16b3748 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -39,6 +39,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if resp != nil { d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetPrivacyPolicy(ctx, &admin.GetPrivacyPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default privacy policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) } return nil } diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index c76b8c73..baacfe0c 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -292,6 +292,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn forceMFAVar: policy.GetForceMfa(), passwordlessTypeVar: policy.GetPasswordlessType().String(), hidePasswordResetVar: policy.GetHidePasswordReset(), + ignoreUnknownUsernamesVar: policy.GetIgnoreUnknownUsernames(), + defaultRedirectURIVar: policy.GetDefaultRedirectUri(), passwordCheckLifetimeVar: policy.GetPasswordCheckLifetime().AsDuration().String(), externalLoginCheckLifetimeVar: policy.GetExternalLoginCheckLifetime().AsDuration().String(), mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), From fc5cdbf712033a07ee1d77f901013b69465d473d Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 20 Dec 2022 18:19:04 +0100 Subject: [PATCH 035/260] fix: add icon, logo and font uploads to default labels policy --- docs/resources/default_label_policy.md | 20 ++ .../resources/default_label_policy.tf | 10 + go.mod | 5 +- go.sum | 316 +----------------- zitadel/v2/default_label_policy/const.go | 20 ++ zitadel/v2/default_label_policy/funcs.go | 26 ++ zitadel/v2/default_label_policy/resource.go | 50 +++ zitadel/v2/helper/client.go | 2 + zitadel/v2/helper/form.go | 107 ++++++ 9 files changed, 241 insertions(+), 315 deletions(-) create mode 100644 zitadel/v2/helper/form.go diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index a0db9aba..d5cb6745 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -24,6 +24,16 @@ resource zitadel_default_label_policy label_policy { font_color_dark = "#ffffff" disable_watermark = false set_active = true + logo_hash = filemd5("/path/to/logo.jpg") + logo_path = "/path/to/logo.jpg" + logo_dark_hash = filemd5("/path/to/logo_dark.jpg") + logo_dark_path = "/path/to/logo_dark.jpg" + icon_hash = filemd5("/path/to/icon.jpg") + icon_path = "/path/to/icon.jpg" + icon_dark_hash = filemd5("/path/to/icon_dark.jpg") + icon_dark_path = "/path/to/icon_dark.jpg" + font_hash = filemd5("/path/to/font.jpg") + font_path = "/path/to/font.jpg" } ``` @@ -45,6 +55,16 @@ resource zitadel_default_label_policy label_policy { ### Optional +- `font_hash` (String) +- `font_path` (String) +- `icon_dark_hash` (String) +- `icon_dark_path` (String) +- `icon_hash` (String) +- `icon_path` (String) +- `logo_dark_hash` (String) +- `logo_dark_path` (String) +- `logo_hash` (String) +- `logo_path` (String) - `set_active` (Boolean) set the label policy active after creating/updating ### Read-Only diff --git a/examples/provider/resources/default_label_policy.tf b/examples/provider/resources/default_label_policy.tf index 241fff35..104964fd 100644 --- a/examples/provider/resources/default_label_policy.tf +++ b/examples/provider/resources/default_label_policy.tf @@ -10,4 +10,14 @@ resource zitadel_default_label_policy label_policy { font_color_dark = "#ffffff" disable_watermark = false set_active = true + logo_hash = filemd5("/path/to/logo.jpg") + logo_path = "/path/to/logo.jpg" + logo_dark_hash = filemd5("/path/to/logo_dark.jpg") + logo_dark_path = "/path/to/logo_dark.jpg" + icon_hash = filemd5("/path/to/icon.jpg") + icon_path = "/path/to/icon.jpg" + icon_dark_hash = filemd5("/path/to/icon_dark.jpg") + icon_dark_path = "/path/to/icon_dark.jpg" + font_hash = filemd5("/path/to/font.jpg") + font_path = "/path/to/font.jpg" } \ No newline at end of file diff --git a/go.mod b/go.mod index 721ac1f0..b4bfb505 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/envoyproxy/protoc-gen-validate v0.9.0 + github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 @@ -14,6 +15,8 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/zitadel/oidc v1.11.0 github.com/zitadel/zitadel-go/v2 v2.0.2 + golang.org/x/oauth2 v0.2.0 + google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.1 ) @@ -52,12 +55,10 @@ require ( github.com/zclconf/go-cty v1.12.1 // indirect golang.org/x/crypto v0.1.0 // indirect golang.org/x/net v0.2.0 // indirect - golang.org/x/oauth2 v0.2.0 // indirect golang.org/x/sys v0.2.0 // indirect golang.org/x/text v0.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect - google.golang.org/grpc v1.51.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index 02696a92..b6c49750 100644 --- a/go.sum +++ b/go.sum @@ -13,36 +13,14 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -52,37 +30,22 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 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/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 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= @@ -90,33 +53,22 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.7 h1:qcZcULcd/abmQg6dwigimCNEyi4gg31M/xaciQlDml8= -github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/envoyproxy/protoc-gen-validate v0.9.0 h1:wyv+mWIshClA4g6hTlKD9xb6fiNAnDu3+8qYf7KSuSE= github.com/envoyproxy/protoc-gen-validate v0.9.0/go.mod h1:aUb/JIPT9p8VQ1hMxCrB3/NZSvKoF7fPIE1ULgCIVz0= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= +github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -127,7 +79,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -143,12 +94,9 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -159,11 +107,7 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -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.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= 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= @@ -171,8 +115,6 @@ github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gA github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -180,35 +122,16 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 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/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 h1:BqHID5W5qnMkug0Z8UmL8tN0gAy4jQ+B4WFt8cCgluU= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2/go.mod h1:ZbS3MZTZq/apAfAEHGoB5HbsQQstoqP92SjAqtQ9zeg= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= @@ -225,30 +148,22 @@ github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHG 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.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= -github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 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/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl/v2 v2.12.0 h1:PsYxySWpMD4KPaoJLnsHwtK5Qptvj/4Q6s0t4sUxZf4= -github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= 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-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q= github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= -github.com/hashicorp/terraform-plugin-framework v0.16.0 h1:kEHh0d6dp5Ig/ey6PYXkWDZPMLIW8Me41T/Oa7bpO4s= -github.com/hashicorp/terraform-plugin-framework v0.16.0/go.mod h1:Vk5MuIJoE1qksHZawAZr6psx6YXsQBFIKDrWbROrwus= github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek= github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ= github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= github.com/hashicorp/terraform-plugin-mux v0.7.0 h1:wRbSYzg+v2sn5Mdee0UKm4YTt4wJG0LfSwtgNuBkglY= github.com/hashicorp/terraform-plugin-mux v0.7.0/go.mod h1:Ae30Mc5lz4d1awtiCbHP0YyvgBeiQ00Q1nAq0U3lb+I= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 h1:9fjPgCenJqnbjo95SDcbJ+YdLyEC1N35cwKWcRWhJTQ= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0/go.mod h1:hLa0sTiySU/AWEgV2GxJh0/pQIqcCmm30IPja9N9lTg= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= @@ -257,17 +172,12 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKL github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 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/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -277,7 +187,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= 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= @@ -288,7 +197,6 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -299,34 +207,20 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -344,20 +238,11 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/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.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.7.0 h1:Hy24siGCg2ciQmicF6zkGpCFOQir0zOBK63CZPS3ZKM= -github.com/zitadel/oidc v1.7.0/go.mod h1:lbT3Wd/8MujrbLWdVm6Ll6VJjmAUfzW9SscvB4GwLTQ= github.com/zitadel/oidc v1.11.0 h1:goYglsHfCfWI+ZxqFm2ovU7x0FgM49rAYJSRjNxZ6ys= github.com/zitadel/oidc v1.11.0/go.mod h1:xgd+BAAz+QIIP8/iRz0pydZOsq8njEeRrcJJ+oP2GoY= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5 h1:EeRJNEAlBeP0nUJ5H2SMfk+wngbowwtSMRub+/7cGxI= -github.com/zitadel/zitadel-go/v2 v2.0.0-v2-alpha.5/go.mod h1:PNlFaUYdbp8vBC6JWI0NoOISoqX7Qmsb2paAf6QNIOc= github.com/zitadel/zitadel-go/v2 v2.0.2 h1:mY3MfVeyS0/hI7jez80+rQlVthL4mfOKWSimNoyymKs= github.com/zitadel/zitadel-go/v2 v2.0.2/go.mod h1:G9Y6rCYGP72J3EoB3AH7lMf5SP9WwGSb5j4RebElLGo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -365,23 +250,12 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= -golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -406,8 +280,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -416,10 +288,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -450,23 +319,9 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= @@ -477,22 +332,6 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY= -golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -504,17 +343,13 @@ 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-20201207232520-09787c993a3a/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/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -537,43 +372,16 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/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-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/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-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= @@ -585,10 +393,6 @@ 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= @@ -636,26 +440,13 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/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.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -672,29 +463,6 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -724,66 +492,14 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 h1:sRT5xdTkj1Kbk30qbYC7VyMj73N5pZYsw6v+Nrzdhno= -google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -798,31 +514,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -835,8 +528,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -848,7 +539,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/zitadel/v2/default_label_policy/const.go b/zitadel/v2/default_label_policy/const.go index 15144cfb..6dc1f9d1 100644 --- a/zitadel/v2/default_label_policy/const.go +++ b/zitadel/v2/default_label_policy/const.go @@ -11,10 +11,30 @@ const ( warnColorDarkVar = "warn_color_dark" fontColorDarkVar = "font_color_dark" disableWatermarkVar = "disable_watermark" + logoPathVar = "logo_path" + logoHashVar = "logo_hash" logoURLVar = "logo_url" + iconPathVar = "icon_path" + iconHashVar = "icon_hash" iconURLVar = "icon_url" + logoDarkPathVar = "logo_dark_path" + logoDarkHashVar = "logo_dark_hash" logoURLDarkVar = "logo_url_dark" + iconDarkPathVar = "icon_dark_path" + iconDarkHashVar = "icon_dark_hash" iconURLDarkVar = "icon_url_dark" + fontPathVar = "font_path" + fontHashVar = "font_hash" fontURLVar = "font_url" setActiveVar = "set_active" ) + +const ( + assetAPI = "/assets/v1" + labelPolicyURL = "/instance/policy/label" + logoURL = assetAPI + labelPolicyURL + "/logo" + logoDarkURL = logoURL + "/dark" + iconURL = assetAPI + labelPolicyURL + "/icon" + iconDarkURL = iconURL + "/dark" + fontURL = assetAPI + labelPolicyURL + "/font" +) diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 1e0d6ff1..91d9a4da 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -61,6 +61,32 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } + if d.HasChanges(logoHashVar, logoPathVar) { + if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo: %v", err) + } + } + if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { + if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo dark: %v", err) + } + } + if d.HasChanges(iconHashVar, iconPathVar) { + if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon: %v", err) + } + } + if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { + if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon dark: %v", err) + } + } + if d.HasChanges(fontHashVar, fontPathVar) { + if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + return diag.Errorf("failed to upload font: %v", err) + } + } + if d.HasChange(setActiveVar) { if d.Get(setActiveVar).(bool) { if _, err := client.ActivateLabelPolicy(ctx, &admin.ActivateLabelPolicyRequest{}); err != nil { diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/v2/default_label_policy/resource.go index 78b07506..716458da 100644 --- a/zitadel/v2/default_label_policy/resource.go +++ b/zitadel/v2/default_label_policy/resource.go @@ -58,26 +58,76 @@ func GetResource() *schema.Resource { Required: true, Description: "disable watermark", }, + logoPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + logoHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, logoURLVar: { Type: schema.TypeString, Computed: true, Description: "", }, + iconPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + iconHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, iconURLVar: { Type: schema.TypeString, Computed: true, Description: "", }, + logoDarkPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + logoDarkHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, logoURLDarkVar: { Type: schema.TypeString, Computed: true, Description: "", }, + iconDarkPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + iconDarkHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, iconURLDarkVar: { Type: schema.TypeString, Computed: true, Description: "", }, + fontPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + fontHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, fontURLVar: { Type: schema.TypeString, Computed: true, diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 98054e59..8f549cff 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -22,6 +22,7 @@ const ( type ClientInfo struct { Domain string Issuer string + KeyPath string Options []zitadel.Option } @@ -51,6 +52,7 @@ func GetClientInfo(insecure bool, domain string, token string, port string) (*Cl return &ClientInfo{ domain, issuer, + token, options, }, nil } diff --git a/zitadel/v2/helper/form.go b/zitadel/v2/helper/form.go new file mode 100644 index 00000000..dc886881 --- /dev/null +++ b/zitadel/v2/helper/form.go @@ -0,0 +1,107 @@ +package helper + +import ( + "bytes" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/textproto" + "os" + "path/filepath" + "strings" + + "github.com/gabriel-vasile/mimetype" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/zitadel/oidc/pkg/client/profile" + "github.com/zitadel/oidc/pkg/oidc" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel" + "golang.org/x/oauth2" +) + +var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") + +func escapeQuotes(s string) string { + return quoteEscaper.Replace(s) +} + +func FormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostics { + file, err := os.Open(path) + if err != nil { + return diag.Errorf("failed to read file: %v", err) + } + info, err := file.Stat() + if err != nil { + return diag.Errorf("failed to read file info: %v", err) + } + if info.Size() > (1 << 19) { + return diag.Errorf("file to large") + } + + body := &bytes.Buffer{} + writer := multipart.NewWriter(body) + data, err := io.ReadAll(file) + if err != nil { + return diag.Errorf("failed to read asset: %v", err) + } + + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", + fmt.Sprintf(`form-data; name="%s"; filename="%s"`, + escapeQuotes("file"), escapeQuotes(filepath.Base(file.Name())))) + h.Set("Content-Type", mimetype.Detect(data).String()) + part, err := writer.CreatePart(h) + if err != nil { + return diag.Errorf("failed to create asset part: %v", err) + } + io.Copy(part, bytes.NewBuffer(data)) + writer.Close() + + r, err := http.NewRequest(http.MethodPost, clientInfo.Issuer+endpoint, body) + if err != nil { + return diag.Errorf("failed to create asset request: %v", err) + } + + r.Header.Add("Content-Type", writer.FormDataContentType()) + client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) + if err != nil { + return diag.Errorf("failed to create client: %v", err) + } + + resp, err := client.Do(r) + if err != nil || resp.StatusCode != http.StatusOK { + return diag.Errorf("failed to do asset request: %v", err) + } + return nil +} + +type Interceptor struct { + tokenSource oauth2.TokenSource + core http.RoundTripper +} + +func NewClientWithInterceptor(issuer, keyPath string, scopes []string) (*http.Client, error) { + ts, err := profile.NewJWTProfileTokenSourceFromKeyFile(issuer, keyPath, scopes) + if err != nil { + return nil, err + } + + return &http.Client{ + Transport: Interceptor{core: http.DefaultTransport, tokenSource: ts}, + }, nil +} + +func (i Interceptor) RoundTrip(r *http.Request) (*http.Response, error) { + defer func() { + _ = r.Body.Close() + }() + + ts := oauth2.ReuseTokenSource(nil, i.tokenSource) + + token, err := ts.Token() + if err != nil { + return nil, err + } + r.Header.Set("authorization", token.TokenType+" "+token.AccessToken) + return i.core.RoundTrip(r) +} From af0e870db33c8493e5850ace5ada9adfbefe0629 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 21 Dec 2022 11:19:12 +0100 Subject: [PATCH 036/260] fix: add icon, logo and font uploads to label policy --- docs/resources/default_label_policy.md | 4 +- docs/resources/label_policy.md | 20 ++++++ .../resources/default_label_policy.tf | 4 +- examples/provider/resources/label_policy.tf | 10 +++ zitadel/v2/default_label_policy/funcs.go | 18 ++++- zitadel/v2/label_policy/const.go | 20 ++++++ zitadel/v2/label_policy/funcs.go | 70 ++++++++++++++++++- zitadel/v2/label_policy/resource.go | 50 +++++++++++++ 8 files changed, 190 insertions(+), 6 deletions(-) diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index d5cb6745..b4d737b4 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -32,8 +32,8 @@ resource zitadel_default_label_policy label_policy { icon_path = "/path/to/icon.jpg" icon_dark_hash = filemd5("/path/to/icon_dark.jpg") icon_dark_path = "/path/to/icon_dark.jpg" - font_hash = filemd5("/path/to/font.jpg") - font_path = "/path/to/font.jpg" + font_hash = filemd5("/path/to/font.tff") + font_path = "/path/to/font.tff" } ``` diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index 5c9368ff..d64af7ac 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -27,6 +27,16 @@ resource zitadel_label_policy label_policy { font_color_dark = "#ffffff" disable_watermark = false set_active = true + logo_hash = filemd5("/path/to/logo.jpg") + logo_path = "/path/to/logo.jpg" + logo_dark_hash = filemd5("/path/to/logo_dark.jpg") + logo_dark_path = "/path/to/logo_dark.jpg" + icon_hash = filemd5("/path/to/icon.jpg") + icon_path = "/path/to/icon.jpg" + icon_dark_hash = filemd5("/path/to/icon_dark.jpg") + icon_dark_path = "/path/to/icon_dark.jpg" + font_hash = filemd5("/path/to/font.tff") + font_path = "/path/to/font.tff" } ``` @@ -49,6 +59,16 @@ resource zitadel_label_policy label_policy { ### Optional +- `font_hash` (String) +- `font_path` (String) +- `icon_dark_hash` (String) +- `icon_dark_path` (String) +- `icon_hash` (String) +- `icon_path` (String) +- `logo_dark_hash` (String) +- `logo_dark_path` (String) +- `logo_hash` (String) +- `logo_path` (String) - `set_active` (Boolean) set the label policy active after creating/updating ### Read-Only diff --git a/examples/provider/resources/default_label_policy.tf b/examples/provider/resources/default_label_policy.tf index 104964fd..082a48e8 100644 --- a/examples/provider/resources/default_label_policy.tf +++ b/examples/provider/resources/default_label_policy.tf @@ -18,6 +18,6 @@ resource zitadel_default_label_policy label_policy { icon_path = "/path/to/icon.jpg" icon_dark_hash = filemd5("/path/to/icon_dark.jpg") icon_dark_path = "/path/to/icon_dark.jpg" - font_hash = filemd5("/path/to/font.jpg") - font_path = "/path/to/font.jpg" + font_hash = filemd5("/path/to/font.tff") + font_path = "/path/to/font.tff" } \ No newline at end of file diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index a14facc3..428e2ea2 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -13,4 +13,14 @@ resource zitadel_label_policy label_policy { font_color_dark = "#ffffff" disable_watermark = false set_active = true + logo_hash = filemd5("/path/to/logo.jpg") + logo_path = "/path/to/logo.jpg" + logo_dark_hash = filemd5("/path/to/logo_dark.jpg") + logo_dark_path = "/path/to/logo_dark.jpg" + icon_hash = filemd5("/path/to/icon.jpg") + icon_path = "/path/to/icon.jpg" + icon_dark_hash = filemd5("/path/to/icon_dark.jpg") + icon_dark_path = "/path/to/icon_dark.jpg" + font_hash = filemd5("/path/to/font.tff") + font_path = "/path/to/font.tff" } \ No newline at end of file diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 91d9a4da..13061070 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -87,7 +87,23 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChange(setActiveVar) { + if d.HasChanges( + primaryColorVar, + hideLoginNameSuffixVar, + warnColorVar, + backgroundColorVar, + fontColorVar, + primaryColorDarkVar, + backgroundColorDarkVar, + warnColorDarkVar, + fontColorDarkVar, + disableWatermarkVar, + logoHashVar, + logoDarkHashVar, + iconHashVar, + iconDarkHashVar, + fontHashVar, + ) { if d.Get(setActiveVar).(bool) { if _, err := client.ActivateLabelPolicy(ctx, &admin.ActivateLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate default label policy: %v", err) diff --git a/zitadel/v2/label_policy/const.go b/zitadel/v2/label_policy/const.go index 04420a05..0bf958bc 100644 --- a/zitadel/v2/label_policy/const.go +++ b/zitadel/v2/label_policy/const.go @@ -12,10 +12,30 @@ const ( warnColorDarkVar = "warn_color_dark" fontColorDarkVar = "font_color_dark" disableWatermarkVar = "disable_watermark" + logoPathVar = "logo_path" + logoHashVar = "logo_hash" logoURLVar = "logo_url" + iconPathVar = "icon_path" + iconHashVar = "icon_hash" iconURLVar = "icon_url" + logoDarkPathVar = "logo_dark_path" + logoDarkHashVar = "logo_dark_hash" logoURLDarkVar = "logo_url_dark" + iconDarkPathVar = "icon_dark_path" + iconDarkHashVar = "icon_dark_hash" iconURLDarkVar = "icon_url_dark" + fontPathVar = "font_path" + fontHashVar = "font_hash" fontURLVar = "font_url" setActiveVar = "set_active" ) + +const ( + assetAPI = "/assets/v1" + labelPolicyURL = "/org/policy/label" + logoURL = assetAPI + labelPolicyURL + "/logo" + logoDarkURL = logoURL + "/dark" + iconURL = assetAPI + labelPolicyURL + "/icon" + iconDarkURL = iconURL + "/dark" + fontURL = assetAPI + labelPolicyURL + "/font" +) diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index fbaafb7d..7b860611 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -76,7 +76,49 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia d.SetId(resp.Details.ResourceOwner) } - if d.HasChange(setActiveVar) { + if d.HasChanges(logoHashVar, logoPathVar) { + if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo: %v", err) + } + } + if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { + if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo dark: %v", err) + } + } + if d.HasChanges(iconHashVar, iconPathVar) { + if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon: %v", err) + } + } + if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { + if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon dark: %v", err) + } + } + if d.HasChanges(fontHashVar, fontPathVar) { + if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + return diag.Errorf("failed to upload font: %v", err) + } + } + + if d.HasChanges( + primaryColorVar, + hideLoginNameSuffixVar, + warnColorVar, + backgroundColorVar, + fontColorVar, + primaryColorDarkVar, + backgroundColorDarkVar, + warnColorDarkVar, + fontColorDarkVar, + disableWatermarkVar, + logoHashVar, + logoDarkHashVar, + iconHashVar, + iconDarkHashVar, + fontHashVar, + ) { if d.Get(setActiveVar).(bool) { if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate label policy: %v", err) @@ -117,6 +159,32 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } d.SetId(org) + if d.Get(logoHashVar) != "" && d.Get(logoPathVar) != "" { + if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo: %v", err) + } + } + if d.Get(logoDarkHashVar) != "" && d.Get(logoDarkPathVar) != "" { + if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload logo dark: %v", err) + } + } + if d.Get(iconHashVar) != "" && d.Get(iconPathVar) != "" { + if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon: %v", err) + } + } + if d.Get(iconDarkHashVar) != "" && d.Get(iconDarkPathVar) != "" { + if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + return diag.Errorf("failed to upload icon dark: %v", err) + } + } + if d.Get(fontHashVar) != "" && d.Get(fontPathVar) != "" { + if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + return diag.Errorf("failed to upload font: %v", err) + } + } + if d.Get(setActiveVar).(bool) { if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate label policy: %v", err) diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go index 7b821d5f..5e771154 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/v2/label_policy/resource.go @@ -64,26 +64,76 @@ func GetResource() *schema.Resource { Required: true, Description: "disable watermark", }, + logoPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + logoHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, logoURLVar: { Type: schema.TypeString, Computed: true, Description: "", }, + iconPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + iconHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, iconURLVar: { Type: schema.TypeString, Computed: true, Description: "", }, + logoDarkPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + logoDarkHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, logoURLDarkVar: { Type: schema.TypeString, Computed: true, Description: "", }, + iconDarkPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + iconDarkHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, iconURLDarkVar: { Type: schema.TypeString, Computed: true, Description: "", }, + fontPathVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, + fontHashVar: { + Type: schema.TypeString, + Optional: true, + Description: "", + }, fontURLVar: { Type: schema.TypeString, Computed: true, From 15aabdb95ed59dbca9664e9b64edbd17988c510e Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 21 Dec 2022 14:01:34 +0100 Subject: [PATCH 037/260] fix: add icon, logo and font uploads to label policy --- zitadel/v2/default_label_policy/funcs.go | 10 ++--- zitadel/v2/helper/form.go | 47 +++++++++++++++++------- zitadel/v2/label_policy/funcs.go | 20 +++++----- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 13061070..466f4a01 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -62,27 +62,27 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges(logoHashVar, logoPathVar) { - if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + if err := helper.InstanceFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { - if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + if err := helper.InstanceFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } if d.HasChanges(iconHashVar, iconPathVar) { - if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + if err := helper.InstanceFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { - if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + if err := helper.InstanceFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } if d.HasChanges(fontHashVar, fontPathVar) { - if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + if err := helper.InstanceFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { return diag.Errorf("failed to upload font: %v", err) } } diff --git a/zitadel/v2/helper/form.go b/zitadel/v2/helper/form.go index dc886881..0d96f832 100644 --- a/zitadel/v2/helper/form.go +++ b/zitadel/v2/helper/form.go @@ -25,24 +25,17 @@ func escapeQuotes(s string) string { return quoteEscaper.Replace(s) } -func FormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostics { +func createMultipartRequest(issuer, endpoint, path string) (*http.Request, error) { file, err := os.Open(path) if err != nil { - return diag.Errorf("failed to read file: %v", err) - } - info, err := file.Stat() - if err != nil { - return diag.Errorf("failed to read file info: %v", err) - } - if info.Size() > (1 << 19) { - return diag.Errorf("file to large") + return nil, fmt.Errorf("failed to read file: %v", err) } body := &bytes.Buffer{} writer := multipart.NewWriter(body) data, err := io.ReadAll(file) if err != nil { - return diag.Errorf("failed to read asset: %v", err) + return nil, fmt.Errorf("failed to read asset: %v", err) } h := make(textproto.MIMEHeader) @@ -52,17 +45,45 @@ func FormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostic h.Set("Content-Type", mimetype.Detect(data).String()) part, err := writer.CreatePart(h) if err != nil { - return diag.Errorf("failed to create asset part: %v", err) + return nil, fmt.Errorf("failed to create asset part: %v", err) } io.Copy(part, bytes.NewBuffer(data)) writer.Close() - r, err := http.NewRequest(http.MethodPost, clientInfo.Issuer+endpoint, body) + r, err := http.NewRequest(http.MethodPost, issuer+endpoint, body) if err != nil { - return diag.Errorf("failed to create asset request: %v", err) + return nil, fmt.Errorf("failed to create asset request: %v", err) } r.Header.Add("Content-Type", writer.FormDataContentType()) + return r, nil +} + +func InstanceFormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostics { + r, err := createMultipartRequest(clientInfo.Issuer, endpoint, path) + if err != nil { + return diag.Errorf("failed to create asset request: %v", err) + } + + client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) + if err != nil { + return diag.Errorf("failed to create client: %v", err) + } + + resp, err := client.Do(r) + if err != nil || resp.StatusCode != http.StatusOK { + return diag.Errorf("failed to do asset request: %v", err) + } + return nil +} + +func OrgFormFilePost(clientInfo *ClientInfo, endpoint, orgID, path string) diag.Diagnostics { + r, err := createMultipartRequest(clientInfo.Issuer, endpoint, path) + if err != nil { + return diag.Errorf("failed to create asset request: %v", err) + } + r.Header.Add("x-zitadel-orgid", orgID) + client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) if err != nil { return diag.Errorf("failed to create client: %v", err) diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index 7b860611..dbab8338 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -77,27 +77,27 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges(logoHashVar, logoPathVar) { - if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoURL, org, d.Get(logoPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { - if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, org, d.Get(logoDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } if d.HasChanges(iconHashVar, iconPathVar) { - if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconURL, org, d.Get(iconPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { - if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, org, d.Get(iconDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } if d.HasChanges(fontHashVar, fontPathVar) { - if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, fontURL, org, d.Get(fontPathVar).(string)); err != nil { return diag.Errorf("failed to upload font: %v", err) } } @@ -160,27 +160,27 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia d.SetId(org) if d.Get(logoHashVar) != "" && d.Get(logoPathVar) != "" { - if err := helper.FormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoURL, org, d.Get(logoPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } if d.Get(logoDarkHashVar) != "" && d.Get(logoDarkPathVar) != "" { - if err := helper.FormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, org, d.Get(logoDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } if d.Get(iconHashVar) != "" && d.Get(iconPathVar) != "" { - if err := helper.FormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconURL, org, d.Get(iconPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } if d.Get(iconDarkHashVar) != "" && d.Get(iconDarkPathVar) != "" { - if err := helper.FormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, org, d.Get(iconDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } if d.Get(fontHashVar) != "" && d.Get(fontPathVar) != "" { - if err := helper.FormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, fontURL, org, d.Get(fontPathVar).(string)); err != nil { return diag.Errorf("failed to upload font: %v", err) } } From 78f4565380cdfab54c83ee890e748b5e3fdb5071 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 21 Dec 2022 14:52:23 +0100 Subject: [PATCH 038/260] fix: add zitadel_instance_member --- docs/resources/instance_member.md | 33 ++++ .../provider/resources/instance_member.tf | 6 + templates/resources/instance_member.md.tmpl | 16 ++ zitadel/provider.go | 2 + zitadel/v2/instance_member/const.go | 6 + zitadel/v2/instance_member/funcs.go | 143 ++++++++++++++++++ zitadel/v2/instance_member/resource.go | 32 ++++ 7 files changed, 238 insertions(+) create mode 100644 docs/resources/instance_member.md create mode 100644 examples/provider/resources/instance_member.tf create mode 100644 templates/resources/instance_member.md.tmpl create mode 100644 zitadel/v2/instance_member/const.go create mode 100644 zitadel/v2/instance_member/funcs.go create mode 100644 zitadel/v2/instance_member/resource.go diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md new file mode 100644 index 00000000..7c212ee5 --- /dev/null +++ b/docs/resources/instance_member.md @@ -0,0 +1,33 @@ +--- +page_title: "zitadel_instance_member Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the membership of a user on an instance, defined with the given role. +--- + +# zitadel_instance_member (Resource) + +Resource representing the membership of a user on an instance, defined with the given role. + +## Example Usage + +```terraform +resource zitadel_instance_member instance_member { + depends_on = [zitadel_human_user.human_user] + + user_id = zitadel_human_user.human_user.id + roles = ["IAM_OWNER"] +} +``` + + +## Schema + +### Required + +- `roles` (Set of String) List of roles granted +- `user_id` (String) ID of the user + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/examples/provider/resources/instance_member.tf b/examples/provider/resources/instance_member.tf new file mode 100644 index 00000000..b4f03f98 --- /dev/null +++ b/examples/provider/resources/instance_member.tf @@ -0,0 +1,6 @@ +resource zitadel_instance_member instance_member { + depends_on = [zitadel_human_user.human_user] + + user_id = zitadel_human_user.human_user.id + roles = ["IAM_OWNER"] +} \ No newline at end of file diff --git a/templates/resources/instance_member.md.tmpl b/templates/resources/instance_member.md.tmpl new file mode 100644 index 00000000..9a8b83ed --- /dev/null +++ b/templates/resources/instance_member.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/instance_member.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 0b6016a9..8858a1b8 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -34,6 +34,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" @@ -206,6 +207,7 @@ func Provider() *schema.Provider { "zitadel_project_grant": project_grant.GetResource(), "zitadel_user_grant": user_grant.GetResource(), "zitadel_org_member": org_member.GetResource(), + "zitadel_instance_member": instance_member.GetResource(), "zitadel_project_member": project_member.GetResource(), "zitadel_project_grant_member": project_grant_member.GetResource(), "zitadel_domain_policy": domain_policy.GetResource(), diff --git a/zitadel/v2/instance_member/const.go b/zitadel/v2/instance_member/const.go new file mode 100644 index 00000000..7272c360 --- /dev/null +++ b/zitadel/v2/instance_member/const.go @@ -0,0 +1,6 @@ +package instance_member + +const ( + userIDVar = "user_id" + rolesVar = "roles" +) diff --git a/zitadel/v2/instance_member/funcs.go b/zitadel/v2/instance_member/funcs.go new file mode 100644 index 00000000..2d79e645 --- /dev/null +++ b/zitadel/v2/instance_member/funcs.go @@ -0,0 +1,143 @@ +package instance_member + +import ( + "context" + "strings" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveIAMMember(ctx, &admin.RemoveIAMMemberRequest{ + UserId: d.Get(userIDVar).(string), + }) + if err != nil { + return diag.Errorf("failed to delete instance member: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateIAMMember(ctx, &admin.UpdateIAMMemberRequest{ + UserId: d.Get(userIDVar).(string), + Roles: helper.GetOkSetToStringSlice(d, rolesVar), + }) + if err != nil { + return diag.Errorf("failed to update instance member: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + resp, err := client.AddIAMMember(ctx, &admin.AddIAMMemberRequest{ + UserId: userID, + Roles: helper.GetOkSetToStringSlice(d, rolesVar), + }) + if err != nil { + return diag.Errorf("failed to create instance member: %v", err) + } + d.SetId(getInstanceMemberID(resp.GetDetails().GetResourceOwner(), userID)) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + userID := d.Get(userIDVar).(string) + resp, err := client.ListIAMMembers(ctx, &admin.ListIAMMembersRequest{ + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to list instance members") + } + + if len(resp.Result) == 1 { + member := resp.Result[0] + set := map[string]interface{}{ + userIDVar: member.GetUserId(), + rolesVar: member.GetRoles(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of instance member: %v", k, err) + } + } + d.SetId(getInstanceMemberID(member.GetDetails().GetResourceOwner(), userID)) + return nil + } + + d.SetId("") + return nil +} + +func getInstanceMemberID(instance string, userID string) string { + return instance + "_" + userID +} + +func splitInstanceMemberID(memberID string) (string, string) { + parts := strings.Split(memberID, "_") + return parts[0], parts[1] +} diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/v2/instance_member/resource.go new file mode 100644 index 00000000..dcb73a27 --- /dev/null +++ b/zitadel/v2/instance_member/resource.go @@ -0,0 +1,32 @@ +package instance_member + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the membership of a user on an instance, defined with the given role.", + Schema: map[string]*schema.Schema{ + userIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the user", + ForceNew: true, + }, + rolesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "List of roles granted", + }, + }, + DeleteContext: delete, + CreateContext: create, + UpdateContext: update, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From cfbda7a3827e7a23204c51263d38125fe70b1e64 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 22 Dec 2022 11:22:46 +0100 Subject: [PATCH 039/260] fix: refactor form post functions --- zitadel/v2/helper/form.go | 24 ++++++++---------------- zitadel/v2/label_policy/funcs.go | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/zitadel/v2/helper/form.go b/zitadel/v2/helper/form.go index 0d96f832..d90cb536 100644 --- a/zitadel/v2/helper/form.go +++ b/zitadel/v2/helper/form.go @@ -60,29 +60,21 @@ func createMultipartRequest(issuer, endpoint, path string) (*http.Request, error } func InstanceFormFilePost(clientInfo *ClientInfo, endpoint, path string) diag.Diagnostics { - r, err := createMultipartRequest(clientInfo.Issuer, endpoint, path) - if err != nil { - return diag.Errorf("failed to create asset request: %v", err) - } - - client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) - if err != nil { - return diag.Errorf("failed to create client: %v", err) - } + return formFilePost(clientInfo, endpoint, path, map[string]string{}) +} - resp, err := client.Do(r) - if err != nil || resp.StatusCode != http.StatusOK { - return diag.Errorf("failed to do asset request: %v", err) - } - return nil +func OrgFormFilePost(clientInfo *ClientInfo, endpoint, path, orgID string) diag.Diagnostics { + return formFilePost(clientInfo, endpoint, path, map[string]string{"x-zitadel-orgid": orgID}) } -func OrgFormFilePost(clientInfo *ClientInfo, endpoint, orgID, path string) diag.Diagnostics { +func formFilePost(clientInfo *ClientInfo, endpoint, path string, additionalHeaders map[string]string) diag.Diagnostics { r, err := createMultipartRequest(clientInfo.Issuer, endpoint, path) if err != nil { return diag.Errorf("failed to create asset request: %v", err) } - r.Header.Add("x-zitadel-orgid", orgID) + for k, v := range additionalHeaders { + r.Header.Add(k, v) + } client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) if err != nil { diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index dbab8338..fbf7fdbe 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -77,27 +77,27 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges(logoHashVar, logoPathVar) { - if err := helper.OrgFormFilePost(clientinfo, logoURL, org, d.Get(logoPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { - if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, org, d.Get(logoDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } if d.HasChanges(iconHashVar, iconPathVar) { - if err := helper.OrgFormFilePost(clientinfo, iconURL, org, d.Get(iconPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { - if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, org, d.Get(iconDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } if d.HasChanges(fontHashVar, fontPathVar) { - if err := helper.OrgFormFilePost(clientinfo, fontURL, org, d.Get(fontPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string), org); err != nil { return diag.Errorf("failed to upload font: %v", err) } } @@ -160,27 +160,27 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia d.SetId(org) if d.Get(logoHashVar) != "" && d.Get(logoPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, logoURL, org, d.Get(logoPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } if d.Get(logoDarkHashVar) != "" && d.Get(logoDarkPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, org, d.Get(logoDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } if d.Get(iconHashVar) != "" && d.Get(iconPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, iconURL, org, d.Get(iconPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } if d.Get(iconDarkHashVar) != "" && d.Get(iconDarkPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, org, d.Get(iconDarkPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } if d.Get(fontHashVar) != "" && d.Get(fontPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, fontURL, org, d.Get(fontPathVar).(string)); err != nil { + if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string), org); err != nil { return diag.Errorf("failed to upload font: %v", err) } } From 19d2c653c2ce2ffefa5c8f1f73f48596bace7043 Mon Sep 17 00:00:00 2001 From: Barthy Date: Wed, 1 Feb 2023 14:02:13 +0100 Subject: [PATCH 040/260] doc: added links and formats --- zitadel/v2/app_key/resource.go | 2 +- zitadel/v2/instance_member/resource.go | 2 +- zitadel/v2/label_policy/resource.go | 2 +- zitadel/v2/machine_key/resource.go | 2 +- zitadel/v2/pat/resource.go | 2 +- zitadel/v2/smtp_config/resource.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index 139662ba..bfcf7f2d 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -43,7 +43,7 @@ func GetResource() *schema.Resource { expirationDateVar: { Type: schema.TypeString, Required: true, - Description: "Expiration date of the app key", + Description: "Expiration date of the app key in the RFC3339 format", ForceNew: true, }, keyDetailsVar: { diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/v2/instance_member/resource.go index dcb73a27..d2c541a8 100644 --- a/zitadel/v2/instance_member/resource.go +++ b/zitadel/v2/instance_member/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { Type: schema.TypeString, }, Required: true, - Description: "List of roles granted", + Description: "List of roles granted, full list available here: https://zitadel.com/docs/guides/manage/console/managers#roles", }, }, DeleteContext: delete, diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go index 5e771154..b153d32e 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/v2/label_policy/resource.go @@ -22,7 +22,7 @@ func GetResource() *schema.Resource { hideLoginNameSuffixVar: { Type: schema.TypeBool, Required: true, - Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes", + Description: "hides the org suffix on the login form if the scope \"urn:zitadel:iam:org:domain:primary:{domainname}\" is set. Details about this scope in https://zitadel.com/docs/apis/openidoauth/scopes#reserved-scopes", }, warnColorVar: { Type: schema.TypeString, diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index 72c1b339..36d53fd2 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -37,7 +37,7 @@ func GetResource() *schema.Resource { expirationDateVar: { Type: schema.TypeString, Optional: true, - Description: "Expiration date of the machine key", + Description: "Expiration date of the machine key in the RFC3339 format", ForceNew: true, Computed: true, }, diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index 3d1deede..e4b0ca5e 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -29,7 +29,7 @@ func GetResource() *schema.Resource { expirationDateVar: { Type: schema.TypeString, Optional: true, - Description: "Expiration date of the token", + Description: "Expiration date of the token in the RFC3339 format", ForceNew: true, }, }, diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index 15438f42..ee5b959e 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -26,7 +26,7 @@ func GetResource() *schema.Resource { hostVar: { Type: schema.TypeString, Required: true, - Description: "Host address to your SMTP server.", + Description: "Host and port address to your SMTP server.", }, userVar: { Type: schema.TypeString, From 39ee10b8a5f64cd9489b09ba261ab90f0142d2d3 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Mon, 6 Feb 2023 11:26:07 +0900 Subject: [PATCH 041/260] feat: add jwt_profile_json to authenticate --- zitadel/provider.go | 40 ++++++++++++++++++++++++++++++------- zitadel/v2/helper/client.go | 21 +++++++++++++------ 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index 8858a1b8..9c265cf9 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -75,10 +75,12 @@ func NewProviderPV6() provider.Provider { } type providerModel struct { - Insecure types.Bool `tfsdk:"insecure"` - Domain types.String `tfsdk:"domain"` - Token types.String `tfsdk:"token"` - Port types.String `tfsdk:"port"` + Insecure types.Bool `tfsdk:"insecure"` + Domain types.String `tfsdk:"domain"` + Token types.String `tfsdk:"token"` + Port types.String `tfsdk:"port"` + JWTProfileFile types.String `tfsdk:"jwt_profile_file"` + JWTProfileJSON types.String `tfsdk:"jwt_profile_json"` } func (p *providerPV6) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { @@ -97,11 +99,21 @@ func (p *providerPV6) GetSchema(_ context.Context) (tfsdk.Schema, fdiag.Diagnost Optional: true, Description: "Use insecure connection", }, - helper.TokenVar: { + helper.JWTProfileFile: { Type: types.StringType, - Required: true, + Optional: true, Description: "Path to the file containing credentials to connect to ZITADEL", }, + helper.JWTProfileJSON: { + Type: types.StringType, + Optional: true, + Description: "JSON value of credentials to connect to ZITADEL", + }, + helper.TokenVar: { + Type: types.StringType, + Optional: true, + Description: "Path to the file containing credentials to connect to ZITADEL (deprecated)", + }, helper.PortVar: { Type: types.StringType, Optional: true, @@ -122,6 +134,8 @@ func (p *providerPV6) Configure(ctx context.Context, req provider.ConfigureReque info, err := helper.GetClientInfo( config.Insecure.ValueBool(), config.Domain.ValueString(), + config.JWTProfileFile.ValueString(), + config.JWTProfileJSON.ValueString(), config.Token.ValueString(), config.Port.ValueString(), ) @@ -184,9 +198,19 @@ func Provider() *schema.Provider { }, helper.TokenVar: { Type: schema.TypeString, - Required: true, + Optional: true, + Description: "Path to the file containing credentials to connect to ZITADEL (deprecated)", + }, + helper.JWTProfileFile: { + Type: schema.TypeString, + Optional: true, Description: "Path to the file containing credentials to connect to ZITADEL", }, + helper.JWTProfileJSON: { + Type: schema.TypeString, + Optional: true, + Description: "JSON value of credentials to connect to ZITADEL", + }, helper.PortVar: { Type: schema.TypeString, Optional: true, @@ -238,6 +262,8 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} clientinfo, err := helper.GetClientInfo( d.Get(helper.InsecureVar).(bool), d.Get(helper.DomainVar).(string), + d.Get(helper.JWTProfileFile).(string), + d.Get(helper.JWTProfileJSON).(string), d.Get(helper.TokenVar).(string), d.Get(helper.PortVar).(string), ) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 8f549cff..3b65e853 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -13,10 +13,12 @@ import ( ) const ( - DomainVar = "domain" - InsecureVar = "insecure" - TokenVar = "token" - PortVar = "port" + DomainVar = "domain" + InsecureVar = "insecure" + TokenVar = "token" + PortVar = "port" + JWTProfileFile = "jwt_profile_file" + JWTProfileJSON = "jwt_profile_json" ) type ClientInfo struct { @@ -26,8 +28,15 @@ type ClientInfo struct { Options []zitadel.Option } -func GetClientInfo(insecure bool, domain string, token string, port string) (*ClientInfo, error) { - options := []zitadel.Option{zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(token))} +func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfileJSON string, token string, port string) (*ClientInfo, error) { + options := []zitadel.Option{} + if jwtProfileFile != "" { + options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(jwtProfileFile))) + } else if jwtProfileJSON != "" { + options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromFileData([]byte(jwtProfileJSON)))) + } else { + options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(token))) + } issuer := "" if port != "" { From 2e5c459100f4699ab023e0e6bc0fce925d1053f7 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 13 Feb 2023 12:56:09 +0100 Subject: [PATCH 042/260] feat: add missing login policy fields --- zitadel/v2/default_login_policy/const.go | 3 +++ zitadel/v2/default_login_policy/funcs.go | 6 +++++ zitadel/v2/default_login_policy/resource.go | 27 +++++++++++++++++++++ zitadel/v2/login_policy/const.go | 3 +++ zitadel/v2/login_policy/funcs.go | 3 +++ zitadel/v2/login_policy/resource.go | 27 +++++++++++++++++++++ 6 files changed, 69 insertions(+) diff --git a/zitadel/v2/default_login_policy/const.go b/zitadel/v2/default_login_policy/const.go index 96e5e0cc..eed1e292 100644 --- a/zitadel/v2/default_login_policy/const.go +++ b/zitadel/v2/default_login_policy/const.go @@ -17,4 +17,7 @@ const ( secondFactorsVar = "second_factors" multiFactorsVar = "multi_factors" idpsVar = "idps" + allowDomainDiscovery = "allow_domain_discovery" + disableLoginWithEmail = "disable_login_with_email" + disableLoginWithPhone = "disable_login_with_phone" ) diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index f081a9ba..cade6e32 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -45,6 +45,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia hidePasswordResetVar, ignoreUnknownUsernamesVar, defaultRedirectURIVar, + allowDomainDiscovery, + disableLoginWithEmail, + disableLoginWithPhone, ) { passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) if err != nil { @@ -80,6 +83,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), + DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), + DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), }) if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update login policy: %v", err) diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index d3416f02..83b3a5cc 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -97,6 +97,33 @@ func GetResource() *schema.Resource { Optional: true, Description: "allowed idps to login or register", }, + allowDomainDiscovery: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", + }, + disableLoginWithEmail: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "defines if user can additionally (to the loginname) be identified by their verified email address", + }, + disableLoginWithPhone: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", + }, }, CreateContext: update, UpdateContext: update, diff --git a/zitadel/v2/login_policy/const.go b/zitadel/v2/login_policy/const.go index c310b402..ed75c06c 100644 --- a/zitadel/v2/login_policy/const.go +++ b/zitadel/v2/login_policy/const.go @@ -18,4 +18,7 @@ const ( secondFactorsVar = "second_factors" multiFactorsVar = "multi_factors" idpsVar = "idps" + allowDomainDiscovery = "allow_domain_discovery" + disableLoginWithEmail = "disable_login_with_email" + disableLoginWithPhone = "disable_login_with_phone" ) diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index baacfe0c..51cf55d3 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -99,6 +99,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), SecondFactorCheckLifetime: durationpb.New(secondFactorCheckLT), MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), + AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), + DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), + DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), }) if err != nil { return diag.Errorf("failed to update login policy: %v", err) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index 702c0b2d..7013142d 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -103,6 +103,33 @@ func GetResource() *schema.Resource { Optional: true, Description: "allowed idps to login or register", }, + allowDomainDiscovery: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", + }, + disableLoginWithEmail: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "defines if user can additionally (to the loginname) be identified by their verified email address", + }, + disableLoginWithPhone: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeBool, + }, + Optional: true, + Default: false, + Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", + }, }, CreateContext: create, UpdateContext: update, From e3e058256b841f61939916ca8ae6adb9b99c6e17 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 13 Feb 2023 12:57:35 +0100 Subject: [PATCH 043/260] chore: ignore idea --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 35da205c..46ae5331 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,7 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* -/test \ No newline at end of file +/test + +# IDEs +.idea From 8a7f7c9571565850884727b10ddc19b8e9be8b8d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 13 Feb 2023 12:58:10 +0100 Subject: [PATCH 044/260] chore: regenerate --- gen.sh | 10 +- .../zitadel/pkg/grpc/text/text_terraform.go | 399 ++++++++++-------- 2 files changed, 227 insertions(+), 182 deletions(-) diff --git a/gen.sh b/gen.sh index cde6a922..506392e0 100755 --- a/gen.sh +++ b/gen.sh @@ -1,14 +1,14 @@ protoc \ - -I$(PWD) \ + -I$(pwd) \ -I$(go env GOPATH)/src/github.com/gogo/protobuf \ -I$(go env GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \ - -I$(go env GOPATH)/src/github.com/bufbuild/protoc-gen-validate \ + -I$(go env GOPATH)/src/github.com/envoyproxy/protoc-gen-validate \ -I$(go env GOPATH)/src/github.com/zitadel/zitadel/proto \ --plugin=$(go env GOBIN)/protoc-gen-terraform \ --terraform_out=config=gen/config.yaml:gen \ $(go env GOPATH)/src/github.com/zitadel/zitadel/proto/zitadel/text.proto -sed -i '' 's#_ "github.com/zitadel/zitadel/pkg/grpc/object"##g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go -sed -i '' 's#textpb "textpb"#textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text"#g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go -sed -i '' 's/U2f/U2F/g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +sed -i 's#_ "github.com/zitadel/zitadel/pkg/grpc/object"##g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +sed -i 's#textpb "textpb"#textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text"#g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +sed -i 's/U2f/U2F/g' gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go index 3d18889d..499c5f1b 100644 --- a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -21,8 +21,8 @@ package text import ( context "context" fmt "fmt" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" math "math" + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" _ "github.com/envoyproxy/protoc-gen-validate/validate" proto "github.com/gogo/protobuf/proto" @@ -32,6 +32,7 @@ import ( github_com_hashicorp_terraform_plugin_framework_tfsdk "github.com/hashicorp/terraform-plugin-framework/tfsdk" github_com_hashicorp_terraform_plugin_framework_types "github.com/hashicorp/terraform-plugin-framework/types" github_com_hashicorp_terraform_plugin_go_tftypes "github.com/hashicorp/terraform-plugin-go/tftypes" + ) // Reference imports to suppress errors if they are not otherwise used. @@ -151,27 +152,27 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "privacy_link_text": { + "privacy_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "title": { + "privacy_link_text": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_and_privacy_label": { + "title": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm": { + "tos_and_privacy_label": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm_and": { + "tos_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, @@ -207,27 +208,27 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "privacy_link_text": { + "privacy_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "title": { + "privacy_link_text": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_and_privacy_label": { + "title": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm": { + "tos_and_privacy_label": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm_and": { + "tos_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, @@ -982,6 +983,11 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, + "login_button_text": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, "title": { Description: "", Optional: true, @@ -1033,6 +1039,11 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, + "privacy_confirm": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, "privacy_link_text": { Description: "", Optional: true, @@ -1058,11 +1069,6 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm_and": { - Description: "", - Optional: true, - Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, - }, "tos_link_text": { Description: "", Optional: true, @@ -1134,27 +1140,27 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "privacy_link_text": { + "privacy_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "title": { + "privacy_link_text": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_and_privacy_label": { + "title": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm": { + "tos_and_privacy_label": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "tos_confirm_and": { + "tos_confirm": { Description: "", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, @@ -1792,6 +1798,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["privacy_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.privacy_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyConfirm = t + } + } + } { a, ok := tf.Attrs["privacy_link_text"] if !ok { @@ -1860,23 +1883,6 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } - { - a, ok := tf.Attrs["tos_confirm_and"] - if !ok { - diags.Append(attrReadMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and"}) - } else { - v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } else { - var t string - if !v.Null && !v.Unknown { - t = string(v.Value) - } - obj.TosConfirmAnd = t - } - } - } { a, ok := tf.Attrs["tos_link_text"] if !ok { @@ -1980,6 +1986,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["privacy_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.privacy_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyConfirm = t + } + } + } { a, ok := tf.Attrs["privacy_link_text"] if !ok { @@ -2048,23 +2071,6 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } - { - a, ok := tf.Attrs["tos_confirm_and"] - if !ok { - diags.Append(attrReadMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and"}) - } else { - v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrReadConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } else { - var t string - if !v.Null && !v.Unknown { - t = string(v.Value) - } - obj.TosConfirmAnd = t - } - } - } { a, ok := tf.Attrs["tos_link_text"] if !ok { @@ -4501,6 +4507,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["login_button_text"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_option_text.login_button_text"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_option_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.LoginButtonText = t + } + } + } { a, ok := tf.Attrs["title"] if !ok { @@ -4672,6 +4695,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["privacy_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.privacy_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyConfirm = t + } + } + } { a, ok := tf.Attrs["privacy_link_text"] if !ok { @@ -4757,23 +4797,6 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } - { - a, ok := tf.Attrs["tos_confirm_and"] - if !ok { - diags.Append(attrReadMissingDiag{"LoginCustomText.registration_org_text.tos_confirm_and"}) - } else { - v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } else { - var t string - if !v.Null && !v.Unknown { - t = string(v.Value) - } - obj.TosConfirmAnd = t - } - } - } { a, ok := tf.Attrs["tos_link_text"] if !ok { @@ -5013,6 +5036,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["privacy_confirm"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.privacy_confirm"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PrivacyConfirm = t + } + } + } { a, ok := tf.Attrs["privacy_link_text"] if !ok { @@ -5081,23 +5121,6 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } - { - a, ok := tf.Attrs["tos_confirm_and"] - if !ok { - diags.Append(attrReadMissingDiag{"LoginCustomText.registration_user_text.tos_confirm_and"}) - } else { - v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrReadConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } else { - var t string - if !v.Null && !v.Unknown { - t = string(v.Value) - } - obj.TosConfirmAnd = t - } - } - } { a, ok := tf.Attrs["tos_link_text"] if !ok { @@ -6256,6 +6279,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["phone_label"] = v } } + { + t, ok := tf.AttrTypes["privacy_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.privacy_confirm"}) + } else { + v, ok := tf.Attrs["privacy_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.privacy_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyConfirm) == "" + } + v.Value = string(obj.PrivacyConfirm) + v.Unknown = false + tf.Attrs["privacy_confirm"] = v + } + } { t, ok := tf.AttrTypes["privacy_link_text"] if !ok { @@ -6344,28 +6389,6 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["tos_confirm"] = v } } - { - t, ok := tf.AttrTypes["tos_confirm_and"] - if !ok { - diags.Append(attrWriteMissingDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and"}) - } else { - v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) - if err != nil { - diags.Append(attrWriteGeneralError{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", err}) - } - v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_registration_user_overview_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } - v.Null = string(obj.TosConfirmAnd) == "" - } - v.Value = string(obj.TosConfirmAnd) - v.Unknown = false - tf.Attrs["tos_confirm_and"] = v - } - } { t, ok := tf.AttrTypes["tos_link_text"] if !ok { @@ -6508,6 +6531,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["link_button_text"] = v } } + { + t, ok := tf.AttrTypes["privacy_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.privacy_confirm"}) + } else { + v, ok := tf.Attrs["privacy_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.privacy_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyConfirm) == "" + } + v.Value = string(obj.PrivacyConfirm) + v.Unknown = false + tf.Attrs["privacy_confirm"] = v + } + } { t, ok := tf.AttrTypes["privacy_link_text"] if !ok { @@ -6596,28 +6641,6 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["tos_confirm"] = v } } - { - t, ok := tf.AttrTypes["tos_confirm_and"] - if !ok { - diags.Append(attrWriteMissingDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and"}) - } else { - v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) - if err != nil { - diags.Append(attrWriteGeneralError{"LoginCustomText.external_user_not_found_text.tos_confirm_and", err}) - } - v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.external_user_not_found_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } - v.Null = string(obj.TosConfirmAnd) == "" - } - v.Value = string(obj.TosConfirmAnd) - v.Unknown = false - tf.Attrs["tos_confirm_and"] = v - } - } { t, ok := tf.AttrTypes["tos_link_text"] if !ok { @@ -9962,6 +9985,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["external_login_description"] = v } } + { + t, ok := tf.AttrTypes["login_button_text"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_option_text.login_button_text"}) + } else { + v, ok := tf.Attrs["login_button_text"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_option_text.login_button_text", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_option_text.login_button_text", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.LoginButtonText) == "" + } + v.Value = string(obj.LoginButtonText) + v.Unknown = false + tf.Attrs["login_button_text"] = v + } + } { t, ok := tf.AttrTypes["title"] if !ok { @@ -10192,6 +10237,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["password_label"] = v } } + { + t, ok := tf.AttrTypes["privacy_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.privacy_confirm"}) + } else { + v, ok := tf.Attrs["privacy_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.privacy_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyConfirm) == "" + } + v.Value = string(obj.PrivacyConfirm) + v.Unknown = false + tf.Attrs["privacy_confirm"] = v + } + } { t, ok := tf.AttrTypes["privacy_link_text"] if !ok { @@ -10302,28 +10369,6 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["tos_confirm"] = v } } - { - t, ok := tf.AttrTypes["tos_confirm_and"] - if !ok { - diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_org_text.tos_confirm_and"}) - } else { - v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) - if err != nil { - diags.Append(attrWriteGeneralError{"LoginCustomText.registration_org_text.tos_confirm_and", err}) - } - v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_org_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } - v.Null = string(obj.TosConfirmAnd) == "" - } - v.Value = string(obj.TosConfirmAnd) - v.Unknown = false - tf.Attrs["tos_confirm_and"] = v - } - } { t, ok := tf.AttrTypes["tos_link_text"] if !ok { @@ -10642,6 +10687,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["password_label"] = v } } + { + t, ok := tf.AttrTypes["privacy_confirm"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.privacy_confirm"}) + } else { + v, ok := tf.Attrs["privacy_confirm"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.privacy_confirm", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.privacy_confirm", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PrivacyConfirm) == "" + } + v.Value = string(obj.PrivacyConfirm) + v.Unknown = false + tf.Attrs["privacy_confirm"] = v + } + } { t, ok := tf.AttrTypes["privacy_link_text"] if !ok { @@ -10730,28 +10797,6 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["tos_confirm"] = v } } - { - t, ok := tf.AttrTypes["tos_confirm_and"] - if !ok { - diags.Append(attrWriteMissingDiag{"LoginCustomText.registration_user_text.tos_confirm_and"}) - } else { - v, ok := tf.Attrs["tos_confirm_and"].(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) - if err != nil { - diags.Append(attrWriteGeneralError{"LoginCustomText.registration_user_text.tos_confirm_and", err}) - } - v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.registration_user_text.tos_confirm_and", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } - v.Null = string(obj.TosConfirmAnd) == "" - } - v.Value = string(obj.TosConfirmAnd) - v.Unknown = false - tf.Attrs["tos_confirm_and"] = v - } - } { t, ok := tf.AttrTypes["tos_link_text"] if !ok { From 6f8b369442389485df91cfd9c0b2a55992043f27 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 13 Feb 2023 12:58:25 +0100 Subject: [PATCH 045/260] fix: update dependencies --- go.mod | 30 ++++++++++------ go.sum | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index b4bfb505..5b72a6c6 100644 --- a/go.mod +++ b/go.mod @@ -3,31 +3,34 @@ module github.com/zitadel/terraform-provider-zitadel go 1.19 require ( - github.com/envoyproxy/protoc-gen-validate v0.9.0 + github.com/envoyproxy/protoc-gen-validate v0.9.1 github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-framework v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.1 github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 - github.com/zitadel/oidc v1.11.0 - github.com/zitadel/zitadel-go/v2 v2.0.2 - golang.org/x/oauth2 v0.2.0 - google.golang.org/grpc v1.51.0 + github.com/zitadel/oidc v1.12.1 + github.com/zitadel/zitadel-go/v2 v2.0.9 + golang.org/x/oauth2 v0.4.0 + google.golang.org/grpc v1.52.3 google.golang.org/protobuf v1.28.1 ) require ( github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/dave/jennifer v1.4.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect + github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed // indirect + github.com/gravitational/trace v1.1.15 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-hclog v1.2.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -39,6 +42,7 @@ require ( github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect + github.com/jonboulle/clockwork v0.2.2 // indirect github.com/kr/pretty v0.2.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect @@ -49,16 +53,22 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + github.com/stoewer/go-strcase v1.2.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.12.1 // indirect golang.org/x/crypto v0.1.0 // indirect - golang.org/x/net v0.2.0 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/mod v0.7.0 // indirect + golang.org/x/net v0.5.0 // indirect + golang.org/x/sys v0.4.0 // indirect + golang.org/x/term v0.4.0 // indirect + golang.org/x/text v0.6.0 // indirect + golang.org/x/tools v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect + google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index b6c49750..aca5b0f8 100644 --- a/go.sum +++ b/go.sum @@ -35,40 +35,58 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 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/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw= +github.com/dave/jennifer v1.4.1/go.mod h1:7jEdnm+qBcxl8PC0zyp7vxcpSRnzXSt9r39tpTVGlwA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/envoyproxy/protoc-gen-validate v0.9.0 h1:wyv+mWIshClA4g6hTlKD9xb6fiNAnDu3+8qYf7KSuSE= github.com/envoyproxy/protoc-gen-validate v0.9.0/go.mod h1:aUb/JIPT9p8VQ1hMxCrB3/NZSvKoF7fPIE1ULgCIVz0= +github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -94,6 +112,7 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -108,6 +127,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/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.6/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= @@ -123,6 +143,7 @@ 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/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -132,8 +153,16 @@ github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed h1:fe+csy2GDEmBMH/UKJuVnRuMJrTWVjV7A2WNN4pi6qU= +github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed/go.mod h1:t+a7ql/xweP/VM0BPmqGRrUtWf9Sv6Gt3bQCi/ZZQaI= +github.com/gravitational/trace v1.1.15 h1:dfaFcARt110nCX6RSvrcRUbvRawEYAasXyCqnhXo0Xg= +github.com/gravitational/trace v1.1.15/go.mod h1:RvdOUHE4SHqR3oXlFFKnGzms8a5dugHygGw1bqDstYI= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1/go.mod h1:chrfS3YoLAlKTRE5cFWvCbt8uGAjshktT4PveTUpsFQ= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= 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-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -172,12 +201,19 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKL github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 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/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -187,6 +223,7 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= 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= @@ -207,20 +244,35 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -240,19 +292,32 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= +github.com/zitadel/logging v0.3.3/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= +github.com/zitadel/oidc v1.5.1/go.mod h1:s/hyqXVzchd3Y3XA2STBv2g4UKc5HeFf4Og/Mu98AYs= github.com/zitadel/oidc v1.11.0 h1:goYglsHfCfWI+ZxqFm2ovU7x0FgM49rAYJSRjNxZ6ys= github.com/zitadel/oidc v1.11.0/go.mod h1:xgd+BAAz+QIIP8/iRz0pydZOsq8njEeRrcJJ+oP2GoY= +github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= +github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= +github.com/zitadel/zitadel-go v0.3.5 h1:j0rWIs/jC39BkKUSIYzKbFhr1NQ/0KBAvC0LfsiNX4o= +github.com/zitadel/zitadel-go v0.3.5/go.mod h1:EFtsbJQRt7cjIK6zV+wwo7OWVjtxD5HaBfJ+9VxBwtI= github.com/zitadel/zitadel-go/v2 v2.0.2 h1:mY3MfVeyS0/hI7jez80+rQlVthL4mfOKWSimNoyymKs= github.com/zitadel/zitadel-go/v2 v2.0.2/go.mod h1:G9Y6rCYGP72J3EoB3AH7lMf5SP9WwGSb5j4RebElLGo= +github.com/zitadel/zitadel-go/v2 v2.0.9 h1:XsXvbolwRFSeURF75BUpjcU9eLNiqhgmqaOe0HlAsbQ= +github.com/zitadel/zitadel-go/v2 v2.0.9/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -280,6 +345,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -289,7 +355,10 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -322,18 +391,24 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY 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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -349,6 +424,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -374,11 +450,15 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -386,16 +466,24 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.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.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -442,7 +530,10 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= +golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -492,16 +583,20 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -514,8 +609,14 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ= +google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -528,6 +629,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -539,7 +642,9 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= @@ -554,3 +659,4 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= From f05588e7d32eb37d6bdd80106cce931f4b91eb8e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 13 Feb 2023 13:06:56 +0100 Subject: [PATCH 046/260] docs: update examples --- examples/provider/resources/default_login_policy.tf | 5 ++++- examples/provider/resources/login_policy.tf | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index 32f5da3f..43796d7c 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -14,4 +14,7 @@ resource zitadel_default_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] -} \ No newline at end of file + allow_domain_discovery = true + disable_login_with_email = true + disable_login_with_phone = true +} diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index 1239a26f..d38d8620 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -18,4 +18,7 @@ resource zitadel_login_policy login_policy { second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] + allow_domain_discovery = true + disable_login_with_email = true + disable_login_with_phone = true } From b35b12e640dbd43d0a83922d1a19e5c39d56fb14 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 15 Feb 2023 09:10:43 +0100 Subject: [PATCH 047/260] docs: add changes to default login policy and login policy docs --- docs/resources/default_login_policy.md | 6 ++ docs/resources/login_policy.md | 6 ++ docs/resources/login_texts.md | 9 +- go.mod | 15 +-- go.sum | 126 +++---------------------- 5 files changed, 31 insertions(+), 131 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index d50cbcb2..0cbe6a29 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -28,6 +28,9 @@ resource zitadel_default_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] + allow_domain_discovery = true + disable_login_with_email = true + disable_login_with_phone = true } ``` @@ -52,6 +55,9 @@ resource zitadel_default_login_policy login_policy { ### Optional +- `allow_domain_discovery` (Set of Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. +- `disable_login_with_email` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified email address +- `disable_login_with_phone` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number - `idps` (Set of String) allowed idps to login or register - `multi_factors` (Set of String) allowed multi factors - `second_factors` (Set of String) allowed second factors diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 91d6be0d..552e3ee7 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -32,6 +32,9 @@ resource zitadel_login_policy login_policy { second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] + allow_domain_discovery = true + disable_login_with_email = true + disable_login_with_phone = true } ``` @@ -57,6 +60,9 @@ resource zitadel_login_policy login_policy { ### Optional +- `allow_domain_discovery` (Set of Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. +- `disable_login_with_email` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified email address +- `disable_login_with_phone` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number - `idps` (Set of String) allowed idps to login or register - `multi_factors` (Set of String) allowed multi factors - `second_factors` (Set of String) allowed second factors diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index c7e1ff85..437c4dd2 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -394,11 +394,11 @@ Optional: - `next_button_text` (String) - `nickname_label` (String) - `phone_label` (String) +- `privacy_confirm` (String) - `privacy_link_text` (String) - `title` (String) - `tos_and_privacy_label` (String) - `tos_confirm` (String) -- `tos_confirm_and` (String) - `tos_link_text` (String) - `username_label` (String) @@ -411,11 +411,11 @@ Optional: - `auto_register_button_text` (String) - `description` (String) - `link_button_text` (String) +- `privacy_confirm` (String) - `privacy_link_text` (String) - `title` (String) - `tos_and_privacy_label` (String) - `tos_confirm` (String) -- `tos_confirm_and` (String) - `tos_link_text` (String) @@ -690,6 +690,7 @@ Optional: - `description` (String) - `external_login_description` (String) +- `login_button_text` (String) - `title` (String) - `user_name_button_text` (String) @@ -706,12 +707,12 @@ Optional: - `orgname_label` (String) - `password_confirm_label` (String) - `password_label` (String) +- `privacy_confirm` (String) - `privacy_link_text` (String) - `save_button_text` (String) - `title` (String) - `tos_and_privacy_label` (String) - `tos_confirm` (String) -- `tos_confirm_and` (String) - `tos_link_text` (String) - `username_label` (String) @@ -732,11 +733,11 @@ Optional: - `next_button_text` (String) - `password_confirm_label` (String) - `password_label` (String) +- `privacy_confirm` (String) - `privacy_link_text` (String) - `title` (String) - `tos_and_privacy_label` (String) - `tos_confirm` (String) -- `tos_confirm_and` (String) - `tos_link_text` (String) - `username_label` (String) diff --git a/go.mod b/go.mod index 5b72a6c6..00074dd3 100644 --- a/go.mod +++ b/go.mod @@ -21,16 +21,14 @@ require ( ) require ( - github.com/agext/levenshtein v1.2.2 // indirect + github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/dave/jennifer v1.4.1 // indirect github.com/fatih/color v1.13.0 // indirect + github.com/go-test/deep v1.0.7 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect - github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed // indirect - github.com/gravitational/trace v1.1.15 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-hclog v1.2.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -42,33 +40,26 @@ require ( github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect github.com/kr/pretty v0.2.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect - github.com/stoewer/go-strcase v1.2.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.12.1 // indirect golang.org/x/crypto v0.1.0 // indirect - golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.5.0 // indirect golang.org/x/sys v0.4.0 // indirect - golang.org/x/term v0.4.0 // indirect golang.org/x/text v0.6.0 // indirect - golang.org/x/tools v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index aca5b0f8..21786127 100644 --- a/go.sum +++ b/go.sum @@ -33,60 +33,42 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -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/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw= -github.com/dave/jennifer v1.4.1/go.mod h1:7jEdnm+qBcxl8PC0zyp7vxcpSRnzXSt9r39tpTVGlwA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= -github.com/envoyproxy/protoc-gen-validate v0.9.0 h1:wyv+mWIshClA4g6hTlKD9xb6fiNAnDu3+8qYf7KSuSE= -github.com/envoyproxy/protoc-gen-validate v0.9.0/go.mod h1:aUb/JIPT9p8VQ1hMxCrB3/NZSvKoF7fPIE1ULgCIVz0= +github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= +github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -112,7 +94,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -127,7 +108,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/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.6/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= @@ -143,25 +123,15 @@ 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/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed h1:fe+csy2GDEmBMH/UKJuVnRuMJrTWVjV7A2WNN4pi6qU= -github.com/gravitational/protoc-gen-terraform v0.0.0-20220907070727-faa35f8a97ed/go.mod h1:t+a7ql/xweP/VM0BPmqGRrUtWf9Sv6Gt3bQCi/ZZQaI= -github.com/gravitational/trace v1.1.15 h1:dfaFcARt110nCX6RSvrcRUbvRawEYAasXyCqnhXo0Xg= -github.com/gravitational/trace v1.1.15/go.mod h1:RvdOUHE4SHqR3oXlFFKnGzms8a5dugHygGw1bqDstYI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1/go.mod h1:chrfS3YoLAlKTRE5cFWvCbt8uGAjshktT4PveTUpsFQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= 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= @@ -201,19 +171,13 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKL github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 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/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -223,7 +187,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= 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= @@ -234,8 +197,8 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= @@ -244,35 +207,21 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -292,17 +241,9 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/zitadel/logging v0.3.3/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.5.1/go.mod h1:s/hyqXVzchd3Y3XA2STBv2g4UKc5HeFf4Og/Mu98AYs= -github.com/zitadel/oidc v1.11.0 h1:goYglsHfCfWI+ZxqFm2ovU7x0FgM49rAYJSRjNxZ6ys= -github.com/zitadel/oidc v1.11.0/go.mod h1:xgd+BAAz+QIIP8/iRz0pydZOsq8njEeRrcJJ+oP2GoY= github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= -github.com/zitadel/zitadel-go v0.3.5 h1:j0rWIs/jC39BkKUSIYzKbFhr1NQ/0KBAvC0LfsiNX4o= -github.com/zitadel/zitadel-go v0.3.5/go.mod h1:EFtsbJQRt7cjIK6zV+wwo7OWVjtxD5HaBfJ+9VxBwtI= -github.com/zitadel/zitadel-go/v2 v2.0.2 h1:mY3MfVeyS0/hI7jez80+rQlVthL4mfOKWSimNoyymKs= -github.com/zitadel/zitadel-go/v2 v2.0.2/go.mod h1:G9Y6rCYGP72J3EoB3AH7lMf5SP9WwGSb5j4RebElLGo= github.com/zitadel/zitadel-go/v2 v2.0.9 h1:XsXvbolwRFSeURF75BUpjcU9eLNiqhgmqaOe0HlAsbQ= github.com/zitadel/zitadel-go/v2 v2.0.9/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -310,14 +251,9 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -345,7 +281,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -355,10 +290,7 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -391,12 +323,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY 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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -405,9 +333,7 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= -golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= +golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -424,7 +350,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -450,39 +375,28 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.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.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -530,10 +444,7 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -583,19 +494,15 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -609,12 +516,6 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ= google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -629,8 +530,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -642,9 +541,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= @@ -659,4 +556,3 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= From 811df7a6c05a7248eeeb38430f2ac06ed3286582 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 15 Feb 2023 09:21:34 +0100 Subject: [PATCH 048/260] fix: add default login policy and login policy fixes --- zitadel/v2/default_login_policy/funcs.go | 3 +++ zitadel/v2/default_login_policy/resource.go | 3 --- zitadel/v2/login_policy/funcs.go | 9 +++++++++ zitadel/v2/login_policy/resource.go | 3 --- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index cade6e32..b449a9ad 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -217,6 +217,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn mfaInitSkipLifetimeVar: resp.Policy.GetMfaInitSkipLifetime().AsDuration().String(), secondFactorCheckLifetimeVar: resp.Policy.GetSecondFactorCheckLifetime().AsDuration().String(), multiFactorCheckLifetimeVar: resp.Policy.GetMultiFactorCheckLifetime().AsDuration().String(), + allowDomainDiscovery: resp.Policy.GetAllowDomainDiscovery(), + disableLoginWithEmail: resp.Policy.GetDisableLoginWithEmail(), + disableLoginWithPhone: resp.Policy.GetDisableLoginWithPhone(), } respSecond, err := client.ListLoginPolicySecondFactors(ctx, &admin.ListLoginPolicySecondFactorsRequest{}) diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 83b3a5cc..57ec010b 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -103,7 +103,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", }, disableLoginWithEmail: { @@ -112,7 +111,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "defines if user can additionally (to the loginname) be identified by their verified email address", }, disableLoginWithPhone: { @@ -121,7 +119,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", }, }, diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 51cf55d3..1510fdb3 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -64,6 +64,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia mfaInitSkipLifetimeVar, secondFactorCheckLifetimeVar, multiFactorCheckLifetimeVar, + allowDomainDiscovery, + disableLoginWithEmail, + disableLoginWithPhone, ) { passwordCheckLT, err := time.ParseDuration(d.Get(passwordCheckLifetimeVar).(string)) if err != nil { @@ -237,6 +240,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia MultiFactorCheckLifetime: durationpb.New(multiFactorCheckLT), SecondFactors: secondFactors, MultiFactors: multiFactors, + AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), + DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), + DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), }) if err != nil { return diag.Errorf("failed to create login policy: %v", err) @@ -302,6 +308,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), secondFactorCheckLifetimeVar: policy.GetSecondFactorCheckLifetime().AsDuration().String(), multiFactorCheckLifetimeVar: policy.GetMultiFactorCheckLifetime().AsDuration().String(), + allowDomainDiscovery: policy.GetAllowDomainDiscovery(), + disableLoginWithEmail: policy.GetDisableLoginWithEmail(), + disableLoginWithPhone: policy.GetDisableLoginWithPhone(), } respSecond, err := client.ListLoginPolicySecondFactors(ctx, &management.ListLoginPolicySecondFactorsRequest{}) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index 7013142d..b2dc84ff 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -109,7 +109,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", }, disableLoginWithEmail: { @@ -118,7 +117,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "defines if user can additionally (to the loginname) be identified by their verified email address", }, disableLoginWithPhone: { @@ -127,7 +125,6 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, }, Optional: true, - Default: false, Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", }, }, From 5dac101b8f5b01f4a47f5d5c55ee71c4ff348152 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Mon, 20 Feb 2023 21:42:59 +0900 Subject: [PATCH 049/260] fix: remove old token parameter --- zitadel/provider.go | 21 ++++----------------- zitadel/v2/helper/client.go | 8 +++++--- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index 9c265cf9..e13fb4e8 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -77,7 +77,6 @@ func NewProviderPV6() provider.Provider { type providerModel struct { Insecure types.Bool `tfsdk:"insecure"` Domain types.String `tfsdk:"domain"` - Token types.String `tfsdk:"token"` Port types.String `tfsdk:"port"` JWTProfileFile types.String `tfsdk:"jwt_profile_file"` JWTProfileJSON types.String `tfsdk:"jwt_profile_json"` @@ -102,17 +101,12 @@ func (p *providerPV6) GetSchema(_ context.Context) (tfsdk.Schema, fdiag.Diagnost helper.JWTProfileFile: { Type: types.StringType, Optional: true, - Description: "Path to the file containing credentials to connect to ZITADEL", + Description: "Path to the file containing credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required", }, helper.JWTProfileJSON: { Type: types.StringType, Optional: true, - Description: "JSON value of credentials to connect to ZITADEL", - }, - helper.TokenVar: { - Type: types.StringType, - Optional: true, - Description: "Path to the file containing credentials to connect to ZITADEL (deprecated)", + Description: "JSON value of credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required", }, helper.PortVar: { Type: types.StringType, @@ -136,7 +130,6 @@ func (p *providerPV6) Configure(ctx context.Context, req provider.ConfigureReque config.Domain.ValueString(), config.JWTProfileFile.ValueString(), config.JWTProfileJSON.ValueString(), - config.Token.ValueString(), config.Port.ValueString(), ) if err != nil { @@ -196,20 +189,15 @@ func Provider() *schema.Provider { Optional: true, Description: "Use insecure connection", }, - helper.TokenVar: { - Type: schema.TypeString, - Optional: true, - Description: "Path to the file containing credentials to connect to ZITADEL (deprecated)", - }, helper.JWTProfileFile: { Type: schema.TypeString, Optional: true, - Description: "Path to the file containing credentials to connect to ZITADEL", + Description: "Path to the file containing credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required", }, helper.JWTProfileJSON: { Type: schema.TypeString, Optional: true, - Description: "JSON value of credentials to connect to ZITADEL", + Description: "JSON value of credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required", }, helper.PortVar: { Type: schema.TypeString, @@ -264,7 +252,6 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} d.Get(helper.DomainVar).(string), d.Get(helper.JWTProfileFile).(string), d.Get(helper.JWTProfileJSON).(string), - d.Get(helper.TokenVar).(string), d.Get(helper.PortVar).(string), ) if err != nil { diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 3b65e853..85caebce 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -25,17 +25,18 @@ type ClientInfo struct { Domain string Issuer string KeyPath string + Data []byte Options []zitadel.Option } -func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfileJSON string, token string, port string) (*ClientInfo, error) { +func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfileJSON string, port string) (*ClientInfo, error) { options := []zitadel.Option{} if jwtProfileFile != "" { options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(jwtProfileFile))) } else if jwtProfileJSON != "" { options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromFileData([]byte(jwtProfileJSON)))) } else { - options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(token))) + return nil, fmt.Errorf("either 'jwt_profile_file' or 'jwt_profile_json' is required") } issuer := "" @@ -61,7 +62,8 @@ func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfi return &ClientInfo{ domain, issuer, - token, + jwtProfileFile, + []byte(jwtProfileJSON), options, }, nil } From 5db62e9a2a5249654f34f3aa9848eb68c25d2e38 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Mon, 20 Feb 2023 21:45:56 +0900 Subject: [PATCH 050/260] fix: apply changes to formFilePost --- zitadel/v2/helper/form.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/zitadel/v2/helper/form.go b/zitadel/v2/helper/form.go index d90cb536..c7d8c85a 100644 --- a/zitadel/v2/helper/form.go +++ b/zitadel/v2/helper/form.go @@ -68,6 +68,7 @@ func OrgFormFilePost(clientInfo *ClientInfo, endpoint, path, orgID string) diag. } func formFilePost(clientInfo *ClientInfo, endpoint, path string, additionalHeaders map[string]string) diag.Diagnostics { + var client *http.Client r, err := createMultipartRequest(clientInfo.Issuer, endpoint, path) if err != nil { return diag.Errorf("failed to create asset request: %v", err) @@ -76,9 +77,18 @@ func formFilePost(clientInfo *ClientInfo, endpoint, path string, additionalHeade r.Header.Add(k, v) } - client, err := NewClientWithInterceptor(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) - if err != nil { - return diag.Errorf("failed to create client: %v", err) + if clientInfo.KeyPath != "" { + client, err = NewClientWithInterceptorFromKeyFile(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) + if err != nil { + return diag.Errorf("failed to create client: %v", err) + } + } else if len(clientInfo.Data) > 0 { + client, err = NewClientWithInterceptorFromKeyFile(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) + if err != nil { + return diag.Errorf("failed to create client: %v", err) + } + } else { + return diag.Errorf("either 'jwt_profile_file' or 'jwt_profile_json' is required") } resp, err := client.Do(r) @@ -93,7 +103,7 @@ type Interceptor struct { core http.RoundTripper } -func NewClientWithInterceptor(issuer, keyPath string, scopes []string) (*http.Client, error) { +func NewClientWithInterceptorFromKeyFile(issuer, keyPath string, scopes []string) (*http.Client, error) { ts, err := profile.NewJWTProfileTokenSourceFromKeyFile(issuer, keyPath, scopes) if err != nil { return nil, err @@ -104,6 +114,17 @@ func NewClientWithInterceptor(issuer, keyPath string, scopes []string) (*http.Cl }, nil } +func NewClientWithInterceptorFromKeyFileData(issuer string, data []byte, scopes []string) (*http.Client, error) { + ts, err := profile.NewJWTProfileTokenSourceFromKeyFileData(issuer, data, scopes) + if err != nil { + return nil, err + } + + return &http.Client{ + Transport: Interceptor{core: http.DefaultTransport, tokenSource: ts}, + }, nil +} + func (i Interceptor) RoundTrip(r *http.Request) (*http.Response, error) { defer func() { _ = r.Body.Close() From c37180c8172478aa49616889d6b5fcc0e525cc58 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 21 Feb 2023 11:46:35 +0100 Subject: [PATCH 051/260] fix: add default login policy and login policy fixes --- docs/resources/default_login_policy.md | 6 +++--- docs/resources/login_policy.md | 6 +++--- zitadel/v2/default_login_policy/resource.go | 15 +++------------ zitadel/v2/login_policy/resource.go | 15 +++------------ 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 0cbe6a29..ec7aaac5 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -55,9 +55,9 @@ resource zitadel_default_login_policy login_policy { ### Optional -- `allow_domain_discovery` (Set of Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. -- `disable_login_with_email` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified email address -- `disable_login_with_phone` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number +- `allow_domain_discovery` (Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. +- `disable_login_with_email` (Boolean) defines if user can additionally (to the loginname) be identified by their verified email address +- `disable_login_with_phone` (Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number - `idps` (Set of String) allowed idps to login or register - `multi_factors` (Set of String) allowed multi factors - `second_factors` (Set of String) allowed second factors diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 552e3ee7..639ddc57 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -60,9 +60,9 @@ resource zitadel_login_policy login_policy { ### Optional -- `allow_domain_discovery` (Set of Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. -- `disable_login_with_email` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified email address -- `disable_login_with_phone` (Set of Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number +- `allow_domain_discovery` (Boolean) if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success. +- `disable_login_with_email` (Boolean) defines if user can additionally (to the loginname) be identified by their verified email address +- `disable_login_with_phone` (Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number - `idps` (Set of String) allowed idps to login or register - `multi_factors` (Set of String) allowed multi factors - `second_factors` (Set of String) allowed second factors diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 57ec010b..4a649f06 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -98,26 +98,17 @@ func GetResource() *schema.Resource { Description: "allowed idps to login or register", }, allowDomainDiscovery: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", }, disableLoginWithEmail: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "defines if user can additionally (to the loginname) be identified by their verified email address", }, disableLoginWithPhone: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", }, diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index b2dc84ff..b26337d8 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -104,26 +104,17 @@ func GetResource() *schema.Resource { Description: "allowed idps to login or register", }, allowDomainDiscovery: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "if set to true, the suffix (@domain.com) of an unknown username input on the login screen will be matched against the org domains and will redirect to the registration of that organisation on success.", }, disableLoginWithEmail: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "defines if user can additionally (to the loginname) be identified by their verified email address", }, disableLoginWithPhone: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeBool, - }, + Type: schema.TypeBool, Optional: true, Description: "defines if user can additionally (to the loginname) be identified by their verified phone number", }, From ee047a86d8de88553b0ab81221220719326fc5d6 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Mon, 27 Feb 2023 16:43:10 +0900 Subject: [PATCH 052/260] fix: wrong function call --- zitadel/v2/helper/form.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/form.go b/zitadel/v2/helper/form.go index c7d8c85a..d5ee76ae 100644 --- a/zitadel/v2/helper/form.go +++ b/zitadel/v2/helper/form.go @@ -83,7 +83,7 @@ func formFilePost(clientInfo *ClientInfo, endpoint, path string, additionalHeade return diag.Errorf("failed to create client: %v", err) } } else if len(clientInfo.Data) > 0 { - client, err = NewClientWithInterceptorFromKeyFile(clientInfo.Issuer, clientInfo.KeyPath, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) + client, err = NewClientWithInterceptorFromKeyFileData(clientInfo.Issuer, clientInfo.Data, []string{oidc.ScopeOpenID, zitadel.ScopeZitadelAPI()}) if err != nil { return diag.Errorf("failed to create client: %v", err) } From 4f1b23a51f435fb6b901571326f6a5caff2dd6b6 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Mon, 27 Feb 2023 16:43:51 +0900 Subject: [PATCH 053/260] fix: revert previous auth parameter --- zitadel/provider.go | 13 +++++++++++++ zitadel/v2/helper/client.go | 11 ++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index e13fb4e8..f1bf2911 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -78,6 +78,7 @@ type providerModel struct { Insecure types.Bool `tfsdk:"insecure"` Domain types.String `tfsdk:"domain"` Port types.String `tfsdk:"port"` + Token types.String `tfsdk:"token"` JWTProfileFile types.String `tfsdk:"jwt_profile_file"` JWTProfileJSON types.String `tfsdk:"jwt_profile_json"` } @@ -98,6 +99,11 @@ func (p *providerPV6) GetSchema(_ context.Context) (tfsdk.Schema, fdiag.Diagnost Optional: true, Description: "Use insecure connection", }, + helper.TokenVar: { + Type: types.StringType, + Optional: true, + Description: "Path to the file containing credentials to connect to ZITADEL", + }, helper.JWTProfileFile: { Type: types.StringType, Optional: true, @@ -128,6 +134,7 @@ func (p *providerPV6) Configure(ctx context.Context, req provider.ConfigureReque info, err := helper.GetClientInfo( config.Insecure.ValueBool(), config.Domain.ValueString(), + config.Token.ValueString(), config.JWTProfileFile.ValueString(), config.JWTProfileJSON.ValueString(), config.Port.ValueString(), @@ -189,6 +196,11 @@ func Provider() *schema.Provider { Optional: true, Description: "Use insecure connection", }, + helper.TokenVar: { + Type: schema.TypeString, + Optional: true, + Description: "Path to the file containing credentials to connect to ZITADEL", + }, helper.JWTProfileFile: { Type: schema.TypeString, Optional: true, @@ -250,6 +262,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} clientinfo, err := helper.GetClientInfo( d.Get(helper.InsecureVar).(bool), d.Get(helper.DomainVar).(string), + d.Get(helper.TokenVar).(string), d.Get(helper.JWTProfileFile).(string), d.Get(helper.JWTProfileJSON).(string), d.Get(helper.PortVar).(string), diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 85caebce..e49f6b1d 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -29,10 +29,15 @@ type ClientInfo struct { Options []zitadel.Option } -func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfileJSON string, port string) (*ClientInfo, error) { +func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile string, jwtProfileJSON string, port string) (*ClientInfo, error) { options := []zitadel.Option{} - if jwtProfileFile != "" { + keyPath := "" + if token != "" { + options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(token))) + keyPath = token + } else if jwtProfileFile != "" { options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(jwtProfileFile))) + keyPath = token } else if jwtProfileJSON != "" { options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromFileData([]byte(jwtProfileJSON)))) } else { @@ -62,7 +67,7 @@ func GetClientInfo(insecure bool, domain string, jwtProfileFile string, jwtProfi return &ClientInfo{ domain, issuer, - jwtProfileFile, + keyPath, []byte(jwtProfileJSON), options, }, nil From 5c0052f172ba97b4f358f95da28e6b8d58630337 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 1 Mar 2023 19:59:42 +0100 Subject: [PATCH 054/260] fix: add domain set primary bool --- docs/resources/domain.md | 10 +++++++--- examples/provider/resources/domain.tf | 6 +++--- zitadel/v2/domain/funcs.go | 4 ++++ zitadel/v2/domain/resource.go | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 30cb98b1..86892b32 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -15,8 +15,9 @@ Resource representing a domain of the organization. resource zitadel_domain domain { depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id - name = "localhost.com" + org_id = zitadel_org.org.id + name = "localhost.com" + isPrimary = true } ``` @@ -28,9 +29,12 @@ resource zitadel_domain domain { - `name` (String) Name of the domain - `org_id` (String) ID of the organization +### Optional + +- `is_primary` (Boolean) Is domain primary + ### Read-Only - `id` (String) The ID of this resource. -- `is_primary` (Boolean) Is domain primary - `is_verified` (Boolean) Is domain verified - `validation_type` (Number) Validation type \ No newline at end of file diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 6ffca369..4fbebb76 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,7 +1,7 @@ - resource zitadel_domain domain { depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id - name = "localhost.com" + org_id = zitadel_org.org.id + name = "localhost.com" + isPrimary = true } \ No newline at end of file diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index f0e45c0d..d3b56cac 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -56,6 +56,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to create domain: %v", err) } d.SetId(name) + _, err = client.SetPrimaryOrgDomain(ctx, &management.SetPrimaryOrgDomainRequest{Domain: name}) + if err != nil { + return diag.Errorf("failed to set domain primary: %v", err) + } return nil } diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index 73fd2680..8dd0f0d8 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -27,7 +27,7 @@ func GetResource() *schema.Resource { }, isPrimaryVar: { Type: schema.TypeBool, - Computed: true, + Optional: true, Description: "Is domain primary", }, validationTypeVar: { From e76480bd583607f378cf7629645ea98e1f3821b3 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 1 Mar 2023 20:01:35 +0100 Subject: [PATCH 055/260] fix: add domain set primary bool correct example --- examples/provider/resources/domain.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 4fbebb76..13aa9bfb 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -3,5 +3,5 @@ resource zitadel_domain domain { org_id = zitadel_org.org.id name = "localhost.com" - isPrimary = true + is_primary = true } \ No newline at end of file From 37f0665ca599bfef595c6f46e471835a6c14f968 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 2 Mar 2023 17:07:00 +0100 Subject: [PATCH 056/260] feat: add default notification and notification policy --- .../resources/default_notification_policy.tf | 3 + .../provider/resources/notification_policy.tf | 6 + go.mod | 2 +- go.sum | 2 + .../default_notification_policy.md.tmpl | 16 +++ .../resources/notification_policy.md.tmpl | 16 +++ zitadel/provider.go | 4 + .../v2/default_notification_policy/const.go | 5 + .../v2/default_notification_policy/funcs.go | 83 ++++++++++++ .../default_notification_policy/resource.go | 23 ++++ zitadel/v2/domain_policy/funcs.go | 1 + zitadel/v2/notification_policy/const.go | 6 + zitadel/v2/notification_policy/funcs.go | 122 ++++++++++++++++++ zitadel/v2/notification_policy/resource.go | 29 +++++ 14 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 examples/provider/resources/default_notification_policy.tf create mode 100644 examples/provider/resources/notification_policy.tf create mode 100644 templates/resources/default_notification_policy.md.tmpl create mode 100644 templates/resources/notification_policy.md.tmpl create mode 100644 zitadel/v2/default_notification_policy/const.go create mode 100644 zitadel/v2/default_notification_policy/funcs.go create mode 100644 zitadel/v2/default_notification_policy/resource.go create mode 100644 zitadel/v2/notification_policy/const.go create mode 100644 zitadel/v2/notification_policy/funcs.go create mode 100644 zitadel/v2/notification_policy/resource.go diff --git a/examples/provider/resources/default_notification_policy.tf b/examples/provider/resources/default_notification_policy.tf new file mode 100644 index 00000000..8d86b5ea --- /dev/null +++ b/examples/provider/resources/default_notification_policy.tf @@ -0,0 +1,3 @@ +resource zitadel_default_notification_policy notification_policy { + password_change = false +} \ No newline at end of file diff --git a/examples/provider/resources/notification_policy.tf b/examples/provider/resources/notification_policy.tf new file mode 100644 index 00000000..0c9c1d83 --- /dev/null +++ b/examples/provider/resources/notification_policy.tf @@ -0,0 +1,6 @@ +resource zitadel_notification_policy notification_policy { + depends_on = [zitadel_org.org] + + org_id = zitadel_org.org.id + password_change = false +} \ No newline at end of file diff --git a/go.mod b/go.mod index 00074dd3..7ac82661 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/zitadel/oidc v1.12.1 - github.com/zitadel/zitadel-go/v2 v2.0.9 + github.com/zitadel/zitadel-go/v2 v2.0.10 golang.org/x/oauth2 v0.4.0 google.golang.org/grpc v1.52.3 google.golang.org/protobuf v1.28.1 diff --git a/go.sum b/go.sum index 21786127..430be923 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= github.com/zitadel/zitadel-go/v2 v2.0.9 h1:XsXvbolwRFSeURF75BUpjcU9eLNiqhgmqaOe0HlAsbQ= github.com/zitadel/zitadel-go/v2 v2.0.9/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= +github.com/zitadel/zitadel-go/v2 v2.0.10 h1:gVV8DK0w4w+GQuazXdHpiwyMjeHPeSG5Uh4/rsY9gZ4= +github.com/zitadel/zitadel-go/v2 v2.0.10/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/templates/resources/default_notification_policy.md.tmpl b/templates/resources/default_notification_policy.md.tmpl new file mode 100644 index 00000000..b05a01d0 --- /dev/null +++ b/templates/resources/default_notification_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_notification_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/notification_policy.md.tmpl b/templates/resources/notification_policy.md.tmpl new file mode 100644 index 00000000..a0f6b6c2 --- /dev/null +++ b/templates/resources/notification_policy.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/notification_policy.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/provider.go b/zitadel/provider.go index 8858a1b8..8230358f 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -22,6 +22,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_notification_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" @@ -41,6 +42,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_texts" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/notification_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" @@ -229,6 +231,8 @@ func Provider() *schema.Provider { "zitadel_default_password_complexity_policy": default_password_complexity_policy.GetResource(), "zitadel_sms_provider_twilio": sms_provider_twilio.GetResource(), "zitadel_smtp_config": smtp_config.GetResource(), + "zitadel_default_notification_policy": default_notification_policy.GetResource(), + "zitadel_notification_policy": notification_policy.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/default_notification_policy/const.go b/zitadel/v2/default_notification_policy/const.go new file mode 100644 index 00000000..a2447ba7 --- /dev/null +++ b/zitadel/v2/default_notification_policy/const.go @@ -0,0 +1,5 @@ +package default_notification_policy + +const ( + passwordChangeVar = "password_change" +) diff --git a/zitadel/v2/default_notification_policy/funcs.go b/zitadel/v2/default_notification_policy/funcs.go new file mode 100644 index 00000000..18e6de34 --- /dev/null +++ b/zitadel/v2/default_notification_policy/funcs.go @@ -0,0 +1,83 @@ +package default_notification_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "default notification policy cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.UpdateNotificationPolicy(ctx, &admin.UpdateNotificationPolicyRequest{ + PasswordChange: d.Get(passwordChangeVar).(bool), + }) + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default notification policy: %v", err) + } + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + } else { + resp, err := client.GetNotificationPolicy(ctx, &admin.GetNotificationPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default notification policy: %v", err) + } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetNotificationPolicy(ctx, &admin.GetNotificationPolicyRequest{}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get default notification policy") + } + policy := resp.Policy + set := map[string]interface{}{ + passwordChangeVar: policy.GetPasswordChange(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default notification policy: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_notification_policy/resource.go b/zitadel/v2/default_notification_policy/resource.go new file mode 100644 index 00000000..a9c7dd5b --- /dev/null +++ b/zitadel/v2/default_notification_policy/resource.go @@ -0,0 +1,23 @@ +package default_notification_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default notification policy.", + Schema: map[string]*schema.Schema{ + passwordChangeVar: { + Type: schema.TypeBool, + Required: true, + Description: "Send notification if a user changes his password", + }, + }, + ReadContext: read, + CreateContext: update, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 0ffe638c..1fdc14cc 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -121,6 +121,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn orgIDVar: policy.GetDetails().GetResourceOwner(), userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), validateOrgDomainVar: policy.GetValidateOrgDomains(), + smtpSenderVar: policy.GetSmtpSenderAddressMatchesInstanceDomain(), } for k, v := range set { diff --git a/zitadel/v2/notification_policy/const.go b/zitadel/v2/notification_policy/const.go new file mode 100644 index 00000000..2c300346 --- /dev/null +++ b/zitadel/v2/notification_policy/const.go @@ -0,0 +1,6 @@ +package notification_policy + +const ( + orgIDVar = "org_id" + passwordChangeVar = "password_change" +) diff --git a/zitadel/v2/notification_policy/funcs.go b/zitadel/v2/notification_policy/funcs.go new file mode 100644 index 00000000..e6b17161 --- /dev/null +++ b/zitadel/v2/notification_policy/funcs.go @@ -0,0 +1,122 @@ +package notification_policy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.ResetNotificationPolicyToDefault(ctx, &management.ResetNotificationPolicyToDefaultRequest{}) + if err != nil { + return diag.Errorf("failed to reset notification policy: %v", err) + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started update") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + org := d.Get(orgIDVar).(string) + + _, err = client.UpdateCustomNotificationPolicy(ctx, &management.UpdateCustomNotificationPolicyRequest{ + PasswordChange: d.Get(passwordChangeVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update notification policy: %v", err) + } + d.SetId(org) + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + org := d.Get(orgIDVar).(string) + + _, err = client.AddCustomNotificationPolicy(ctx, &management.AddCustomNotificationPolicyRequest{ + PasswordChange: d.Get(passwordChangeVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to create notification policy: %v", err) + } + d.SetId(org) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started read") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + org := d.Get(orgIDVar).(string) + client, err := helper.GetManagementClient(clientinfo, org) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetNotificationPolicy(ctx, &management.GetNotificationPolicyRequest{}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get notification policy") + } + + policy := resp.Policy + if policy.GetIsDefault() == true { + d.SetId("") + return nil + } + set := map[string]interface{}{ + orgIDVar: policy.GetDetails().GetResourceOwner(), + passwordChangeVar: policy.GetPasswordChange(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of notification: %v", k, err) + } + } + d.SetId(policy.GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/notification_policy/resource.go b/zitadel/v2/notification_policy/resource.go new file mode 100644 index 00000000..c347f89a --- /dev/null +++ b/zitadel/v2/notification_policy/resource.go @@ -0,0 +1,29 @@ +package notification_policy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the custom notification policy of an organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "Id for the organization", + ForceNew: true, + }, + passwordChangeVar: { + Type: schema.TypeBool, + Required: true, + Description: "Send notification if a user changes his password", + }, + }, + ReadContext: read, + CreateContext: create, + DeleteContext: delete, + UpdateContext: update, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From fb6c84e5768f17b3dbe5ebb61fcac696dfd89924 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 2 Mar 2023 17:56:14 +0100 Subject: [PATCH 057/260] fix: add review changes --- docs/resources/domain.md | 4 ++-- examples/provider/resources/domain.tf | 2 +- zitadel/v2/domain/funcs.go | 32 +++++++++++++++++++++++++-- zitadel/v2/domain/resource.go | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 86892b32..9e4360bb 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -16,8 +16,8 @@ resource zitadel_domain domain { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - name = "localhost.com" - isPrimary = true + name = "zitadel.default.127.0.0.1.sslip.io" + is_primary = true } ``` diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 13aa9bfb..be89d69e 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -2,6 +2,6 @@ resource zitadel_domain domain { depends_on = [zitadel_org.org] org_id = zitadel_org.org.id - name = "localhost.com" + name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } \ No newline at end of file diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index d3b56cac..e41e7f63 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -56,9 +56,37 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to create domain: %v", err) } d.SetId(name) - _, err = client.SetPrimaryOrgDomain(ctx, &management.SetPrimaryOrgDomainRequest{Domain: name}) + if d.Get(isPrimaryVar).(bool) { + _, err = client.SetPrimaryOrgDomain(ctx, &management.SetPrimaryOrgDomainRequest{Domain: name}) + if err != nil { + return diag.Errorf("failed to set domain primary: %v", err) + } + } + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started create") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { - return diag.Errorf("failed to set domain primary: %v", err) + return diag.FromErr(err) + } + + name := d.Get(nameVar).(string) + d.SetId(name) + if d.HasChange(isPrimaryVar) { + if d.Get(isPrimaryVar).(bool) { + _, err = client.SetPrimaryOrgDomain(ctx, &management.SetPrimaryOrgDomainRequest{Domain: name}) + if err != nil { + return diag.Errorf("failed to set domain primary: %v", err) + } + } } return nil } diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index 8dd0f0d8..2b0f8800 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -38,6 +38,7 @@ func GetResource() *schema.Resource { }, ReadContext: read, CreateContext: create, + UpdateContext: update, DeleteContext: delete, Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } From 3afaea5fb941d9e8ec4f4879df353f4702d9280c Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 7 Mar 2023 17:41:58 +0100 Subject: [PATCH 058/260] fix: add review changes --- docs/data-sources/action.md | 6 ++-- docs/data-sources/application_api.md | 2 -- docs/data-sources/application_oidc.md | 4 +-- docs/data-sources/human_user.md | 2 -- docs/data-sources/machine_user.md | 2 -- docs/data-sources/org_jwt_idp.md | 2 -- docs/data-sources/org_oidc_idp.md | 4 +-- docs/data-sources/project.md | 6 ++-- docs/data-sources/project_role.md | 8 ++--- docs/data-sources/trigger_actions.md | 2 -- docs/resources/action.md | 2 -- docs/resources/application_api.md | 2 -- docs/resources/application_key.md | 2 -- docs/resources/application_oidc.md | 4 +-- .../default_domain_claimed_message_text.md | 10 +++--- docs/resources/default_init_message_text.md | 10 +++--- docs/resources/default_notification_policy.md | 29 +++++++++++++++++ .../default_password_reset_message_text.md | 10 +++--- ..._passwordless_registration_message_text.md | 10 +++--- .../default_verify_email_message_text.md | 10 +++--- .../default_verify_phone_message_text.md | 10 +++--- docs/resources/domain.md | 2 -- docs/resources/domain_claimed_message_text.md | 14 ++++----- docs/resources/domain_policy.md | 2 -- docs/resources/human_user.md | 2 -- docs/resources/init_message_text.md | 14 ++++----- docs/resources/instance_member.md | 2 -- docs/resources/label_policy.md | 2 -- docs/resources/lockout_policy.md | 2 -- docs/resources/login_policy.md | 2 -- docs/resources/login_texts.md | 4 +-- docs/resources/machine_key.md | 2 -- docs/resources/machine_user.md | 2 -- docs/resources/notification_policy.md | 31 +++++++++++++++++++ docs/resources/org.md | 2 +- docs/resources/org_idp_jwt.md | 2 -- docs/resources/org_idp_oidc.md | 2 -- docs/resources/org_member.md | 2 -- docs/resources/password_complexity_policy.md | 2 -- docs/resources/password_reset_message_text.md | 14 ++++----- .../passwordless_registration_message_text.md | 14 ++++----- docs/resources/personal_access_token.md | 2 -- docs/resources/privacy_policy.md | 2 -- docs/resources/project.md | 2 -- docs/resources/project_grant.md | 2 -- docs/resources/project_grant_member.md | 2 -- docs/resources/project_member.md | 2 -- docs/resources/project_role.md | 2 -- docs/resources/trigger_actions.md | 2 -- docs/resources/user_grant.md | 2 -- docs/resources/verify_email_message_text.md | 14 ++++----- docs/resources/verify_phone_message_text.md | 14 ++++----- examples/provider/data-sources/action.tf | 6 ++-- .../provider/data-sources/application_api.tf | 2 -- .../provider/data-sources/application_oidc.tf | 4 +-- examples/provider/data-sources/human_user.tf | 2 -- .../provider/data-sources/machine_user.tf | 2 -- examples/provider/data-sources/org_jwt_idp.tf | 2 -- .../provider/data-sources/org_oidc_idp.tf | 4 +-- examples/provider/data-sources/project.tf | 6 ++-- .../provider/data-sources/project_role.tf | 8 ++--- .../provider/data-sources/trigger_actions.tf | 2 -- examples/provider/resources/action.tf | 3 -- examples/provider/resources/app_key.tf | 2 -- .../provider/resources/application_api.tf | 2 -- .../provider/resources/application_oidc.tf | 4 +-- .../default_domain_claimed_message_text.tf | 10 +++--- .../resources/default_domain_policy.tf | 1 - .../resources/default_init_message_text.tf | 10 +++--- .../resources/default_lockout_policy.tf | 1 - .../default_password_complexity_policy.tf | 1 - .../default_password_reset_message_text.tf | 10 +++--- ..._passwordless_registration_message_text.tf | 10 +++--- .../resources/default_privacy_policy.tf | 1 - .../default_verify_email_message_text.tf | 10 +++--- .../default_verify_phone_message_text.tf | 10 +++--- examples/provider/resources/domain.tf | 3 -- .../resources/domain_claimed_message_text.tf | 14 ++++----- examples/provider/resources/domain_policy.tf | 3 -- .../provider/resources/granted_human_user.tf | 3 -- examples/provider/resources/granted_org.tf | 3 +- examples/provider/resources/human_user.tf | 2 -- .../provider/resources/init_message_text.tf | 14 ++++----- .../provider/resources/instance_member.tf | 2 -- examples/provider/resources/label_policy.tf | 2 -- examples/provider/resources/lockout_policy.tf | 3 -- examples/provider/resources/login_policy.tf | 2 -- examples/provider/resources/login_texts.tf | 4 +-- examples/provider/resources/machine_key.tf | 2 -- examples/provider/resources/machine_user.tf | 3 -- .../provider/resources/notification_policy.tf | 2 -- examples/provider/resources/org.tf | 2 +- examples/provider/resources/org_idp_jwt.tf | 2 -- examples/provider/resources/org_idp_oidc.tf | 2 -- examples/provider/resources/org_member.tf | 2 -- .../resources/password_complexity_policy.tf | 3 -- .../resources/password_reset_message_text.tf | 14 ++++----- .../passwordless_registration_message_text.tf | 14 ++++----- .../resources/personal_access_token.tf | 2 -- examples/provider/resources/privacy_policy.tf | 3 -- examples/provider/resources/project.tf | 3 -- examples/provider/resources/project_grant.tf | 2 -- .../resources/project_grant_member.tf | 3 -- examples/provider/resources/project_member.tf | 3 -- examples/provider/resources/project_role.tf | 3 -- .../provider/resources/trigger_actions.tf | 2 -- examples/provider/resources/user_grant.tf | 2 -- .../resources/verify_email_message_text.tf | 14 ++++----- .../resources/verify_phone_message_text.tf | 14 ++++----- zitadel/v2/default_domain_policy/funcs.go | 27 +++++++++------- zitadel/v2/default_label_policy/funcs.go | 17 +++++----- zitadel/v2/default_lockout_policy/funcs.go | 23 ++++++++------ zitadel/v2/default_login_policy/funcs.go | 18 ++++++----- .../v2/default_notification_policy/funcs.go | 27 +++++++++------- .../funcs.go | 31 +++++++++++-------- zitadel/v2/default_privacy_policy/funcs.go | 27 +++++++++------- zitadel/v2/notification_policy/funcs.go | 12 ++++--- 117 files changed, 324 insertions(+), 425 deletions(-) create mode 100644 docs/resources/default_notification_policy.md create mode 100644 docs/resources/notification_policy.md diff --git a/docs/data-sources/action.md b/docs/data-sources/action.md index d198d94f..de656e4b 100644 --- a/docs/data-sources/action.md +++ b/docs/data-sources/action.md @@ -13,10 +13,8 @@ Datasource representing an action belonging to an organization. ```terraform data zitadel_action action { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id - action_id = "177073621691269123" + org_id = data.zitadel_org.org.id + action_id = "177073621691269123" } output action { diff --git a/docs/data-sources/application_api.md b/docs/data-sources/application_api.md index 1094a12b..492948be 100644 --- a/docs/data-sources/application_api.md +++ b/docs/data-sources/application_api.md @@ -13,8 +13,6 @@ Datasource representing an API application belonging to a project, with all conf ```terraform data zitadel_application_api api_application { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073625566806019" diff --git a/docs/data-sources/application_oidc.md b/docs/data-sources/application_oidc.md index 1d014e95..cd0ccc1f 100644 --- a/docs/data-sources/application_oidc.md +++ b/docs/data-sources/application_oidc.md @@ -13,11 +13,9 @@ Datasource representing an OIDC application belonging to a project, with all con ```terraform data zitadel_application_oidc oidc_application { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id - app_id = "177073626925760515" + app_id = "177073626925760515" } output oidc_application { diff --git a/docs/data-sources/human_user.md b/docs/data-sources/human_user.md index 314b3ff0..1a10a0cc 100644 --- a/docs/data-sources/human_user.md +++ b/docs/data-sources/human_user.md @@ -13,8 +13,6 @@ Datasource representing a human user situated under an organization, which then ```terraform data zitadel_human_user human_user { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id user_id = "177073614158299139" } diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md index 475edcc8..96813d99 100644 --- a/docs/data-sources/machine_user.md +++ b/docs/data-sources/machine_user.md @@ -13,8 +13,6 @@ Datasource representing a serviceaccount situated under an organization, which t ```terraform data zitadel_machine_user machine_user { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id user_id = "177073617463410691" } diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md index b26b57a8..77798cda 100644 --- a/docs/data-sources/org_jwt_idp.md +++ b/docs/data-sources/org_jwt_idp.md @@ -13,8 +13,6 @@ Datasource representing a domain of the organization. ```terraform data zitadel_org_jwt_idp org_jwt_idp { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md index 96a1b75d..f5a41dc1 100644 --- a/docs/data-sources/org_oidc_idp.md +++ b/docs/data-sources/org_oidc_idp.md @@ -13,9 +13,7 @@ Datasource representing a OIDC IDP of the organization. ```terraform data zitadel_org_oidc_idp org_oidc_idp { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id + org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 3816c2bb..741f04b4 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -13,10 +13,8 @@ Datasource representing the project, which can then be granted to different orga ```terraform data zitadel_project project { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id - project_id = "177073620768522243" + org_id = data.zitadel_org.org.id + project_id = "177073620768522243" } output project { diff --git a/docs/data-sources/project_role.md b/docs/data-sources/project_role.md index d85cc35e..ccdd19e8 100644 --- a/docs/data-sources/project_role.md +++ b/docs/data-sources/project_role.md @@ -13,11 +13,9 @@ Datasource representing the project roles, which can be given as authorizations ```terraform data zitadel_project_role project_role { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - role_key = "key" + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + role_key = "key" } output project_role { diff --git a/docs/data-sources/trigger_actions.md b/docs/data-sources/trigger_actions.md index 08ada025..7c56c276 100644 --- a/docs/data-sources/trigger_actions.md +++ b/docs/data-sources/trigger_actions.md @@ -13,8 +13,6 @@ Resource representing triggers, when actions get started ```terraform data zitadel_trigger_actions trigger_actions { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/docs/resources/action.md b/docs/resources/action.md index d5ca878d..3252e976 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -13,8 +13,6 @@ Resource representing an action belonging to an organization. ```terraform resource zitadel_action action { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "actionname" script = "testscript" diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index d5b423ee..b94cbfcf 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -13,8 +13,6 @@ Resource representing an API application belonging to a project, with all config ```terraform resource zitadel_application_api application_api { - depends_on = [zitadel_org.org, zitadel_project.project] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 9f1c8e39..8c00e8af 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -13,8 +13,6 @@ Resource representing a app key ```terraform resource zitadel_application_key app_key { - depends_on = [zitadel_application_api.application_api, zitadel_project.project, zitadel_org.org] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id app_id = zitadel_application_api.application_api.id diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 449fcc08..3569be6b 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -12,9 +12,7 @@ Resource representing an OIDC application belonging to a project, with all confi ## Example Usage ```terraform -resource zitadel_application_oidc application_oidc{ - depends_on = [zitadel_org.org, zitadel_project.project] - +resource zitadel_application_oidc application_oidc { project_id = zitadel_project.project.id org_id = zitadel_org.org.id diff --git a/docs/resources/default_domain_claimed_message_text.md b/docs/resources/default_domain_claimed_message_text.md index 0a78f4c4..863b2996 100644 --- a/docs/resources/default_domain_claimed_message_text.md +++ b/docs/resources/default_domain_claimed_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_domain_claimed_message_text domain_claimed_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/default_init_message_text.md b/docs/resources/default_init_message_text.md index 0ee31efb..54be0f80 100644 --- a/docs/resources/default_init_message_text.md +++ b/docs/resources/default_init_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_init_message_text init_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/default_notification_policy.md b/docs/resources/default_notification_policy.md new file mode 100644 index 00000000..a3ff90f0 --- /dev/null +++ b/docs/resources/default_notification_policy.md @@ -0,0 +1,29 @@ +--- +page_title: "zitadel_default_notification_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default notification policy. +--- + +# zitadel_default_notification_policy (Resource) + +Resource representing the default notification policy. + +## Example Usage + +```terraform +resource zitadel_default_notification_policy notification_policy { + password_change = false +} +``` + + +## Schema + +### Required + +- `password_change` (Boolean) Send notification if a user changes his password + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/default_password_reset_message_text.md b/docs/resources/default_password_reset_message_text.md index 05b88c16..82ef6aad 100644 --- a/docs/resources/default_password_reset_message_text.md +++ b/docs/resources/default_password_reset_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_password_reset_message_text password_reset_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/default_passwordless_registration_message_text.md b/docs/resources/default_passwordless_registration_message_text.md index 6c0a0571..5f6a119b 100644 --- a/docs/resources/default_passwordless_registration_message_text.md +++ b/docs/resources/default_passwordless_registration_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/default_verify_email_message_text.md b/docs/resources/default_verify_email_message_text.md index f20991a7..58a05475 100644 --- a/docs/resources/default_verify_email_message_text.md +++ b/docs/resources/default_verify_email_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_verify_email_message_text verify_email_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/default_verify_phone_message_text.md b/docs/resources/default_verify_phone_message_text.md index ed093981..1e19d653 100644 --- a/docs/resources/default_verify_phone_message_text.md +++ b/docs/resources/default_verify_phone_message_text.md @@ -15,11 +15,11 @@ description: |- resource zitadel_default_verify_phone_message_text verify_phone_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 30cb98b1..c58810e6 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -13,8 +13,6 @@ Resource representing a domain of the organization. ```terraform resource zitadel_domain domain { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "localhost.com" } diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md index b0b6b1eb..0f5dbe02 100644 --- a/docs/resources/domain_claimed_message_text.md +++ b/docs/resources/domain_claimed_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_domain_claimed_message_text domain_claimed_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 8db6323f..2a4ae722 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -13,8 +13,6 @@ Resource representing the custom domain policy of an organization. ```terraform resource zitadel_domain_policy domain_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_login_must_be_domain = false validate_org_domains = false diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index cad1faec..fe47c469 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -15,8 +15,6 @@ Resource representing a human user situated under an organization, which then ca ```terraform resource zitadel_human_user human_user { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_name = "humanfull@localhost.com" first_name = "firstname" diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md index 005ae8e2..0fba96e5 100644 --- a/docs/resources/init_message_text.md +++ b/docs/resources/init_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_init_message_text init_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 7c212ee5..e24612c0 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -13,8 +13,6 @@ Resource representing the membership of a user on an instance, defined with the ```terraform resource zitadel_instance_member instance_member { - depends_on = [zitadel_human_user.human_user] - user_id = zitadel_human_user.human_user.id roles = ["IAM_OWNER"] } diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index d64af7ac..9384651f 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -13,8 +13,6 @@ Resource representing the custom label policy of an organization. ```terraform resource zitadel_label_policy label_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id primary_color = "#5469d4" hide_login_name_suffix = true diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index 19f6a199..17113399 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -13,8 +13,6 @@ Resource representing the custom lockout policy of an organization. ```terraform resource zitadel_lockout_policy lockout_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id max_password_attempts = "5" } diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 639ddc57..304a7233 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -13,8 +13,6 @@ Resource representing the custom login policy of an organization. ```terraform resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org, zitadel_org_idp_jwt.jwt_idp, zitadel_org_idp_oidc.oidc_idp] - org_id = zitadel_org.org.id user_login = true allow_register = true diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index 437c4dd2..3c4ab425 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -13,9 +13,7 @@ description: |- ```terraform resource zitadel_login_texts login_texts_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" email_verification_done_text = { diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index c356389b..a7a7d3a5 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -13,8 +13,6 @@ Resource representing a machine key ```terraform resource zitadel_machine_key machine_key { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index 6527bd8a..daa664f5 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -13,8 +13,6 @@ Resource representing a serviceaccount situated under an organization, which the ```terraform resource zitadel_machine_user machine_user { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_name = "machine@localhost.com" name = "name" diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md new file mode 100644 index 00000000..4c3e0476 --- /dev/null +++ b/docs/resources/notification_policy.md @@ -0,0 +1,31 @@ +--- +page_title: "zitadel_notification_policy Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the custom notification policy of an organization. +--- + +# zitadel_notification_policy (Resource) + +Resource representing the custom notification policy of an organization. + +## Example Usage + +```terraform +resource zitadel_notification_policy notification_policy { + org_id = zitadel_org.org.id + password_change = false +} +``` + + +## Schema + +### Required + +- `org_id` (String) Id for the organization +- `password_change` (Boolean) Send notification if a user changes his password + +### Read-Only + +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/org.md b/docs/resources/org.md index 5da6722c..2084130b 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -13,7 +13,7 @@ Resource representing an organization in ZITADEL, which is the highest level aft ```terraform resource zitadel_org org { - name = "terraform-test" + name = "terraform-test" } ``` diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 23d0cd85..aa18e126 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -13,8 +13,6 @@ Resource representing a domain of the organization. ```terraform resource zitadel_org_idp_jwt jwt_idp { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index f9e88949..7533176c 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -13,8 +13,6 @@ Resource representing a OIDC IDP of the organization. ```terraform resource zitadel_org_idp_oidc oidc_idp { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 5ca877e9..858846e7 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -13,8 +13,6 @@ Resource representing the membership of a user on an organization, defined with ```terraform resource zitadel_org_member org_member { - depends_on = [zitadel_org.org, zitadel_human_user.human_user] - org_id = zitadel_org.org.id user_id = zitadel_human_user.human_user.id roles = ["ORG_OWNER"] diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index 51ada4ce..e47ae90b 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -13,8 +13,6 @@ Resource representing the custom password complexity policy of an organization. ```terraform resource zitadel_password_complexity_policy password_complexity_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id min_length = "8" has_uppercase = true diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md index 973be5d5..2c0c6a40 100644 --- a/docs/resources/password_reset_message_text.md +++ b/docs/resources/password_reset_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_password_reset_message_text password_reset_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md index 6ba6a0dd..4526496e 100644 --- a/docs/resources/passwordless_registration_message_text.md +++ b/docs/resources/passwordless_registration_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_passwordless_registration_message_text passwordless_registration_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 046e1a8e..9bd070d5 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -13,8 +13,6 @@ Resource representing a personal access token of a user ```terraform resource zitadel_personal_access_token pat { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id expiration_date = "2519-04-01T08:45:00Z" diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index d85cadc4..ffb4a63f 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -13,8 +13,6 @@ Resource representing the custom privacy policy of an organization. ```terraform resource zitadel_privacy_policy privacy_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id tos_link = "https://google.com" privacy_link = "https://google.com" diff --git a/docs/resources/project.md b/docs/resources/project.md index f983bf58..88612eea 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -13,8 +13,6 @@ Resource representing the project, which can then be granted to different organi ```terraform resource zitadel_project project { - depends_on = [zitadel_org.org] - name = "projectname" org_id = zitadel_org.org.id project_role_assertion = true diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 6a75e763..6f3fc0d1 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -13,8 +13,6 @@ Resource representing the grant of a project to a different organization, also c ```terraform resource zitadel_project_grant project_grant { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id granted_org_id = zitadel_org.grantedorg.id diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 698dc6ee..3a2587d2 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -13,8 +13,6 @@ Resource representing the membership of a user on an granted project, defined wi ```terraform resource zitadel_project_grant_member project_grant_member { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_project_grant.project_grant, zitadel_human_user.granted_human_user] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id grant_id = zitadel_project_grant.project_grant.id diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index fef6e934..14286715 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -13,8 +13,6 @@ Resource representing the membership of a user on an project, defined with the g ```terraform resource zitadel_project_member project_member { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_human_user.human_user] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id user_id = zitadel_human_user.human_user.id diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index ecf7e291..1624787c 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -13,8 +13,6 @@ Resource representing the project roles, which can be given as authorizations to ```terraform resource zitadel_project_role project_role { - depends_on = [zitadel_org.org, zitadel_project.project] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id role_key = "key" diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index ffed563f..920e0c0b 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -13,8 +13,6 @@ Resource representing triggers, when actions get started ```terraform resource zitadel_trigger_actions trigger_actions { - depends_on = [zitadel_action.action, zitadel_org.org] - org_id = zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 92a603da..78114dcc 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -13,8 +13,6 @@ Resource representing the authorization given to a user directly, including the ```terraform resource zitadel_user_grant user_grant { - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] - project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = ["key"] diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md index 42e650fb..00886751 100644 --- a/docs/resources/verify_email_message_text.md +++ b/docs/resources/verify_email_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_verify_email_message_text verify_email_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md index 7b6d1a5b..3d00af67 100644 --- a/docs/resources/verify_phone_message_text.md +++ b/docs/resources/verify_phone_message_text.md @@ -13,16 +13,14 @@ description: |- ```terraform resource zitadel_verify_phone_message_text verify_phone_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } diff --git a/examples/provider/data-sources/action.tf b/examples/provider/data-sources/action.tf index f0f107b3..b9fcb04f 100644 --- a/examples/provider/data-sources/action.tf +++ b/examples/provider/data-sources/action.tf @@ -1,8 +1,6 @@ data zitadel_action action { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id - action_id = "177073621691269123" + org_id = data.zitadel_org.org.id + action_id = "177073621691269123" } output action { diff --git a/examples/provider/data-sources/application_api.tf b/examples/provider/data-sources/application_api.tf index 83a59d92..a0f30f72 100644 --- a/examples/provider/data-sources/application_api.tf +++ b/examples/provider/data-sources/application_api.tf @@ -1,6 +1,4 @@ data zitadel_application_api api_application { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073625566806019" diff --git a/examples/provider/data-sources/application_oidc.tf b/examples/provider/data-sources/application_oidc.tf index 8d5476b3..d70d1bcc 100644 --- a/examples/provider/data-sources/application_oidc.tf +++ b/examples/provider/data-sources/application_oidc.tf @@ -1,9 +1,7 @@ data zitadel_application_oidc oidc_application { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id - app_id = "177073626925760515" + app_id = "177073626925760515" } output oidc_application { diff --git a/examples/provider/data-sources/human_user.tf b/examples/provider/data-sources/human_user.tf index 93584dae..7570eaeb 100644 --- a/examples/provider/data-sources/human_user.tf +++ b/examples/provider/data-sources/human_user.tf @@ -1,6 +1,4 @@ data zitadel_human_user human_user { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id user_id = "177073614158299139" } diff --git a/examples/provider/data-sources/machine_user.tf b/examples/provider/data-sources/machine_user.tf index 59b1758c..10badde8 100644 --- a/examples/provider/data-sources/machine_user.tf +++ b/examples/provider/data-sources/machine_user.tf @@ -1,6 +1,4 @@ data zitadel_machine_user machine_user { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id user_id = "177073617463410691" } diff --git a/examples/provider/data-sources/org_jwt_idp.tf b/examples/provider/data-sources/org_jwt_idp.tf index c57cfaad..08d47849 100644 --- a/examples/provider/data-sources/org_jwt_idp.tf +++ b/examples/provider/data-sources/org_jwt_idp.tf @@ -1,6 +1,4 @@ data zitadel_org_jwt_idp org_jwt_idp { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } diff --git a/examples/provider/data-sources/org_oidc_idp.tf b/examples/provider/data-sources/org_oidc_idp.tf index 4d1b4e23..4d9e4c9e 100644 --- a/examples/provider/data-sources/org_oidc_idp.tf +++ b/examples/provider/data-sources/org_oidc_idp.tf @@ -1,7 +1,5 @@ data zitadel_org_oidc_idp org_oidc_idp { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id + org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } diff --git a/examples/provider/data-sources/project.tf b/examples/provider/data-sources/project.tf index 8ba021b5..c252507d 100644 --- a/examples/provider/data-sources/project.tf +++ b/examples/provider/data-sources/project.tf @@ -1,8 +1,6 @@ data zitadel_project project { - depends_on = [data.zitadel_org.org] - - org_id = data.zitadel_org.org.id - project_id = "177073620768522243" + org_id = data.zitadel_org.org.id + project_id = "177073620768522243" } output project { diff --git a/examples/provider/data-sources/project_role.tf b/examples/provider/data-sources/project_role.tf index 7f4acebd..c4c00b91 100644 --- a/examples/provider/data-sources/project_role.tf +++ b/examples/provider/data-sources/project_role.tf @@ -1,9 +1,7 @@ data zitadel_project_role project_role { - depends_on = [data.zitadel_org.org, data.zitadel_project.project] - - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - role_key = "key" + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + role_key = "key" } output project_role { diff --git a/examples/provider/data-sources/trigger_actions.tf b/examples/provider/data-sources/trigger_actions.tf index fa2dae0f..f82a6594 100644 --- a/examples/provider/data-sources/trigger_actions.tf +++ b/examples/provider/data-sources/trigger_actions.tf @@ -1,6 +1,4 @@ data zitadel_trigger_actions trigger_actions { - depends_on = [data.zitadel_org.org] - org_id = data.zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/examples/provider/resources/action.tf b/examples/provider/resources/action.tf index 2636e24b..8d1256b4 100644 --- a/examples/provider/resources/action.tf +++ b/examples/provider/resources/action.tf @@ -1,7 +1,4 @@ - resource zitadel_action action { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "actionname" script = "testscript" diff --git a/examples/provider/resources/app_key.tf b/examples/provider/resources/app_key.tf index 343b92e9..3354852c 100644 --- a/examples/provider/resources/app_key.tf +++ b/examples/provider/resources/app_key.tf @@ -1,6 +1,4 @@ resource zitadel_application_key app_key { - depends_on = [zitadel_application_api.application_api, zitadel_project.project, zitadel_org.org] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id app_id = zitadel_application_api.application_api.id diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index de9cea54..57e96ab3 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -1,6 +1,4 @@ resource zitadel_application_api application_api { - depends_on = [zitadel_org.org, zitadel_project.project] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index c972328c..df1daa12 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,6 +1,4 @@ -resource zitadel_application_oidc application_oidc{ - depends_on = [zitadel_org.org, zitadel_project.project] - +resource zitadel_application_oidc application_oidc { project_id = zitadel_project.project.id org_id = zitadel_org.org.id diff --git a/examples/provider/resources/default_domain_claimed_message_text.tf b/examples/provider/resources/default_domain_claimed_message_text.tf index c401364c..ee5f7957 100644 --- a/examples/provider/resources/default_domain_claimed_message_text.tf +++ b/examples/provider/resources/default_domain_claimed_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_domain_claimed_message_text domain_claimed_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/default_domain_policy.tf b/examples/provider/resources/default_domain_policy.tf index bb12d167..e0a64eaa 100644 --- a/examples/provider/resources/default_domain_policy.tf +++ b/examples/provider/resources/default_domain_policy.tf @@ -1,4 +1,3 @@ - resource zitadel_default_domain_policy domain_policy { user_login_must_be_domain = false validate_org_domains = false diff --git a/examples/provider/resources/default_init_message_text.tf b/examples/provider/resources/default_init_message_text.tf index 8450094e..1738cedc 100644 --- a/examples/provider/resources/default_init_message_text.tf +++ b/examples/provider/resources/default_init_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_init_message_text init_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/default_lockout_policy.tf b/examples/provider/resources/default_lockout_policy.tf index 5f7f0731..4a64e7e4 100644 --- a/examples/provider/resources/default_lockout_policy.tf +++ b/examples/provider/resources/default_lockout_policy.tf @@ -1,4 +1,3 @@ - resource zitadel_default_lockout_policy lockout_policy { max_password_attempts = "5" } \ No newline at end of file diff --git a/examples/provider/resources/default_password_complexity_policy.tf b/examples/provider/resources/default_password_complexity_policy.tf index cfa844a9..ec4970b9 100644 --- a/examples/provider/resources/default_password_complexity_policy.tf +++ b/examples/provider/resources/default_password_complexity_policy.tf @@ -1,4 +1,3 @@ - resource zitadel_default_password_complexity_policy password_complexity_policy { min_length = "8" has_uppercase = true diff --git a/examples/provider/resources/default_password_reset_message_text.tf b/examples/provider/resources/default_password_reset_message_text.tf index 3fafca82..b12a8b3f 100644 --- a/examples/provider/resources/default_password_reset_message_text.tf +++ b/examples/provider/resources/default_password_reset_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_password_reset_message_text password_reset_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/default_passwordless_registration_message_text.tf b/examples/provider/resources/default_passwordless_registration_message_text.tf index 7591f22f..a3c0fbd9 100644 --- a/examples/provider/resources/default_passwordless_registration_message_text.tf +++ b/examples/provider/resources/default_passwordless_registration_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf index 0fc0e179..5bae97d6 100644 --- a/examples/provider/resources/default_privacy_policy.tf +++ b/examples/provider/resources/default_privacy_policy.tf @@ -1,4 +1,3 @@ - resource zitadel_default_privacy_policy privacy_policy { tos_link = "https://google.com" privacy_link = "https://google.com" diff --git a/examples/provider/resources/default_verify_email_message_text.tf b/examples/provider/resources/default_verify_email_message_text.tf index de135c59..693de48f 100644 --- a/examples/provider/resources/default_verify_email_message_text.tf +++ b/examples/provider/resources/default_verify_email_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_verify_email_message_text verify_email_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/default_verify_phone_message_text.tf b/examples/provider/resources/default_verify_phone_message_text.tf index ed0aee87..f58c46c0 100644 --- a/examples/provider/resources/default_verify_phone_message_text.tf +++ b/examples/provider/resources/default_verify_phone_message_text.tf @@ -1,11 +1,11 @@ resource zitadel_default_verify_phone_message_text verify_phone_en { language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 6ffca369..2570c45c 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,7 +1,4 @@ - resource zitadel_domain domain { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "localhost.com" } \ No newline at end of file diff --git a/examples/provider/resources/domain_claimed_message_text.tf b/examples/provider/resources/domain_claimed_message_text.tf index 88e6c734..e3f2c191 100644 --- a/examples/provider/resources/domain_claimed_message_text.tf +++ b/examples/provider/resources/domain_claimed_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_domain_claimed_message_text domain_claimed_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index d74a7929..70c02620 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,7 +1,4 @@ - resource zitadel_domain_policy domain_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_login_must_be_domain = false validate_org_domains = false diff --git a/examples/provider/resources/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf index 5ade8858..42d32965 100644 --- a/examples/provider/resources/granted_human_user.tf +++ b/examples/provider/resources/granted_human_user.tf @@ -1,7 +1,4 @@ - resource zitadel_human_user granted_human_user { - depends_on = [zitadel_org.grantedorg] - org_id = zitadel_org.grantedorg.id user_name = "human@localhost" first_name = "firstname" diff --git a/examples/provider/resources/granted_org.tf b/examples/provider/resources/granted_org.tf index ddcd2ac3..73f0cb78 100644 --- a/examples/provider/resources/granted_org.tf +++ b/examples/provider/resources/granted_org.tf @@ -1,4 +1,3 @@ - resource zitadel_org grantedorg { - name = "terraform-test-granted" + name = "terraform-test-granted" } diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 7df5a9ae..5370b14e 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,6 +1,4 @@ resource zitadel_human_user human_user { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_name = "humanfull@localhost.com" first_name = "firstname" diff --git a/examples/provider/resources/init_message_text.tf b/examples/provider/resources/init_message_text.tf index 8e7ac115..e648014a 100644 --- a/examples/provider/resources/init_message_text.tf +++ b/examples/provider/resources/init_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_init_message_text init_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/instance_member.tf b/examples/provider/resources/instance_member.tf index b4f03f98..ddac2c4f 100644 --- a/examples/provider/resources/instance_member.tf +++ b/examples/provider/resources/instance_member.tf @@ -1,6 +1,4 @@ resource zitadel_instance_member instance_member { - depends_on = [zitadel_human_user.human_user] - user_id = zitadel_human_user.human_user.id roles = ["IAM_OWNER"] } \ No newline at end of file diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index 428e2ea2..7aaa6d23 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -1,6 +1,4 @@ resource zitadel_label_policy label_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id primary_color = "#5469d4" hide_login_name_suffix = true diff --git a/examples/provider/resources/lockout_policy.tf b/examples/provider/resources/lockout_policy.tf index ffb69e35..4d8a6a05 100644 --- a/examples/provider/resources/lockout_policy.tf +++ b/examples/provider/resources/lockout_policy.tf @@ -1,7 +1,4 @@ - resource zitadel_lockout_policy lockout_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id max_password_attempts = "5" } \ No newline at end of file diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index d38d8620..f2470880 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -1,6 +1,4 @@ resource zitadel_login_policy login_policy { - depends_on = [zitadel_org.org, zitadel_org_idp_jwt.jwt_idp, zitadel_org_idp_oidc.oidc_idp] - org_id = zitadel_org.org.id user_login = true allow_register = true diff --git a/examples/provider/resources/login_texts.tf b/examples/provider/resources/login_texts.tf index be57d19d..ea13f4c6 100644 --- a/examples/provider/resources/login_texts.tf +++ b/examples/provider/resources/login_texts.tf @@ -1,7 +1,5 @@ resource zitadel_login_texts login_texts_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" email_verification_done_text = { diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 59e1449e..3516c458 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,6 +1,4 @@ resource zitadel_machine_key machine_key { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" diff --git a/examples/provider/resources/machine_user.tf b/examples/provider/resources/machine_user.tf index a61f64af..ae091cf6 100644 --- a/examples/provider/resources/machine_user.tf +++ b/examples/provider/resources/machine_user.tf @@ -1,7 +1,4 @@ - resource zitadel_machine_user machine_user { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id user_name = "machine@localhost.com" name = "name" diff --git a/examples/provider/resources/notification_policy.tf b/examples/provider/resources/notification_policy.tf index 0c9c1d83..a10f774c 100644 --- a/examples/provider/resources/notification_policy.tf +++ b/examples/provider/resources/notification_policy.tf @@ -1,6 +1,4 @@ resource zitadel_notification_policy notification_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id password_change = false } \ No newline at end of file diff --git a/examples/provider/resources/org.tf b/examples/provider/resources/org.tf index c79c899d..8dbaa015 100644 --- a/examples/provider/resources/org.tf +++ b/examples/provider/resources/org.tf @@ -1,3 +1,3 @@ resource zitadel_org org { - name = "terraform-test" + name = "terraform-test" } \ No newline at end of file diff --git a/examples/provider/resources/org_idp_jwt.tf b/examples/provider/resources/org_idp_jwt.tf index d68d4df3..6f316a25 100644 --- a/examples/provider/resources/org_idp_jwt.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -1,6 +1,4 @@ resource zitadel_org_idp_jwt jwt_idp { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index af57d67b..ce1606d3 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,6 +1,4 @@ resource zitadel_org_idp_oidc oidc_idp { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/examples/provider/resources/org_member.tf b/examples/provider/resources/org_member.tf index 3044c7a6..56bb57dc 100644 --- a/examples/provider/resources/org_member.tf +++ b/examples/provider/resources/org_member.tf @@ -1,6 +1,4 @@ resource zitadel_org_member org_member { - depends_on = [zitadel_org.org, zitadel_human_user.human_user] - org_id = zitadel_org.org.id user_id = zitadel_human_user.human_user.id roles = ["ORG_OWNER"] diff --git a/examples/provider/resources/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf index a2665964..08534b5e 100644 --- a/examples/provider/resources/password_complexity_policy.tf +++ b/examples/provider/resources/password_complexity_policy.tf @@ -1,7 +1,4 @@ - resource zitadel_password_complexity_policy password_complexity_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id min_length = "8" has_uppercase = true diff --git a/examples/provider/resources/password_reset_message_text.tf b/examples/provider/resources/password_reset_message_text.tf index 9273909c..807e8bb5 100644 --- a/examples/provider/resources/password_reset_message_text.tf +++ b/examples/provider/resources/password_reset_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_password_reset_message_text password_reset_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/passwordless_registration_message_text.tf b/examples/provider/resources/passwordless_registration_message_text.tf index b511d8aa..d43a8a0a 100644 --- a/examples/provider/resources/passwordless_registration_message_text.tf +++ b/examples/provider/resources/passwordless_registration_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_passwordless_registration_message_text passwordless_registration_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/personal_access_token.tf b/examples/provider/resources/personal_access_token.tf index 0b063787..7596eb8b 100644 --- a/examples/provider/resources/personal_access_token.tf +++ b/examples/provider/resources/personal_access_token.tf @@ -1,6 +1,4 @@ resource zitadel_personal_access_token pat { - depends_on = [zitadel_machine_user.machine_user, zitadel_org.org] - org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id expiration_date = "2519-04-01T08:45:00Z" diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index 5b13c971..486bb012 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,7 +1,4 @@ - resource zitadel_privacy_policy privacy_policy { - depends_on = [zitadel_org.org] - org_id = zitadel_org.org.id tos_link = "https://google.com" privacy_link = "https://google.com" diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 42b0b884..3c445ddc 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,7 +1,4 @@ - resource zitadel_project project { - depends_on = [zitadel_org.org] - name = "projectname" org_id = zitadel_org.org.id project_role_assertion = true diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index e1e7982a..9c5c0178 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,6 +1,4 @@ resource zitadel_project_grant project_grant { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_org.grantedorg, zitadel_project_role.project_role] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id granted_org_id = zitadel_org.grantedorg.id diff --git a/examples/provider/resources/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf index 58e9427b..27875252 100644 --- a/examples/provider/resources/project_grant_member.tf +++ b/examples/provider/resources/project_grant_member.tf @@ -1,7 +1,4 @@ - resource zitadel_project_grant_member project_grant_member { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_project_grant.project_grant, zitadel_human_user.granted_human_user] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id grant_id = zitadel_project_grant.project_grant.id diff --git a/examples/provider/resources/project_member.tf b/examples/provider/resources/project_member.tf index 683ca6fc..d31aebca 100644 --- a/examples/provider/resources/project_member.tf +++ b/examples/provider/resources/project_member.tf @@ -1,7 +1,4 @@ - resource zitadel_project_member project_member { - depends_on = [zitadel_org.org, zitadel_project.project, zitadel_human_user.human_user] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id user_id = zitadel_human_user.human_user.id diff --git a/examples/provider/resources/project_role.tf b/examples/provider/resources/project_role.tf index 6a461c01..1b56ff5a 100644 --- a/examples/provider/resources/project_role.tf +++ b/examples/provider/resources/project_role.tf @@ -1,7 +1,4 @@ - resource zitadel_project_role project_role { - depends_on = [zitadel_org.org, zitadel_project.project] - org_id = zitadel_org.org.id project_id = zitadel_project.project.id role_key = "key" diff --git a/examples/provider/resources/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf index f910005d..4bf115de 100644 --- a/examples/provider/resources/trigger_actions.tf +++ b/examples/provider/resources/trigger_actions.tf @@ -1,6 +1,4 @@ resource zitadel_trigger_actions trigger_actions { - depends_on = [zitadel_action.action, zitadel_org.org] - org_id = zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 4162c7c9..77a1cb65 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,6 +1,4 @@ resource zitadel_user_grant user_grant { - depends_on = [zitadel_project.project, zitadel_org.org, zitadel_human_user.granted_human_user] - project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = ["key"] diff --git a/examples/provider/resources/verify_email_message_text.tf b/examples/provider/resources/verify_email_message_text.tf index 758efc93..e0648cc6 100644 --- a/examples/provider/resources/verify_email_message_text.tf +++ b/examples/provider/resources/verify_email_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_verify_email_message_text verify_email_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/examples/provider/resources/verify_phone_message_text.tf b/examples/provider/resources/verify_phone_message_text.tf index c3e6d5b2..4a57d174 100644 --- a/examples/provider/resources/verify_phone_message_text.tf +++ b/examples/provider/resources/verify_phone_message_text.tf @@ -1,14 +1,12 @@ resource zitadel_verify_phone_message_text verify_phone_en { - depends_on = [zitadel_org.org] - - org_id = zitadel_org.org.id + org_id = zitadel_org.org.id language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" button_text = "button_text example" footer_text = "footer_text example" } \ No newline at end of file diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index 510e3264..e6f9ec3c 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -29,23 +29,28 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdateDomainPolicy(ctx, &admin.UpdateDomainPolicyRequest{ - UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), - ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), - SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), - }) - if helper.IgnorePreconditionError(err) != nil { - return diag.Errorf("failed to update default domain policy: %v", err) + id := "" + if d.HasChanges(userLoginMustBeDomainVar, validateOrgDomainVar, smtpSenderVar) { + resp, err := client.UpdateDomainPolicy(ctx, &admin.UpdateDomainPolicyRequest{ + UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), + SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), + }) + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default domain policy: %v", err) + } + if resp != nil { + id = resp.GetDetails().GetResourceOwner() + } } - if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { + if id == "" { resp, err := client.GetDomainPolicy(ctx, &admin.GetDomainPolicyRequest{}) if err != nil { return diag.Errorf("failed to update default domain policy: %v", err) } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) return nil } diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 07bde5d2..caa20521 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -29,6 +29,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } + id := "" if d.HasChanges( primaryColorVar, hideLoginNameSuffixVar, @@ -57,15 +58,17 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to update default label policy: %v", err) } if resp != nil { - d.SetId(resp.Details.ResourceOwner) - } else { - resp, err := client.GetLabelPolicy(ctx, &admin.GetLabelPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to update default label policy: %v", err) - } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.Details.ResourceOwner + } + } + if id == "" { + resp, err := client.GetLabelPolicy(ctx, &admin.GetLabelPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default label policy: %v", err) } + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) if d.HasChanges(logoHashVar, logoPathVar) { if err := helper.InstanceFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index b0fb425f..d3900de8 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -29,21 +29,26 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ - MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), - }) - if helper.IgnorePreconditionError(err) != nil { - return diag.Errorf("failed to update default lockout policy: %v", err) + id := "" + if d.HasChanges(maxPasswordAttemptsVar) { + resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ + MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + }) + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default lockout policy: %v", err) + } + if resp != nil { + id = resp.GetDetails().GetResourceOwner() + } } - if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { + if id == "" { resp, err := client.GetLockoutPolicy(ctx, &admin.GetLockoutPolicyRequest{}) if err != nil { return diag.Errorf("failed to update default lockout policy: %v", err) } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) return nil } diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index b449a9ad..222ac3ae 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -32,6 +32,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } + id := "" if d.HasChanges(passwordCheckLifetimeVar, externalLoginCheckLifetimeVar, mfaInitSkipLifetimeVar, @@ -91,15 +92,18 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to update login policy: %v", err) } if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { - resp, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) - if err != nil { - return diag.Errorf("failed to update default login policy: %v", err) - } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.GetDetails().GetResourceOwner() + } + } + + if id == "" { + resp, err := client.GetLoginPolicy(ctx, &admin.GetLoginPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default login policy: %v", err) } + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) if d.HasChange(secondFactorsVar) { o, err := client.ListLoginPolicySecondFactors(ctx, &admin.ListLoginPolicySecondFactorsRequest{}) diff --git a/zitadel/v2/default_notification_policy/funcs.go b/zitadel/v2/default_notification_policy/funcs.go index 18e6de34..42906f19 100644 --- a/zitadel/v2/default_notification_policy/funcs.go +++ b/zitadel/v2/default_notification_policy/funcs.go @@ -29,21 +29,24 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdateNotificationPolicy(ctx, &admin.UpdateNotificationPolicyRequest{ - PasswordChange: d.Get(passwordChangeVar).(bool), - }) - if helper.IgnorePreconditionError(err) != nil { - return diag.Errorf("failed to update default notification policy: %v", err) - } - if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { - resp, err := client.GetNotificationPolicy(ctx, &admin.GetNotificationPolicyRequest{}) - if err != nil { + if d.HasChanges(passwordChangeVar) { + resp, err := client.UpdateNotificationPolicy(ctx, &admin.UpdateNotificationPolicyRequest{ + PasswordChange: d.Get(passwordChangeVar).(bool), + }) + if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default notification policy: %v", err) } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + if resp != nil { + d.SetId(resp.GetDetails().GetResourceOwner()) + return nil + } + } + + resp, err := client.GetNotificationPolicy(ctx, &admin.GetNotificationPolicyRequest{}) + if err != nil { + return diag.Errorf("failed to update default notification policy: %v", err) } + d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) return nil } diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go index 93645c0d..752166e5 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -29,25 +29,30 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdatePasswordComplexityPolicy(ctx, &admin.UpdatePasswordComplexityPolicyRequest{ - MinLength: uint32(d.Get(minLengthVar).(int)), - HasUppercase: d.Get(hasUppercaseVar).(bool), - HasLowercase: d.Get(hasLowercaseVar).(bool), - HasNumber: d.Get(hasNumberVar).(bool), - HasSymbol: d.Get(hasSymbolVar).(bool), - }) - if helper.IgnorePreconditionError(err) != nil { - return diag.Errorf("failed to update default password complexity policy: %v", err) + id := "" + if d.HasChanges(minLengthVar, hasUppercaseVar, hasLowercaseVar, hasNumberVar, hasSymbolVar) { + resp, err := client.UpdatePasswordComplexityPolicy(ctx, &admin.UpdatePasswordComplexityPolicyRequest{ + MinLength: uint32(d.Get(minLengthVar).(int)), + HasUppercase: d.Get(hasUppercaseVar).(bool), + HasLowercase: d.Get(hasLowercaseVar).(bool), + HasNumber: d.Get(hasNumberVar).(bool), + HasSymbol: d.Get(hasSymbolVar).(bool), + }) + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default password complexity policy: %v", err) + } + if resp != nil { + id = resp.GetDetails().GetResourceOwner() + } } - if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { + if id == "" { resp, err := client.GetPasswordComplexityPolicy(ctx, &admin.GetPasswordComplexityPolicyRequest{}) if err != nil { return diag.Errorf("failed to get default password complexity policy: %v", err) } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) return nil } diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index b16b3748..b11bde98 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -29,23 +29,28 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - resp, err := client.UpdatePrivacyPolicy(ctx, &admin.UpdatePrivacyPolicyRequest{ - TosLink: d.Get(tosLinkVar).(string), - PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), - }) - if helper.IgnorePreconditionError(err) != nil { - return diag.Errorf("failed to update default privacy policy: %v", err) + id := "" + if d.HasChanges(tosLinkVar, privacyLinkVar, helpLinkVar) { + resp, err := client.UpdatePrivacyPolicy(ctx, &admin.UpdatePrivacyPolicyRequest{ + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + }) + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default privacy policy: %v", err) + } + if resp != nil { + id = resp.GetDetails().GetResourceOwner() + } } - if resp != nil { - d.SetId(resp.GetDetails().GetResourceOwner()) - } else { + if id == "" { resp, err := client.GetPrivacyPolicy(ctx, &admin.GetPrivacyPolicyRequest{}) if err != nil { return diag.Errorf("failed to update default privacy policy: %v", err) } - d.SetId(resp.GetPolicy().GetDetails().GetResourceOwner()) + id = resp.GetPolicy().GetDetails().GetResourceOwner() } + d.SetId(id) return nil } diff --git a/zitadel/v2/notification_policy/funcs.go b/zitadel/v2/notification_policy/funcs.go index e6b17161..4c74b497 100644 --- a/zitadel/v2/notification_policy/funcs.go +++ b/zitadel/v2/notification_policy/funcs.go @@ -45,11 +45,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } org := d.Get(orgIDVar).(string) - _, err = client.UpdateCustomNotificationPolicy(ctx, &management.UpdateCustomNotificationPolicyRequest{ - PasswordChange: d.Get(passwordChangeVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update notification policy: %v", err) + if d.HasChanges(passwordChangeVar) { + _, err = client.UpdateCustomNotificationPolicy(ctx, &management.UpdateCustomNotificationPolicyRequest{ + PasswordChange: d.Get(passwordChangeVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update notification policy: %v", err) + } } d.SetId(org) return nil From 6e715557be76404280e43592b5edf6176746deb8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 8 Mar 2023 13:42:37 +0100 Subject: [PATCH 059/260] chore: declare tfplugindocs dependency --- go.mod | 34 +++++++++++---- go.sum | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools.go | 8 ++++ 3 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 tools.go diff --git a/go.mod b/go.mod index 00074dd3..2dc86c71 100644 --- a/go.mod +++ b/go.mod @@ -21,43 +21,63 @@ require ( ) require ( + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/armon/go-radix v1.0.0 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/go-test/deep v1.0.7 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect - github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-checkpoint v0.5.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.2.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.4.6 // 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.0 // indirect github.com/hashicorp/hcl/v2 v2.15.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.15.0 // indirect + github.com/hashicorp/terraform-plugin-docs v0.14.1 // indirect github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect - github.com/kr/pretty v0.2.1 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mitchellh/cli v1.1.5 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/posener/complete v1.2.3 // indirect + github.com/russross/blackfriday v1.6.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.5.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect - golang.org/x/crypto v0.1.0 // indirect + github.com/zclconf/go-cty v1.13.0 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.5.0 // indirect golang.org/x/sys v0.4.0 // indirect - golang.org/x/text v0.6.0 // indirect + golang.org/x/text v0.7.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index 21786127..584a3f7d 100644 --- a/go.sum +++ b/go.sum @@ -33,13 +33,31 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= +github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= +github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -50,16 +68,25 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= +github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -123,6 +150,9 @@ 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/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -135,15 +165,24 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= 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/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.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.1/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/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -151,10 +190,18 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= +github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= 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.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= +github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= +github.com/hashicorp/terraform-plugin-docs v0.14.1 h1:MikFi59KxrP/ewrZoaowrB9he5Vu4FtvhamZFustiA4= +github.com/hashicorp/terraform-plugin-docs v0.14.1/go.mod h1:k2NW8+t113jAus6bb5tQYQgEAX/KueE/u8X2Z45V1GM= github.com/hashicorp/terraform-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q= github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek= @@ -171,54 +218,99 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKL github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 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/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/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/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= 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/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= +github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= @@ -232,6 +324,7 @@ github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvC github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -239,8 +332,13 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/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.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= +github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= +github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= @@ -251,14 +349,21 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -291,6 +396,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -322,6 +429,7 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -347,6 +455,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -355,6 +464,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -375,7 +485,10 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -385,19 +498,24 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -534,16 +652,22 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/tools.go b/tools.go new file mode 100644 index 00000000..18001576 --- /dev/null +++ b/tools.go @@ -0,0 +1,8 @@ +//go:build tools +// +build tools + +package tools + +import ( + _ "github.com/hashicorp/terraform-plugin-docs" +) From 7b82a5952fff2894bd9bf7c2752488c0e83fa19f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 8 Mar 2023 13:43:08 +0100 Subject: [PATCH 060/260] docs: update docs --- docs/resources/application_key.md | 2 +- docs/resources/instance_member.md | 2 +- docs/resources/label_policy.md | 2 +- docs/resources/login_texts.md | 2 +- docs/resources/machine_key.md | 2 +- docs/resources/personal_access_token.md | 2 +- docs/resources/smtp_config.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 9f1c8e39..6b4dec60 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -29,7 +29,7 @@ resource zitadel_application_key app_key { ### Required - `app_id` (String) ID of the application -- `expiration_date` (String) Expiration date of the app key +- `expiration_date` (String) Expiration date of the app key in the RFC3339 format - `key_type` (String) Type of the app key, supported values: KEY_TYPE_UNSPECIFIED, KEY_TYPE_JSON - `org_id` (String) ID of the organization - `project_id` (String) ID of the project diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 7c212ee5..b421cca5 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -25,7 +25,7 @@ resource zitadel_instance_member instance_member { ### Required -- `roles` (Set of String) List of roles granted +- `roles` (Set of String) List of roles granted, full list available here: https://zitadel.com/docs/guides/manage/console/managers#roles - `user_id` (String) ID of the user ### Read-Only diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index d64af7ac..ced39284 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -50,7 +50,7 @@ resource zitadel_label_policy label_policy { - `disable_watermark` (Boolean) disable watermark - `font_color` (String) hex value for font color - `font_color_dark` (String) hex value for font color dark theme -- `hide_login_name_suffix` (Boolean) hides the org suffix on the login form if the scope "urn:zitadel:iam:org:domain:primary:{domainname}" is set. Details about this scope in https://docs.zitadel.ch/concepts#Reserved_Scopes +- `hide_login_name_suffix` (Boolean) hides the org suffix on the login form if the scope "urn:zitadel:iam:org:domain:primary:{domainname}" is set. Details about this scope in https://zitadel.com/docs/apis/openidoauth/scopes#reserved-scopes - `org_id` (String) Id for the organization - `primary_color` (String) hex value for primary color - `primary_color_dark` (String) hex value for primary color dark theme diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index 437c4dd2..5f9bffd6 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -762,7 +762,7 @@ Optional: Optional: -- `auto_redirect_description` (String) Text to describe that auto redirect should happen after successful login +- `auto_redirect_description` (String) Text to describe that auto-redirect should happen after successful login - `next_button_text` (String) - `redirected_description` (String) Text to describe that the window can be closed after redirect - `title` (String) diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index c356389b..81a5b6f8 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -33,7 +33,7 @@ resource zitadel_machine_key machine_key { ### Optional -- `expiration_date` (String) Expiration date of the machine key +- `expiration_date` (String) Expiration date of the machine key in the RFC3339 format ### Read-Only diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 046e1a8e..7366b323 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -31,7 +31,7 @@ resource zitadel_personal_access_token pat { ### Optional -- `expiration_date` (String) Expiration date of the token +- `expiration_date` (String) Expiration date of the token in the RFC3339 format ### Read-Only diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index 30d8df99..6ca2635a 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -27,7 +27,7 @@ resource zitadel_smtp_config smtp { ### Required -- `host` (String) Host address to your SMTP server. +- `host` (String) Host and port address to your SMTP server. - `sender_address` (String) Address used to send emails. - `sender_name` (String) Sender name used to send emails. From 1ea064be489585079586d4a34bba86a43566171e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 8 Mar 2023 13:43:53 +0100 Subject: [PATCH 061/260] docs: regen resources --- gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go index 499c5f1b..13ab4bdc 100644 --- a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -1228,7 +1228,7 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo "success_login_text": { Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ "auto_redirect_description": { - Description: "Text to describe that auto redirect should happen after successful login", + Description: "Text to describe that auto-redirect should happen after successful login", Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, From 5f4cee301dd89e5c66f40e4f737da1c0e31f1b1f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 8 Mar 2023 15:33:42 +0100 Subject: [PATCH 062/260] chore: fix tools declaration --- go.mod | 5 +---- go.sum | 29 ++++++++++++++++------------- tools.go | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index df82d101..86f56a75 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 + github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-framework v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.1 github.com/hashicorp/terraform-plugin-log v0.7.0 @@ -48,14 +49,11 @@ require ( github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.18.1 // indirect github.com/hashicorp/terraform-json v0.15.0 // indirect - github.com/hashicorp/terraform-plugin-docs v0.14.1 // indirect github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/kr/pretty v0.3.0 // indirect - github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/cli v1.1.5 // indirect @@ -80,6 +78,5 @@ require ( golang.org/x/text v0.7.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index b81d3611..1bfebfc3 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,11 @@ github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFP github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= +github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -68,6 +71,7 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -79,13 +83,17 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= 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= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -163,7 +171,6 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= -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/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -226,20 +233,21 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH 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/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/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -249,13 +257,11 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= 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= @@ -264,6 +270,7 @@ github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2c github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= @@ -287,12 +294,13 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -324,6 +332,7 @@ github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvC github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -334,16 +343,12 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= -github.com/zitadel/zitadel-go/v2 v2.0.9 h1:XsXvbolwRFSeURF75BUpjcU9eLNiqhgmqaOe0HlAsbQ= -github.com/zitadel/zitadel-go/v2 v2.0.9/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= github.com/zitadel/zitadel-go/v2 v2.0.10 h1:gVV8DK0w4w+GQuazXdHpiwyMjeHPeSG5Uh4/rsY9gZ4= github.com/zitadel/zitadel-go/v2 v2.0.10/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -362,8 +367,6 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -514,7 +517,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= @@ -662,6 +664,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/tools.go b/tools.go index 18001576..f770edf2 100644 --- a/tools.go +++ b/tools.go @@ -4,5 +4,5 @@ package tools import ( - _ "github.com/hashicorp/terraform-plugin-docs" + _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" ) From ecae7d382ed4175d9448222e45a8ac2b0d0fe331 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 20 Mar 2023 16:25:54 +0100 Subject: [PATCH 063/260] fix: add handling for flow and trigger type strings --- docs/resources/trigger_actions.md | 4 +-- zitadel/v2/action/resource.go | 2 +- zitadel/v2/helper/helper.go | 8 ++++++ zitadel/v2/trigger_actions/resource.go | 37 +++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index 920e0c0b..1473cd52 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -26,9 +26,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_UNSPECIFIED, FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION ### Read-Only diff --git a/zitadel/v2/action/resource.go b/zitadel/v2/action/resource.go index 007846eb..04440608 100644 --- a/zitadel/v2/action/resource.go +++ b/zitadel/v2/action/resource.go @@ -18,7 +18,7 @@ func GetResource() *schema.Resource { Type: schema.TypeInt, Computed: true, Description: "the state of the action", - /* Not necessary as long as only active users are created + /* Not necessary as long as only active actions are created ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return EnumValueValidation(actionState, value, action.ActionState_value) },*/ diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index aa4ddf2c..85a54e52 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -130,3 +130,11 @@ func DescriptionEnumValuesList(enum map[int32]string) string { str += strings.Join(values, ", ") return str } + +func EnumValueMap(enum map[int32]string) map[string]int32 { + values := make(map[string]int32) + for k, v := range enum { + values[v] = k + } + return values +} diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 0ab0a8dc..d4423fd4 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -1,7 +1,11 @@ package trigger_actions import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -17,14 +21,20 @@ func GetResource() *schema.Resource { flowTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the flow to which the action triggers belong", - ForceNew: true, + Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(flowTypes()), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(flowTypeVar, value, helper.EnumValueMap(flowTypes())) + }, + ForceNew: true, }, triggerTypeVar: { Type: schema.TypeString, Required: true, - Description: "Trigger type on when the actions get triggered", - ForceNew: true, + Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(triggerTypes()), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(triggerTypeVar, value, helper.EnumValueMap(triggerTypes())) + }, + ForceNew: true, }, actionsVar: { Type: schema.TypeSet, @@ -42,3 +52,22 @@ func GetResource() *schema.Resource { Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } + +func flowTypes() map[int32]string { + return map[int32]string{ + 0: "FLOW_TYPE_UNSPECIFIED", + 1: "FLOW_TYPE_EXTERNAL_AUTHENTICATION", + 2: "FLOW_TYPE_CUSTOMISE_TOKEN", + 3: "FLOW_TYPE_INTERNAL_AUTHENTICATION", + } +} +func triggerTypes() map[int32]string { + return map[int32]string{ + 0: "TRIGGER_TYPE_UNSPECIFIED", + 1: "TRIGGER_TYPE_POST_AUTHENTICATION", + 2: "TRIGGER_TYPE_PRE_CREATION", + 3: "TRIGGER_TYPE_POST_CREATION", + 4: "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION", + 5: "TRIGGER_TYPE_PRE_USERINFO_CREATION", + } +} From 79b0ae6beaf738ba57f4c72ec6cd35a74bb30994 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 22 Mar 2023 15:16:21 +0100 Subject: [PATCH 064/260] fix: add handling for flow and trigger type strings --- zitadel/v2/trigger_actions/funcs.go | 23 +++++++++++++++++------ zitadel/v2/trigger_actions/resource.go | 2 -- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index 89594940..2b180156 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -2,6 +2,7 @@ package trigger_actions import ( "context" + "strconv" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -24,9 +25,13 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } + flowType := d.Get(flowTypeVar).(string) + flowTypeValues := helper.EnumValueMap(flowTypes()) + triggerType := d.Get(triggerTypeVar).(string) + triggerTypeValues := helper.EnumValueMap(triggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: d.Get(flowTypeVar).(string), - TriggerType: d.Get(triggerTypeVar).(string), + FlowType: strconv.Itoa(int(flowTypeValues[flowType])), + TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), ActionIds: []string{}, }) if helper.IgnoreIfNotFoundError(err) != nil { @@ -48,9 +53,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } + flowType := d.Get(flowTypeVar).(string) + flowTypeValues := helper.EnumValueMap(flowTypes()) + triggerType := d.Get(triggerTypeVar).(string) + triggerTypeValues := helper.EnumValueMap(triggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: d.Get(flowTypeVar).(string), - TriggerType: d.Get(triggerTypeVar).(string), + FlowType: strconv.Itoa(int(flowTypeValues[flowType])), + TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) if err != nil { @@ -75,10 +84,12 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } flowType := d.Get(flowTypeVar).(string) + flowTypeValues := helper.EnumValueMap(flowTypes()) triggerType := d.Get(triggerTypeVar).(string) + triggerTypeValues := helper.EnumValueMap(triggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ - FlowType: flowType, - TriggerType: triggerType, + FlowType: strconv.Itoa(int(flowTypeValues[flowType])), + TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), }) d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index d4423fd4..b0e2bea5 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -55,7 +55,6 @@ func GetResource() *schema.Resource { func flowTypes() map[int32]string { return map[int32]string{ - 0: "FLOW_TYPE_UNSPECIFIED", 1: "FLOW_TYPE_EXTERNAL_AUTHENTICATION", 2: "FLOW_TYPE_CUSTOMISE_TOKEN", 3: "FLOW_TYPE_INTERNAL_AUTHENTICATION", @@ -63,7 +62,6 @@ func flowTypes() map[int32]string { } func triggerTypes() map[int32]string { return map[int32]string{ - 0: "TRIGGER_TYPE_UNSPECIFIED", 1: "TRIGGER_TYPE_POST_AUTHENTICATION", 2: "TRIGGER_TYPE_PRE_CREATION", 3: "TRIGGER_TYPE_POST_CREATION", From 6e071e594d238d93e44697bfa0ef111076138de9 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Thu, 23 Mar 2023 19:46:01 +0900 Subject: [PATCH 065/260] feat: add access_token_type argument in machine user --- zitadel/v2/machine_user/const.go | 5 +++-- zitadel/v2/machine_user/datasource.go | 5 +++++ zitadel/v2/machine_user/funcs.go | 18 +++++++++++------- zitadel/v2/machine_user/resource.go | 5 +++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/zitadel/v2/machine_user/const.go b/zitadel/v2/machine_user/const.go index 848aa89c..904cd8ed 100644 --- a/zitadel/v2/machine_user/const.go +++ b/zitadel/v2/machine_user/const.go @@ -8,6 +8,7 @@ const ( loginNamesVar = "login_names" preferredLoginNameVar = "preferred_login_name" - nameVar = "name" - descriptionVar = "description" + nameVar = "name" + descriptionVar = "description" + accessTokenTypeVar = "access_token_type" ) diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index deee8018..7e188ac3 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -50,6 +50,11 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "Description of the user", }, + accessTokenTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "Access token type of the user", + }, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 2fa45eea..29e1d0e5 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -47,9 +48,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } respUser, err := client.AddMachineUser(ctx, &management.AddMachineUserRequest{ - UserName: d.Get(userNameVar).(string), - Name: d.Get(nameVar).(string), - Description: d.Get(descriptionVar).(string), + UserName: d.Get(userNameVar).(string), + Name: d.Get(nameVar).(string), + Description: d.Get(descriptionVar).(string), + AccessTokenType: user.AccessTokenType(user.AccessTokenType_value[(d.Get(accessTokenTypeVar).(string))]), }) if err != nil { return diag.Errorf("failed to create machine user: %v", err) @@ -81,11 +83,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChanges(nameVar, descriptionVar) { + if d.HasChanges(nameVar, descriptionVar, accessTokenTypeVar) { _, err := client.UpdateMachine(ctx, &management.UpdateMachineRequest{ - UserId: d.Id(), - Name: d.Get(nameVar).(string), - Description: d.Get(descriptionVar).(string), + UserId: d.Id(), + Name: d.Get(nameVar).(string), + Description: d.Get(descriptionVar).(string), + AccessTokenType: user.AccessTokenType(user.AccessTokenType_value[(d.Get(accessTokenTypeVar).(string))]), }) if err != nil { return diag.Errorf("failed to update machine user: %v", err) @@ -127,6 +130,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if machine := user.GetMachine(); machine != nil { set[nameVar] = machine.GetName() set[descriptionVar] = machine.GetDescription() + set[accessTokenTypeVar] = machine.GetAccessTokenType().String() } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index ac397cc2..0888fe01 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -51,6 +51,11 @@ func GetResource() *schema.Resource { Optional: true, Description: "Description of the user", }, + accessTokenTypeVar: { + Type: schema.TypeString, + Optional: true, + Description: "Access token type of the user", + }, }, ReadContext: read, CreateContext: create, From 72e872b6d0aef84129f0721376dc923434f64737 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Thu, 23 Mar 2023 22:14:01 +0900 Subject: [PATCH 066/260] fix: validate ACCESS_TOKEN_TYPE --- zitadel/v2/machine_user/datasource.go | 12 ++++++++++-- zitadel/v2/machine_user/resource.go | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index 7e188ac3..b5d269bb 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -1,6 +1,10 @@ package machine_user -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" +) func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -53,7 +57,11 @@ func GetDatasource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Computed: true, - Description: "Access token type of the user", + Description: "Access token type of the user, (enum; ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT)", + ValidateFunc: validation.StringInSlice([]string{ + user.AccessTokenType_ACCESS_TOKEN_TYPE_BEARER.String(), + user.AccessTokenType_ACCESS_TOKEN_TYPE_JWT.String(), + }, false), }, }, ReadContext: read, diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 0888fe01..a03a7d35 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -2,6 +2,8 @@ package machine_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" ) func GetResource() *schema.Resource { @@ -54,7 +56,11 @@ func GetResource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Access token type of the user", + Description: "Access token type of the user, (enum; ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT)", + ValidateFunc: validation.StringInSlice([]string{ + user.AccessTokenType_ACCESS_TOKEN_TYPE_BEARER.String(), + user.AccessTokenType_ACCESS_TOKEN_TYPE_JWT.String(), + }, false), }, }, ReadContext: read, From 0a91548e6246e724be4ada7f283c068d68224ebd Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Fri, 24 Mar 2023 09:27:26 +0900 Subject: [PATCH 067/260] fix: use EnumValueValidation from helper --- zitadel/v2/machine_user/datasource.go | 15 +++------------ zitadel/v2/machine_user/resource.go | 13 +++++++------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index b5d269bb..b0977bf9 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -1,10 +1,6 @@ package machine_user -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" -) +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -57,13 +53,8 @@ func GetDatasource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Computed: true, - Description: "Access token type of the user, (enum; ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT)", - ValidateFunc: validation.StringInSlice([]string{ - user.AccessTokenType_ACCESS_TOKEN_TYPE_BEARER.String(), - user.AccessTokenType_ACCESS_TOKEN_TYPE_JWT.String(), - }, false), - }, - }, + Description: "Access token type", + }}, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index a03a7d35..5f9d1b79 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -1,8 +1,10 @@ package machine_user import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" ) @@ -56,11 +58,10 @@ func GetResource() *schema.Resource { accessTokenTypeVar: { Type: schema.TypeString, Optional: true, - Description: "Access token type of the user, (enum; ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT)", - ValidateFunc: validation.StringInSlice([]string{ - user.AccessTokenType_ACCESS_TOKEN_TYPE_BEARER.String(), - user.AccessTokenType_ACCESS_TOKEN_TYPE_JWT.String(), - }, false), + Description: "Access token type" + helper.DescriptionEnumValuesList(user.AccessTokenType_name), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(accessTokenTypeVar, value, user.AccessTokenType_value) + }, }, }, ReadContext: read, From 35a0d31b82403b6ba36546eaf17c146a87818153 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Mon, 27 Mar 2023 09:53:16 +0200 Subject: [PATCH 068/260] fix: generate docs and minor fix on the enum helper function --- docs/data-sources/machine_user.md | 1 + docs/index.md | 16 +++++++++------- docs/resources/machine_user.md | 1 + docs/resources/trigger_actions.md | 4 ++-- examples/provider/provider.tf | 14 +++++++------- zitadel/v2/helper/helper.go | 6 ++++-- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md index 96813d99..da5576ef 100644 --- a/docs/data-sources/machine_user.md +++ b/docs/data-sources/machine_user.md @@ -32,6 +32,7 @@ output machine_user { ### Read-Only +- `access_token_type` (String) Access token type - `description` (String) Description of the user - `id` (String) The ID of this resource. - `login_names` (List of String) Loginnames diff --git a/docs/index.md b/docs/index.md index 6300fe95..8a6fc06e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,17 +31,17 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.7" + version = "1.0.0-alpha.14" } } } provider zitadel { - domain = "localhost" - insecure = "true" - port = "8080" - project = "170832731415117995" - token = "local-token" + domain = "localhost" + insecure = "true" + port = "8080" + project = "170832731415117995" + jwt_profile_file = "local-token" } ``` @@ -51,12 +51,14 @@ provider zitadel { ### Required - `domain` (String) Domain used to connect to the ZITADEL instance -- `token` (String) Path to the file containing credentials to connect to ZITADEL ### Optional - `insecure` (Boolean) Use insecure connection +- `jwt_profile_file` (String) Path to the file containing credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required +- `jwt_profile_json` (String) JSON value of credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required - `port` (String) Used port if not the default ports 80 or 443 are configured +- `token` (String) Path to the file containing credentials to connect to ZITADEL ## Limitations diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index daa664f5..d6b7ed04 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -31,6 +31,7 @@ resource zitadel_machine_user machine_user { ### Optional +- `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT - `description` (String) Description of the user ### Read-Only diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index 1473cd52..e7bf14e6 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -26,9 +26,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_UNSPECIFIED, FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_UNSPECIFIED, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION ### Read-Only diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 8398e889..7a204d98 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,15 +2,15 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.7" + version = "1.0.0-alpha.14" } } } provider zitadel { - domain = "localhost" - insecure = "true" - port = "8080" - project = "170832731415117995" - token = "local-token" -} \ No newline at end of file + domain = "localhost" + insecure = "true" + port = "8080" + project = "170832731415117995" + jwt_profile_file = "local-token" +} diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index 85a54e52..df6ee2d7 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -124,8 +124,10 @@ func GetStringFromAttr(ctx context.Context, attrs map[string]attr.Value, key str func DescriptionEnumValuesList(enum map[int32]string) string { str := ", supported values: " values := make([]string, len(enum)) - for i := 0; i < len(enum); i++ { - values[i] = enum[int32(i)] + i := 0 + for k := range enum { + values[i] = enum[k] + i++ } str += strings.Join(values, ", ") return str From 6938d3fd56ef74774b1d76b25729a9a6a0f09b63 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 5 Apr 2023 18:41:00 +0200 Subject: [PATCH 069/260] fix: correct enum values for trigger types --- zitadel/v2/trigger_actions/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index b0e2bea5..364efdbb 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -65,7 +65,7 @@ func triggerTypes() map[int32]string { 1: "TRIGGER_TYPE_POST_AUTHENTICATION", 2: "TRIGGER_TYPE_PRE_CREATION", 3: "TRIGGER_TYPE_POST_CREATION", - 4: "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION", - 5: "TRIGGER_TYPE_PRE_USERINFO_CREATION", + 4: "TRIGGER_TYPE_PRE_USERINFO_CREATION", + 5: "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION", } } From 4d7f74ee58a2f78c3e0ca32057842d6e051ca271 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 6 Apr 2023 08:48:05 +0200 Subject: [PATCH 070/260] docs: generate docs --- docs/resources/application_oidc.md | 6 +++--- docs/resources/trigger_actions.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 3569be6b..15613ef7 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -39,7 +39,7 @@ resource zitadel_application_oidc application_oidc { ### Required -- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN +- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project @@ -51,8 +51,8 @@ resource zitadel_application_oidc application_oidc { - `access_token_role_assertion` (Boolean) Access token role assertion - `access_token_type` (String) Access token type, supported values: OIDC_TOKEN_TYPE_BEARER, OIDC_TOKEN_TYPE_JWT - `additional_origins` (List of String) Additional origins -- `app_type` (String) App type, supported values: OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT, OIDC_APP_TYPE_NATIVE -- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_BASIC, OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE, OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT +- `app_type` (String) App type, supported values: OIDC_APP_TYPE_NATIVE, OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT +- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, OIDC_AUTH_METHOD_TYPE_BASIC, OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE - `clock_skew` (String) Clockskew - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index e7bf14e6..07e7e075 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -28,7 +28,7 @@ resource zitadel_trigger_actions trigger_actions { - `action_ids` (Set of String) IDs of the triggered actions - `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION ### Read-Only From c31bae84f806881f3886a8fb9ac0f9fe01454828 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 6 Apr 2023 14:41:23 +0200 Subject: [PATCH 071/260] fix: handling of default values for project and machine user --- docs/resources/machine_user.md | 2 +- docs/resources/project.md | 2 +- docs/resources/trigger_actions.md | 4 ++-- zitadel/v2/machine_user/const.go | 8 ++++++++ zitadel/v2/machine_user/resource.go | 4 +++- zitadel/v2/project/const.go | 6 ++++++ zitadel/v2/project/resource.go | 1 + 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index d6b7ed04..edfadb3c 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -31,7 +31,7 @@ resource zitadel_machine_user machine_user { ### Optional -- `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT +- `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_JWT, ACCESS_TOKEN_TYPE_BEARER - `description` (String) Description of the user ### Read-Only diff --git a/docs/resources/project.md b/docs/resources/project.md index 88612eea..01a04552 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -33,7 +33,7 @@ resource zitadel_project project { ### Optional - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project -- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY - `project_role_assertion` (Boolean) describes if roles of user should be added in token - `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index e7bf14e6..98f5271b 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -26,9 +26,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_INTERNAL_AUTHENTICATION, FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION, TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION ### Read-Only diff --git a/zitadel/v2/machine_user/const.go b/zitadel/v2/machine_user/const.go index 904cd8ed..4d077e54 100644 --- a/zitadel/v2/machine_user/const.go +++ b/zitadel/v2/machine_user/const.go @@ -1,5 +1,9 @@ package machine_user +import ( + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" +) + const ( userIDVar = "user_id" orgIDVar = "org_id" @@ -12,3 +16,7 @@ const ( descriptionVar = "description" accessTokenTypeVar = "access_token_type" ) + +var ( + defaultAccessTokenType = user.AccessTokenType_name[0] +) diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 5f9d1b79..9765085d 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -4,8 +4,9 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -62,6 +63,7 @@ func GetResource() *schema.Resource { ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(accessTokenTypeVar, value, user.AccessTokenType_value) }, + Default: defaultAccessTokenType, }, }, ReadContext: read, diff --git a/zitadel/v2/project/const.go b/zitadel/v2/project/const.go index 2c66d4df..a623d19f 100644 --- a/zitadel/v2/project/const.go +++ b/zitadel/v2/project/const.go @@ -1,5 +1,7 @@ package project +import "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + const ( projectIDVar = "project_id" nameVar = "name" @@ -10,3 +12,7 @@ const ( hasProjectCheckVar = "has_project_check" privateLabelingSettingVar = "private_labeling_setting" ) + +var ( + defaultPrivateLabelingSetting = project.PrivateLabelingSetting_name[0] +) diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index caa867d6..5b5bba34 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -54,6 +54,7 @@ func GetResource() *schema.Resource { ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { return helper.EnumValueValidation(privateLabelingSettingVar, value, project.PrivateLabelingSetting_value) }, + Default: defaultPrivateLabelingSetting, }, }, DeleteContext: delete, From b531a7116674ad58f8b4145465357abf7487fd37 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 6 Apr 2023 16:49:54 +0200 Subject: [PATCH 072/260] fix: handling of default ports of schemas in clientinfo --- zitadel/v2/helper/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index e49f6b1d..7be1034b 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -44,12 +44,12 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st return nil, fmt.Errorf("either 'jwt_profile_file' or 'jwt_profile_json' is required") } - issuer := "" - if port != "" { + issuer := domain + //issuer only contains the port if it's not the default port of the schema + if port != "" && !(insecure && port == "80") && !(!insecure && port == "443") { domain = domain + ":" + port issuer = domain } else { - issuer = domain if insecure { domain = domain + ":80" } else { From 300e364ad4bbb7d22b8ff25e25893817a7c27046 Mon Sep 17 00:00:00 2001 From: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> Date: Tue, 11 Apr 2023 07:48:34 -0500 Subject: [PATCH 073/260] Add support for modifying the password change email message text Signed-off-by: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> --- .../default_password_change_message_text.md | 48 ++++ .../resources/password_change_message_text.md | 50 ++++ .../default_password_change_message_text.tf | 11 + .../resources/password_change_message_text.tf | 12 + zitadel/provider.go | 4 + .../resource.go | 235 ++++++++++++++++ .../password_change_message_text/resource.go | 253 ++++++++++++++++++ 7 files changed, 613 insertions(+) create mode 100644 docs/resources/default_password_change_message_text.md create mode 100644 docs/resources/password_change_message_text.md create mode 100644 examples/provider/resources/default_password_change_message_text.tf create mode 100644 examples/provider/resources/password_change_message_text.tf create mode 100644 zitadel/v2/default_password_change_message_text/resource.go create mode 100644 zitadel/v2/password_change_message_text/resource.go diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md new file mode 100644 index 00000000..2ec195dc --- /dev/null +++ b/docs/resources/default_password_change_message_text.md @@ -0,0 +1,48 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_default_password_change_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_password_change_message_text (Resource) + + +## Example Usage + +```terraform +resource zitadel_default_password_change_message_text password_change_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md new file mode 100644 index 00000000..be8a789e --- /dev/null +++ b/docs/resources/password_change_message_text.md @@ -0,0 +1,50 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_password_change_message_text Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_password_change_message_text (Resource) + + +## Example Usage + +```terraform +resource zitadel_password_change_message_text password_change_en { + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` + + + +## Schema + +### Required + +- `language` (String) +- `org_id` (String) + +### Optional + +- `button_text` (String) +- `footer_text` (String) +- `greeting` (String) +- `pre_header` (String) +- `subject` (String) +- `text` (String) +- `title` (String) + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/examples/provider/resources/default_password_change_message_text.tf b/examples/provider/resources/default_password_change_message_text.tf new file mode 100644 index 00000000..e54125a8 --- /dev/null +++ b/examples/provider/resources/default_password_change_message_text.tf @@ -0,0 +1,11 @@ +resource zitadel_default_password_change_message_text password_change_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} diff --git a/examples/provider/resources/password_change_message_text.tf b/examples/provider/resources/password_change_message_text.tf new file mode 100644 index 00000000..abfbb1f0 --- /dev/null +++ b/examples/provider/resources/password_change_message_text.tf @@ -0,0 +1,12 @@ +resource zitadel_password_change_message_text password_change_en { + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} diff --git a/zitadel/provider.go b/zitadel/provider.go index a3ca958c..73473b15 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -23,6 +23,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_notification_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_change_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" @@ -47,6 +48,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_change_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_reset_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/passwordless_registration_message_text" @@ -159,6 +161,7 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { init_message_text.New, login_texts.New, password_reset_message_text.New, + password_change_message_text.New, verify_email_message_text.New, verify_phone_message_text.New, domain_claimed_message_text.New, @@ -166,6 +169,7 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { default_domain_claimed_message_text.New, default_init_message_text.New, default_password_reset_message_text.New, + default_password_change_message_text.New, default_passwordless_registration_message_text.New, default_verify_email_message_text.New, default_verify_phone_message_text.New, diff --git a/zitadel/v2/default_password_change_message_text/resource.go b/zitadel/v2/default_password_change_message_text/resource.go new file mode 100644 index 00000000..74224153 --- /dev/null +++ b/zitadel/v2/default_password_change_message_text/resource.go @@ -0,0 +1,235 @@ +package default_password_change_message_text + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultPasswordChangeMessageTextResource{} +) + +func New() resource.Resource { + return &defaultPasswordChangeMessageTextResource{} +} + +type defaultPasswordChangeMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultPasswordChangeMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_password_change_message_text" +} + +func (r *defaultPasswordChangeMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaMessageCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultPasswordChangeMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultPasswordChangeMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordChangeMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordChangeMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordChangeMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordChangeMessageText(ctx, &admin.GetCustomPasswordChangeMessageTextRequest{Language: language}) + if err != nil { + return + } + if zResp.CustomText.IsDefault { + return + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultPasswordChangeMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &admin.SetDefaultPasswordChangeMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetDefaultPasswordChangeMessageText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultPasswordChangeMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordChangeMessageTextToDefault(ctx, &admin.ResetCustomPasswordChangeMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/v2/password_change_message_text/resource.go new file mode 100644 index 00000000..c878455e --- /dev/null +++ b/zitadel/v2/password_change_message_text/resource.go @@ -0,0 +1,253 @@ +package password_change_message_text + +import ( + "context" + "strings" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + orgIDVar = "org_id" + languageVar = "language" +) + +var ( + _ resource.Resource = &passwordChangeMessageTextResource{} +) + +func New() resource.Resource { + return &passwordChangeMessageTextResource{} +} + +type passwordChangeMessageTextResource struct { + clientInfo *helper.ClientInfo +} + +func (r *passwordChangeMessageTextResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_password_change_message_text" +} + +func (r *passwordChangeMessageTextResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return text.GenSchemaMessageCustomText(ctx) +} + +func (r *passwordChangeMessageTextResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *passwordChangeMessageTextResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordChangeMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordChangeMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordChangeMessageTextResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + orgID, language := getID(ctx, state) + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomPasswordChangeMessageText(ctx, &management.GetCustomPasswordChangeMessageTextRequest{Language: language}) + if err != nil { + return + } + if zResp.CustomText.IsDefault { + return + } + + resp.Diagnostics.Append(text.CopyMessageCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *passwordChangeMessageTextResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + orgID, language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.MessageCustomText{} + resp.Diagnostics.Append(text.CopyMessageCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal", err.Error()) + return + } + zReq := &management.SetCustomPasswordChangeMessageTextRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomPasswordChangeMessageCustomText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update", err.Error()) + return + } + + setID(plan, orgID, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *passwordChangeMessageTextResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + orgID, language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetManagementClient(r.clientInfo, orgID) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomPasswordChangeMessageTextToDefault(ctx, &management.ResetCustomPasswordChangeMessageTextToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete", err.Error()) + return + } +} + +func setID(obj types.Object, orgID string, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(orgID + "_" + language) + attrs[orgIDVar] = types.StringValue(orgID) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) (string, string) { + id := helper.GetStringFromAttr(ctx, obj.Attributes(), "id") + parts := strings.Split(id, "_") + if len(parts) == 2 { + return parts[0], parts[1] + } + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { + var orgID string + diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + if diag.HasError() { + return "", "" + } + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "", "" + } + + return orgID, language +} From d1723ba218dad0fcd615b05f72a518973b28d3f5 Mon Sep 17 00:00:00 2001 From: TakumiHaruta Date: Fri, 24 Mar 2023 14:38:15 +0900 Subject: [PATCH 074/260] feat: add default login texts --- zitadel/provider.go | 2 + zitadel/v2/default_login_texts/resource.go | 235 +++++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 zitadel/v2/default_login_texts/resource.go diff --git a/zitadel/provider.go b/zitadel/provider.go index a3ca958c..e81c49f3 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -22,6 +22,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_texts" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_notification_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" @@ -165,6 +166,7 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { passwordless_registration_message_text.New, default_domain_claimed_message_text.New, default_init_message_text.New, + default_login_texts.New, default_password_reset_message_text.New, default_passwordless_registration_message_text.New, default_verify_email_message_text.New, diff --git a/zitadel/v2/default_login_texts/resource.go b/zitadel/v2/default_login_texts/resource.go new file mode 100644 index 00000000..3a60a1d9 --- /dev/null +++ b/zitadel/v2/default_login_texts/resource.go @@ -0,0 +1,235 @@ +package default_login_texts + +import ( + "context" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/encoding/protojson" + + textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + + "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + languageVar = "language" +) + +var ( + _ resource.Resource = &defaultLoginTextsResource{} +) + +func New() resource.Resource { + return &defaultLoginTextsResource{} +} + +type defaultLoginTextsResource struct { + clientInfo *helper.ClientInfo +} + +func (r *defaultLoginTextsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_default_login_texts" +} + +func (r *defaultLoginTextsResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + s, d := text.GenSchemaLoginCustomText(ctx) + delete(s.Attributes, "org_id") + return s, d +} + +func (r *defaultLoginTextsResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.clientInfo = req.ProviderData.(*helper.ClientInfo) +} + +func (r *defaultLoginTextsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.LoginCustomText{} + resp.Diagnostics.Append(text.CopyLoginCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal login texts", err.Error()) + return + } + zReq := &admin.SetCustomLoginTextsRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal login texts", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomLoginText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to create login texts", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultLoginTextsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + language := getID(ctx, state) + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + zResp, err := client.GetCustomLoginTexts(ctx, &admin.GetCustomLoginTextsRequest{Language: language}) + if err != nil { + return + } + if zResp.CustomText.IsDefault { + return + } + + resp.Diagnostics.Append(text.CopyLoginCustomTextToTerraform(ctx, *zResp.CustomText, &state)...) + if resp.Diagnostics.HasError() { + return + } + + setID(state, language) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *defaultLoginTextsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + language := getPlanAttrs(ctx, req.Plan, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + var plan types.Object + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + obj := textpb.LoginCustomText{} + resp.Diagnostics.Append(text.CopyLoginCustomTextFromTerraform(ctx, plan, &obj)...) + if resp.Diagnostics.HasError() { + return + } + + jsonpb := &runtime.JSONPb{ + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + } + data, err := jsonpb.Marshal(obj) + if err != nil { + resp.Diagnostics.AddError("failed to marshal login texts", err.Error()) + return + } + zReq := &admin.SetCustomLoginTextsRequest{} + if err := jsonpb.Unmarshal(data, zReq); err != nil { + resp.Diagnostics.AddError("failed to unmarshal login texts", err.Error()) + return + } + zReq.Language = language + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.SetCustomLoginText(ctx, zReq) + if err != nil { + resp.Diagnostics.AddError("failed to update login texts", err.Error()) + return + } + + setID(plan, language) + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) +} + +func (r *defaultLoginTextsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + language := getStateAttrs(ctx, req.State, resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + client, err := helper.GetAdminClient(r.clientInfo) + if err != nil { + resp.Diagnostics.AddError("failed to get client", err.Error()) + return + } + + _, err = client.ResetCustomLoginTextToDefault(ctx, &admin.ResetCustomLoginTextsToDefaultRequest{Language: language}) + if err != nil { + resp.Diagnostics.AddError("failed to delete login texts", err.Error()) + return + } +} + +func setID(obj types.Object, language string) { + attrs := obj.Attributes() + attrs["id"] = types.StringValue(language) + attrs[languageVar] = types.StringValue(language) +} + +func getID(ctx context.Context, obj types.Object) string { + return helper.GetStringFromAttr(ctx, obj.Attributes(), "id") +} + +func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { + var language string + diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} + +func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { + var language string + diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + if diag.HasError() { + return "" + } + return language +} From 6a9a7f6e8f7e4a185d92d987a3d89df0396e5da3 Mon Sep 17 00:00:00 2001 From: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> Date: Tue, 11 Apr 2023 23:03:41 -0500 Subject: [PATCH 075/260] Add docs and examples for new resource Signed-off-by: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> --- docs/resources/default_login_texts.md | 811 ++++++++++++++++++ .../provider/resources/default_login_texts.tf | 291 +++++++ 2 files changed, 1102 insertions(+) create mode 100644 docs/resources/default_login_texts.md create mode 100644 examples/provider/resources/default_login_texts.tf diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md new file mode 100644 index 00000000..db08f05d --- /dev/null +++ b/docs/resources/default_login_texts.md @@ -0,0 +1,811 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "zitadel_default_login_texts Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + +--- + +# zitadel_default_login_texts (Resource) + + +## Example Usage + +```terraform +resource zitadel_default_login_texts login_texts_en { + language = "en" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "example" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +} +``` + + + + +## Schema + +### Required + +- `language` (String) + +### Optional + +- `email_verification_done_text` (Attributes) (see [below for nested schema](#nestedatt--email_verification_done_text)) +- `email_verification_text` (Attributes) (see [below for nested schema](#nestedatt--email_verification_text)) +- `external_registration_user_overview_text` (Attributes) (see [below for nested schema](#nestedatt--external_registration_user_overview_text)) +- `external_user_not_found_text` (Attributes) (see [below for nested schema](#nestedatt--external_user_not_found_text)) +- `footer_text` (Attributes) (see [below for nested schema](#nestedatt--footer_text)) +- `init_mfa_done_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_done_text)) +- `init_mfa_otp_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_otp_text)) +- `init_mfa_prompt_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_prompt_text)) +- `init_mfa_u2f_text` (Attributes) (see [below for nested schema](#nestedatt--init_mfa_u2f_text)) +- `init_password_done_text` (Attributes) (see [below for nested schema](#nestedatt--init_password_done_text)) +- `init_password_text` (Attributes) (see [below for nested schema](#nestedatt--init_password_text)) +- `initialize_done_text` (Attributes) (see [below for nested schema](#nestedatt--initialize_done_text)) +- `initialize_user_text` (Attributes) (see [below for nested schema](#nestedatt--initialize_user_text)) +- `linking_user_done_text` (Attributes) (see [below for nested schema](#nestedatt--linking_user_done_text)) +- `login_text` (Attributes) (see [below for nested schema](#nestedatt--login_text)) +- `logout_text` (Attributes) (see [below for nested schema](#nestedatt--logout_text)) +- `mfa_providers_text` (Attributes) (see [below for nested schema](#nestedatt--mfa_providers_text)) +- `password_change_done_text` (Attributes) (see [below for nested schema](#nestedatt--password_change_done_text)) +- `password_change_text` (Attributes) (see [below for nested schema](#nestedatt--password_change_text)) +- `password_reset_done_text` (Attributes) (see [below for nested schema](#nestedatt--password_reset_done_text)) +- `password_text` (Attributes) (see [below for nested schema](#nestedatt--password_text)) +- `passwordless_prompt_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_prompt_text)) +- `passwordless_registration_done_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_registration_done_text)) +- `passwordless_registration_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_registration_text)) +- `passwordless_text` (Attributes) (see [below for nested schema](#nestedatt--passwordless_text)) +- `registration_option_text` (Attributes) (see [below for nested schema](#nestedatt--registration_option_text)) +- `registration_org_text` (Attributes) (see [below for nested schema](#nestedatt--registration_org_text)) +- `registration_user_text` (Attributes) (see [below for nested schema](#nestedatt--registration_user_text)) +- `select_account_text` (Attributes) (see [below for nested schema](#nestedatt--select_account_text)) +- `success_login_text` (Attributes) (see [below for nested schema](#nestedatt--success_login_text)) +- `username_change_done_text` (Attributes) (see [below for nested schema](#nestedatt--username_change_done_text)) +- `username_change_text` (Attributes) (see [below for nested schema](#nestedatt--username_change_text)) +- `verify_mfa_otp_text` (Attributes) (see [below for nested schema](#nestedatt--verify_mfa_otp_text)) +- `verify_mfa_u2f_text` (Attributes) (see [below for nested schema](#nestedatt--verify_mfa_u2f_text)) + +### Read-Only + +- `id` (String) The ID of this resource. + + +### Nested Schema for `email_verification_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `login_button_text` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `email_verification_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `external_registration_user_overview_text` + +Optional: + +- `back_button_text` (String) +- `description` (String) +- `email_label` (String) +- `firstname_label` (String) +- `language_label` (String) +- `lastname_label` (String) +- `next_button_text` (String) +- `nickname_label` (String) +- `phone_label` (String) +- `privacy_confirm` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `external_user_not_found_text` + +Optional: + +- `auto_register_button_text` (String) +- `description` (String) +- `link_button_text` (String) +- `privacy_confirm` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_link_text` (String) + + + +### Nested Schema for `footer_text` + +Optional: + +- `help` (String) +- `privacy_policy` (String) +- `tos` (String) + + + +### Nested Schema for `init_mfa_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `init_mfa_otp_text` + +Optional: + +- `cancel_button_text` (String) +- `code_label` (String) +- `description` (String) +- `description_otp` (String) +- `next_button_text` (String) +- `secret_label` (String) +- `title` (String) + + + +### Nested Schema for `init_mfa_prompt_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `otp_option` (String) +- `skip_button_text` (String) +- `title` (String) +- `u2f_option` (String) + + + +### Nested Schema for `init_mfa_u2f_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `register_token_button_text` (String) +- `title` (String) +- `token_name_label` (String) + + + +### Nested Schema for `init_password_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `init_password_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `initialize_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `initialize_user_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `resend_button_text` (String) +- `title` (String) + + + +### Nested Schema for `linking_user_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `login_text` + +Optional: + +- `description` (String) +- `description_linking_process` (String) +- `external_user_description` (String) +- `login_name_label` (String) +- `login_name_placeholder` (String) +- `next_button_text` (String) +- `register_button_text` (String) +- `title` (String) +- `title_linking_process` (String) +- `user_must_be_member_of_org` (String) +- `user_name_placeholder` (String) + + + +### Nested Schema for `logout_text` + +Optional: + +- `description` (String) +- `login_button_text` (String) +- `title` (String) + + + +### Nested Schema for `mfa_providers_text` + +Optional: + +- `choose_other` (String) +- `otp` (String) +- `u2f` (String) + + + +### Nested Schema for `password_change_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `password_change_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `new_password_confirm_label` (String) +- `new_password_label` (String) +- `next_button_text` (String) +- `old_password_label` (String) +- `title` (String) + + + +### Nested Schema for `password_reset_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `password_text` + +Optional: + +- `back_button_text` (String) +- `confirmation` (String) +- `description` (String) +- `has_lowercase` (String) +- `has_number` (String) +- `has_symbol` (String) +- `has_uppercase` (String) +- `min_length` (String) +- `next_button_text` (String) +- `password_label` (String) +- `reset_link_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_prompt_text` + +Optional: + +- `description` (String) +- `description_init` (String) +- `next_button_text` (String) +- `passwordless_button_text` (String) +- `skip_button_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_registration_done_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `description_close` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `passwordless_registration_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `register_token_button_text` (String) +- `title` (String) +- `token_name_label` (String) + + + +### Nested Schema for `passwordless_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `login_with_pw_button_text` (String) +- `not_supported` (String) +- `title` (String) +- `validate_token_button_text` (String) + + + +### Nested Schema for `registration_option_text` + +Optional: + +- `description` (String) +- `external_login_description` (String) +- `login_button_text` (String) +- `title` (String) +- `user_name_button_text` (String) + + + +### Nested Schema for `registration_org_text` + +Optional: + +- `description` (String) +- `email_label` (String) +- `firstname_label` (String) +- `lastname_label` (String) +- `orgname_label` (String) +- `password_confirm_label` (String) +- `password_label` (String) +- `privacy_confirm` (String) +- `privacy_link_text` (String) +- `save_button_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `registration_user_text` + +Optional: + +- `back_button_text` (String) +- `description` (String) +- `description_org_register` (String) +- `email_label` (String) +- `firstname_label` (String) +- `gender_label` (String) +- `language_label` (String) +- `lastname_label` (String) +- `next_button_text` (String) +- `password_confirm_label` (String) +- `password_label` (String) +- `privacy_confirm` (String) +- `privacy_link_text` (String) +- `title` (String) +- `tos_and_privacy_label` (String) +- `tos_confirm` (String) +- `tos_link_text` (String) +- `username_label` (String) + + + +### Nested Schema for `select_account_text` + +Optional: + +- `description` (String) +- `description_linking_process` (String) +- `other_user` (String) +- `session_state_active` (String) +- `session_state_inactive` (String) +- `title` (String) +- `title_linking_process` (String) +- `user_must_be_member_of_org` (String) + + + +### Nested Schema for `success_login_text` + +Optional: + +- `auto_redirect_description` (String) Text to describe that auto-redirect should happen after successful login +- `next_button_text` (String) +- `redirected_description` (String) Text to describe that the window can be closed after redirect +- `title` (String) + + + +### Nested Schema for `username_change_done_text` + +Optional: + +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `username_change_text` + +Optional: + +- `cancel_button_text` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) +- `username_label` (String) + + + +### Nested Schema for `verify_mfa_otp_text` + +Optional: + +- `code_label` (String) +- `description` (String) +- `next_button_text` (String) +- `title` (String) + + + +### Nested Schema for `verify_mfa_u2f_text` + +Optional: + +- `description` (String) +- `error_retry` (String) +- `not_supported` (String) +- `title` (String) +- `validate_token_text` (String) diff --git a/examples/provider/resources/default_login_texts.tf b/examples/provider/resources/default_login_texts.tf new file mode 100644 index 00000000..e0b9ff47 --- /dev/null +++ b/examples/provider/resources/default_login_texts.tf @@ -0,0 +1,291 @@ +resource zitadel_default_login_texts login_texts_en { + language = "en" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "example" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +} + From bb1cbe31adc6657db9c8407f4336ba15bdcac2c9 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 12 Apr 2023 06:54:26 +0200 Subject: [PATCH 076/260] unmutated variables --- zitadel/v2/helper/client.go | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 7be1034b..f364bf6a 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -44,28 +44,32 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st return nil, fmt.Errorf("either 'jwt_profile_file' or 'jwt_profile_json' is required") } - issuer := domain - //issuer only contains the port if it's not the default port of the schema - if port != "" && !(insecure && port == "80") && !(!insecure && port == "443") { - domain = domain + ":" + port - issuer = domain - } else { - if insecure { - domain = domain + ":80" - } else { - domain = domain + ":443" - } - } - + issuerScheme := "https" if insecure { options = append(options, zitadel.WithInsecure()) - issuer = "http://" + issuer - } else { - issuer = "https://" + issuer + issuerScheme = "http" + } + + issuerPort := port + if port == "80" && insecure || port == "443" && !insecure { + issuerPort = "" + } + + issuer := issuerScheme + domain + ":" + issuerPort + if issuerPort == "" { + issuer = issuerScheme + domain + } + + clientDomain := domain + ":" + port + if port == "" { + clientDomain = domain + ":443" + if insecure { + clientDomain = domain + ":80" + } } return &ClientInfo{ - domain, + clientDomain, issuer, keyPath, []byte(jwtProfileJSON), From d9c737df54516eb5b1cf9ab5f2f206525c59252c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 12 Apr 2023 07:02:09 +0200 Subject: [PATCH 077/260] fix scheme --- zitadel/v2/helper/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index f364bf6a..e318c793 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -44,10 +44,10 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st return nil, fmt.Errorf("either 'jwt_profile_file' or 'jwt_profile_json' is required") } - issuerScheme := "https" + issuerScheme := "https://" if insecure { options = append(options, zitadel.WithInsecure()) - issuerScheme = "http" + issuerScheme = "http://" } issuerPort := port From 7c76d65ec265f977898bf2435b6c772c39f5130f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 14 Apr 2023 02:30:47 +0200 Subject: [PATCH 078/260] feat: add zitadel_org_idp_github --- go.mod | 22 ++-- go.sum | 45 +++++---- zitadel/provider.go | 3 + zitadel/v2/login_policy/funcs.go | 44 +++++--- zitadel/v2/org_idp_github/const.go | 14 +++ zitadel/v2/org_idp_github/datasource.go | 70 +++++++++++++ zitadel/v2/org_idp_github/funcs.go | 129 ++++++++++++++++++++++++ zitadel/v2/org_idp_github/resource.go | 69 +++++++++++++ 8 files changed, 352 insertions(+), 44 deletions(-) create mode 100644 zitadel/v2/org_idp_github/const.go create mode 100644 zitadel/v2/org_idp_github/datasource.go create mode 100644 zitadel/v2/org_idp_github/funcs.go create mode 100644 zitadel/v2/org_idp_github/resource.go diff --git a/go.mod b/go.mod index 86f56a75..2e449920 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/envoyproxy/protoc-gen-validate v0.9.1 github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-framework v0.15.0 @@ -14,11 +14,11 @@ require ( github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 - github.com/zitadel/oidc v1.12.1 - github.com/zitadel/zitadel-go/v2 v2.0.10 - golang.org/x/oauth2 v0.4.0 - google.golang.org/grpc v1.52.3 - google.golang.org/protobuf v1.28.1 + github.com/zitadel/oidc v1.13.2 + github.com/zitadel/zitadel-go/v2 v2.0.12 + golang.org/x/oauth2 v0.6.0 + google.golang.org/grpc v1.53.0 + google.golang.org/protobuf v1.30.0 ) require ( @@ -72,11 +72,11 @@ require ( github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.13.0 // indirect golang.org/x/crypto v0.5.0 // indirect - golang.org/x/mod v0.7.0 // indirect - golang.org/x/net v0.5.0 // indirect - golang.org/x/sys v0.4.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect + google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index 1bfebfc3..80ed7d8d 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -323,8 +323,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -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/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -347,10 +347,10 @@ github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0 github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.12.1 h1:f+NB+GnNhygzFulgRhsvxJAJnmfcgPTfFSIJmgBIGWw= -github.com/zitadel/oidc v1.12.1/go.mod h1:RSZbbTbwvbP6cXdw9sj/mjXWHSK+p9s2jqArOlk+81Q= -github.com/zitadel/zitadel-go/v2 v2.0.10 h1:gVV8DK0w4w+GQuazXdHpiwyMjeHPeSG5Uh4/rsY9gZ4= -github.com/zitadel/zitadel-go/v2 v2.0.10/go.mod h1:jErhzYaawlYz03EUYPSLHvH1SffvXJXKGbi4/aZQt34= +github.com/zitadel/oidc v1.13.2 h1:DiwAgHtw1kKcngNzLjgv1/oRL1OjdYf3emEsFzQzraI= +github.com/zitadel/oidc v1.13.2/go.mod h1:GUywRhXAiTvvjdRdXblmGknDOeMwrsdMxTRCypi6974= +github.com/zitadel/zitadel-go/v2 v2.0.12 h1:uLboL/Cx+1UG2evYiMNS7RHqkRbFOrooOBngbD2UN3A= +github.com/zitadel/zitadel-go/v2 v2.0.12/go.mod h1:pqPiKbTGSslWF7qv9T73zn/oK+AqTR/sq4MjbPRB0EQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -401,8 +401,9 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -438,16 +439,17 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= +golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -504,8 +506,9 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= 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/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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= @@ -516,10 +519,10 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -624,8 +627,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= -google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -638,8 +641,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ= -google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -652,8 +655,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/zitadel/provider.go b/zitadel/provider.go index a3ca958c..eb3efbcb 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -44,6 +44,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/notification_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" @@ -186,6 +187,7 @@ func Provider() *schema.Provider { "zitadel_trigger_actions": trigger_actions.GetDatasource(), "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), + "zitadel_org_idp_github": org_idp_github.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -247,6 +249,7 @@ func Provider() *schema.Provider { "zitadel_machine_key": machine_key.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), + "zitadel_org_idp_github": org_idp_github.GetResource(), "zitadel_default_label_policy": default_label_policy.GetResource(), "zitadel_default_login_policy": default_login_policy.GetResource(), "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 1510fdb3..05e5a101 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + mgmtclient "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" @@ -156,14 +157,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia addIdps, deleteIdps := helper.GetAddAndDelete(helper.SetToStringSlice(o.(*schema.Set)), helper.SetToStringSlice(n.(*schema.Set))) for _, addIdp := range addIdps { - var ownertype idp.IDPOwnerType - _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) + idpOwnerType, err := getIDPOwnerType(ctx, client, addIdp) if err != nil { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM - } else { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + return diag.FromErr(err) } - if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: idpOwnerType}); err != nil { return diag.FromErr(err) } } @@ -251,20 +249,42 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia idps := helper.GetOkSetToStringSlice(d, idpsVar) for _, addIdp := range idps { - var ownertype idp.IDPOwnerType - _, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: addIdp}) + idpOwnerType, err := getIDPOwnerType(ctx, client, addIdp) if err != nil { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM - } else { - ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_ORG + return diag.FromErr(err) } - if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: ownertype}); err != nil { + if _, err := client.AddIDPToLoginPolicy(ctx, &management.AddIDPToLoginPolicyRequest{IdpId: addIdp, OwnerType: idpOwnerType}); err != nil { return diag.FromErr(err) } } return nil } +func getIDPOwnerType(ctx context.Context, client *mgmtclient.Client, id string) (idp.IDPOwnerType, error) { + ownertype := idp.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED + templateProvider, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: id}) + err = helper.IgnoreIfNotFoundError(err) + if err != nil { + return idp.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED, err + } + ownertype = templateProvider.GetIdp().GetOwner() + if ownertype == idp.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED { + // Maybe it's a legacy provider + legacyProvider, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: id}) + err = helper.IgnoreIfNotFoundError(err) + if err != nil { + return idp.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED, err + } + ownertype = legacyProvider.GetIdp().GetOwner() + } + + if ownertype == idp.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED { + // If the IDP is still not found, the only possibility left is a legacy instance level provider + ownertype = idp.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM + } + return ownertype, nil +} + func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") diff --git a/zitadel/v2/org_idp_github/const.go b/zitadel/v2/org_idp_github/const.go new file mode 100644 index 00000000..1cc61c4a --- /dev/null +++ b/zitadel/v2/org_idp_github/const.go @@ -0,0 +1,14 @@ +package org_idp_github + +const ( + idpIDVar = "idp_id" + orgIDVar = "org_id" + nameVar = "name" + clientIDVar = "client_id" + clientSecretVar = "client_secret" + scopesVar = "scopes" + isLinkingAllowedVar = "is_linking_allowed" + isCreationAllowedVar = "is_creation_allowed" + isAutoCreationVar = "is_auto_creation" + isAutoUpdateVar = "is_auto_update" +) diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go new file mode 100644 index 00000000..5ef31b9d --- /dev/null +++ b/zitadel/v2/org_idp_github/datasource.go @@ -0,0 +1,70 @@ +package org_idp_github + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + idpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + clientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + Sensitive: true, + }, + clientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + scopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + isLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + isCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + isAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + isAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go new file mode 100644 index 00000000..310694a1 --- /dev/null +++ b/zitadel/v2/org_idp_github/funcs.go @@ -0,0 +1,129 @@ +package org_idp_github + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + _, err = client.DeleteProvider(ctx, &management.DeleteProviderRequest{ + Id: d.Id(), + }) + if err != nil { + return diag.Errorf("failed to delete idp: %v", err) + } + return nil +} + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitHubProvider(ctx, &management.AddGitHubProviderRequest{ + Name: d.Get(nameVar).(string), + ClientId: d.Get(clientIDVar).(string), + ClientSecret: d.Get(clientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, scopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(isLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(isCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(isAutoUpdateVar).(bool), + IsAutoCreation: d.Get(isAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChanges(nameVar, clientIDVar, clientSecretVar, scopesVar, isLinkingAllowedVar, isCreationAllowedVar, isAutoCreationVar, isAutoUpdateVar) { + _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ + Id: d.Id(), + Name: d.Get(nameVar).(string), + ClientId: d.Get(clientIDVar).(string), + ClientSecret: d.Get(clientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, scopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(isLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(isCreationAllowedVar).(bool), + IsAutoCreation: d.Get(isAutoCreationVar).(bool), + IsAutoUpdate: d.Get(isAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGithub() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + orgIDVar: idp.GetDetails().GetResourceOwner(), + nameVar: idp.GetName(), + clientIDVar: specificCfg.GetClientId(), + clientSecretVar: d.Get(clientSecretVar).(string), + scopesVar: specificCfg.GetScopes(), + isLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + isCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + isAutoCreationVar: generalCfg.GetIsAutoCreation(), + isAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go new file mode 100644 index 00000000..a74c5435 --- /dev/null +++ b/zitadel/v2/org_idp_github/resource.go @@ -0,0 +1,69 @@ +package org_idp_github + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP of the organization.", + Schema: map[string]*schema.Schema{ + orgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + nameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + clientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + Sensitive: true, + }, + clientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + scopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + isLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + isCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + isAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + isAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: delete, + Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + } +} From 94ba46eade2e091313fa63b52139cc503590d6d8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 14 Apr 2023 10:39:40 +0200 Subject: [PATCH 079/260] simplify issuer string building --- zitadel/v2/helper/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index e318c793..10b88512 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -55,9 +55,9 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st issuerPort = "" } - issuer := issuerScheme + domain + ":" + issuerPort - if issuerPort == "" { - issuer = issuerScheme + domain + issuer := issuerScheme + domain + if issuerPort != "" { + issuer = issuer + ":" + issuerPort } clientDomain := domain + ":" + port From 84ef92901be88adb3076ac31deb4008ba904b458 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 14 Apr 2023 10:42:54 +0200 Subject: [PATCH 080/260] use += --- zitadel/v2/helper/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 10b88512..f6c2c0b7 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -57,7 +57,7 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st issuer := issuerScheme + domain if issuerPort != "" { - issuer = issuer + ":" + issuerPort + issuer += issuerPort } clientDomain := domain + ":" + port From cace549eac2cc57f0ab9af074f715f6d3a8d7d7e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 14 Apr 2023 11:14:04 +0200 Subject: [PATCH 081/260] semicolon --- zitadel/v2/helper/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index f6c2c0b7..96955b67 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -57,7 +57,7 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st issuer := issuerScheme + domain if issuerPort != "" { - issuer += issuerPort + issuer += ":" + issuerPort } clientDomain := domain + ":" + port From d8e595b814c9135dea524dfe25e46de557ed7335 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 14 Apr 2023 11:21:53 +0200 Subject: [PATCH 082/260] generate support mail field --- .../zitadel/pkg/grpc/text/text_terraform.go | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go index 13ab4bdc..e1c7df24 100644 --- a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -254,6 +254,11 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, + "support_email": { + Description: "", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, "tos": { Description: "", Optional: true, @@ -2140,6 +2145,23 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } + { + a, ok := tf.Attrs["support_email"] + if !ok { + diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text.support_email"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text.support_email", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SupportEmail = t + } + } + } { a, ok := tf.Attrs["tos"] if !ok { @@ -6739,6 +6761,28 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["privacy_policy"] = v } } + { + t, ok := tf.AttrTypes["support_email"] + if !ok { + diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text.support_email"}) + } else { + v, ok := tf.Attrs["support_email"].(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"LoginCustomText.footer_text.support_email", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text.support_email", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SupportEmail) == "" + } + v.Value = string(obj.SupportEmail) + v.Unknown = false + tf.Attrs["support_email"] = v + } + } { t, ok := tf.AttrTypes["tos"] if !ok { From 66f72f537994142fe82de4e8c07f3376744d0a5b Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 17 Apr 2023 09:05:20 +0200 Subject: [PATCH 083/260] revert generation --- .../zitadel/pkg/grpc/text/text_terraform.go | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go index e1c7df24..13ab4bdc 100644 --- a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -254,11 +254,6 @@ func GenSchemaLoginCustomText(ctx context.Context) (github_com_hashicorp_terrafo Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, }, - "support_email": { - Description: "", - Optional: true, - Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, - }, "tos": { Description: "", Optional: true, @@ -2145,23 +2140,6 @@ func CopyLoginCustomTextFromTerraform(_ context.Context, tf github_com_hashicorp } } } - { - a, ok := tf.Attrs["support_email"] - if !ok { - diags.Append(attrReadMissingDiag{"LoginCustomText.footer_text.support_email"}) - } else { - v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrReadConversionFailureDiag{"LoginCustomText.footer_text.support_email", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } else { - var t string - if !v.Null && !v.Unknown { - t = string(v.Value) - } - obj.SupportEmail = t - } - } - } { a, ok := tf.Attrs["tos"] if !ok { @@ -6761,28 +6739,6 @@ func CopyLoginCustomTextToTerraform(ctx context.Context, obj textpb.LoginCustomT tf.Attrs["privacy_policy"] = v } } - { - t, ok := tf.AttrTypes["support_email"] - if !ok { - diags.Append(attrWriteMissingDiag{"LoginCustomText.footer_text.support_email"}) - } else { - v, ok := tf.Attrs["support_email"].(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) - if err != nil { - diags.Append(attrWriteGeneralError{"LoginCustomText.footer_text.support_email", err}) - } - v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) - if !ok { - diags.Append(attrWriteConversionFailureDiag{"LoginCustomText.footer_text.support_email", "github.com/hashicorp/terraform-plugin-framework/types.String"}) - } - v.Null = string(obj.SupportEmail) == "" - } - v.Value = string(obj.SupportEmail) - v.Unknown = false - tf.Attrs["support_email"] = v - } - } { t, ok := tf.AttrTypes["tos"] if !ok { From eb90319fa147d94294ae47723303353117829957 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 07:18:25 +0200 Subject: [PATCH 084/260] update tf sdk --- go.mod | 20 ++++++++++---------- go.sum | 49 +++++++++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/go.mod b/go.mod index 2e449920..395cec1a 100644 --- a/go.mod +++ b/go.mod @@ -10,10 +10,10 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-framework v0.15.0 - github.com/hashicorp/terraform-plugin-go v0.14.1 - github.com/hashicorp/terraform-plugin-log v0.7.0 + github.com/hashicorp/terraform-plugin-go v0.14.3 + github.com/hashicorp/terraform-plugin-log v0.8.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 github.com/zitadel/oidc v1.13.2 github.com/zitadel/zitadel-go/v2 v2.0.12 golang.org/x/oauth2 v0.6.0 @@ -39,17 +39,17 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.2.1 // indirect + github.com/hashicorp/go-hclog v1.4.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.6 // indirect + github.com/hashicorp/go-plugin v1.4.8 // 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.0 // indirect - github.com/hashicorp/hcl/v2 v2.15.0 // indirect + github.com/hashicorp/hcl/v2 v2.16.2 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.18.1 // indirect - github.com/hashicorp/terraform-json v0.15.0 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect + github.com/hashicorp/terraform-json v0.16.0 // indirect + github.com/hashicorp/terraform-registry-address v0.1.0 // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.2 // indirect @@ -70,8 +70,8 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.13.0 // indirect - golang.org/x/crypto v0.5.0 // indirect + github.com/zclconf/go-cty v1.13.1 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/mod v0.8.0 // indirect golang.org/x/net v0.8.0 // indirect golang.org/x/sys v0.6.0 // indirect diff --git a/go.sum b/go.sum index 80ed7d8d..2da5a601 100644 --- a/go.sum +++ b/go.sum @@ -50,7 +50,6 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 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= @@ -143,7 +142,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/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-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= @@ -182,13 +180,13 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= -github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I= +github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= -github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -199,28 +197,28 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= -github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= -github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= +github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= 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.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= -github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= +github.com/hashicorp/terraform-json v0.16.0 h1:UKkeWRWb23do5LNAFlh/K3N0ymn1qTOO8c+85Albo3s= +github.com/hashicorp/terraform-json v0.16.0/go.mod h1:v0Ufk9jJnk6tcIZvScHvetlKfiNTC+WS21mnXIlc0B0= github.com/hashicorp/terraform-plugin-docs v0.14.1 h1:MikFi59KxrP/ewrZoaowrB9he5Vu4FtvhamZFustiA4= github.com/hashicorp/terraform-plugin-docs v0.14.1/go.mod h1:k2NW8+t113jAus6bb5tQYQgEAX/KueE/u8X2Z45V1GM= github.com/hashicorp/terraform-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q= github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= -github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek= -github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ= -github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= -github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= +github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+3BL/DBBxFEki+j0= +github.com/hashicorp/terraform-plugin-go v0.14.3/go.mod h1:7ees7DMZ263q8wQ6E4RdIdR6nHHJtrdt4ogX5lPkX1A= +github.com/hashicorp/terraform-plugin-log v0.8.0 h1:pX2VQ/TGKu+UU1rCay0OlzosNKe4Nz1pepLXj95oyy0= +github.com/hashicorp/terraform-plugin-log v0.8.0/go.mod h1:1myFrhVsBLeylQzYYEV17VVjtG8oYPRFdaZs7xdW2xs= github.com/hashicorp/terraform-plugin-mux v0.7.0 h1:wRbSYzg+v2sn5Mdee0UKm4YTt4wJG0LfSwtgNuBkglY= github.com/hashicorp/terraform-plugin-mux v0.7.0/go.mod h1:Ae30Mc5lz4d1awtiCbHP0YyvgBeiQ00Q1nAq0U3lb+I= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ= +github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U= +github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= @@ -282,7 +280,6 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -298,7 +295,6 @@ github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBO github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -315,7 +311,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -341,11 +336,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/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.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= -github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= +github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.13.2 h1:DiwAgHtw1kKcngNzLjgv1/oRL1OjdYf3emEsFzQzraI= github.com/zitadel/oidc v1.13.2/go.mod h1:GUywRhXAiTvvjdRdXblmGknDOeMwrsdMxTRCypi6974= @@ -367,8 +359,9 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -512,12 +505,12 @@ golang.org/x/sys v0.6.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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= From db9d680707ebca63519fe8a1e9a8fd5857bc1fda Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 07:18:34 +0200 Subject: [PATCH 085/260] ignore local binary --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 46ae5331..85ff4cce 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ override.tf.json # IDEs .idea + +# local binary +terraform-provider-zitadel From 43bfa6f36288a2733bdb3e1ce24939dd31b2e461 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 07:18:55 +0200 Subject: [PATCH 086/260] test lifecycle --- zitadel/v2/org_idp_github/const.go | 2 +- zitadel/v2/org_idp_github/context_test.go | 92 ++++++++++++ zitadel/v2/org_idp_github/funcs.go | 2 +- zitadel/v2/org_idp_github/resource_test.go | 159 +++++++++++++++++++++ 4 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 zitadel/v2/org_idp_github/context_test.go create mode 100644 zitadel/v2/org_idp_github/resource_test.go diff --git a/zitadel/v2/org_idp_github/const.go b/zitadel/v2/org_idp_github/const.go index 1cc61c4a..04588fd5 100644 --- a/zitadel/v2/org_idp_github/const.go +++ b/zitadel/v2/org_idp_github/const.go @@ -1,7 +1,7 @@ package org_idp_github const ( - idpIDVar = "idp_id" + idpIDVar = "id" orgIDVar = "org_id" nameVar = "name" clientIDVar = "client_id" diff --git a/zitadel/v2/org_idp_github/context_test.go b/zitadel/v2/org_idp_github/context_test.go new file mode 100644 index 00000000..8087d5cf --- /dev/null +++ b/zitadel/v2/org_idp_github/context_test.go @@ -0,0 +1,92 @@ +package org_idp_github_test + +import ( + "context" + "fmt" + "os" + + "github.com/zitadel/terraform-provider-zitadel/zitadel" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +const zitadelCtxKey = "zitadel" + +type zitadelContext struct { + client *mgmt.Client + orgID, + terraformType, terraformID, terraformName, + providerSnippet string + zitadelProvider *schema.Provider +} + +func fromZitadelContext(ctx context.Context) *zitadelContext { + return ctx.Value(zitadelCtxKey).(*zitadelContext) +} + +func toZitadelContext() (context.Context, error) { + const ( + orgName = "terraform-tests" + domain = "localhost" + insecure = true + port = "8080" + ) + ctx := context.Background() + tokenPath := os.Getenv("TF_ACC_ZITADEL_TOKEN") + zitadelProvider := zitadel.Provider() + diag := zitadelProvider.Configure(ctx, terraform.NewResourceConfigRaw(map[string]interface{}{ + "domain": domain, + "insecure": insecure, + "port": port, + "token": tokenPath, + })) + providerSnippet := fmt.Sprintf(` +provider "zitadel" { + domain = "%s" + insecure = "%t" + port = "%s" + token = "%s" +} +`, domain, insecure, port, tokenPath) + if diag.HasError() { + return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) + } + clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) + mgmtClient, err := helper.GetManagementClient(clientInfo, "") + if err != nil { + return nil, err + } + org, err := mgmtClient.GetOrgByDomainGlobal(ctx, &management.GetOrgByDomainGlobalRequest{Domain: fmt.Sprintf("%s.%s", orgName, domain)}) + orgID := org.GetOrg().GetId() + if status.Code(err) == codes.NotFound { + var newOrg *management.AddOrgResponse + newOrg, err = mgmtClient.AddOrg(ctx, &management.AddOrgRequest{Name: orgName}) + orgID = newOrg.GetId() + } + if err != nil { + return nil, err + } + mgmtClient, err = helper.GetManagementClient(clientInfo, orgID) + if err != nil { + return nil, err + } + terraformType := "zitadel_org_idp_github" + terraformID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) + terraformName := fmt.Sprintf("%s.%s", terraformType, terraformID) + return context.WithValue(ctx, zitadelCtxKey, &zitadelContext{ + client: mgmtClient, + orgID: orgID, + terraformType: terraformType, + terraformID: terraformID, + terraformName: terraformName, + providerSnippet: providerSnippet, + zitadelProvider: zitadelProvider, + }), err +} diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index 310694a1..16429776 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -66,7 +66,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChanges(nameVar, clientIDVar, clientSecretVar, scopesVar, isLinkingAllowedVar, isCreationAllowedVar, isAutoCreationVar, isAutoUpdateVar) { + if d.HasChangesExcept(idpIDVar, orgIDVar) { _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ Id: d.Id(), Name: d.Get(nameVar).(string), diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go new file mode 100644 index 00000000..ab1231ed --- /dev/null +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -0,0 +1,159 @@ +package org_idp_github_test + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestAccZITADELOrgIdPGitHub(t *testing.T) { + ctx, err := toZitadelContext() + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + zitadelCtx := fromZitadelContext(ctx) + getProviderByIDResponse := new(management.GetProviderByIDResponse) + resource.Test(t, resource.TestCase{ + ProviderFactories: zitadelProviderFactories(ctx), + CheckDestroy: checkDestroy(ctx), + Steps: []resource.TestStep{ + { // Check resource can be created + Config: fmt.Sprintf(` +resource "zitadel_org_idp_github" "%s" { + org_id = "%s" + name = "aninitialprovidername" + client_id = "aclientid" + client_secret = "a secret" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +%s +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), + RefreshState: false, + // ExpectNonEmptyPlan: true, + Check: resource.ComposeTestCheckFunc( + assignGetProviderByIDResponse(ctx, getProviderByIDResponse), + resource.ComposeAggregateTestCheckFunc( + checkStateHasIDSet(ctx), + checkName("aninitialprovidername", getProviderByIDResponse), + ), + ), + }, { // Check resource can be updated + Config: fmt.Sprintf(` +resource "zitadel_org_idp_github" "%s" { + org_id = "%s" + name = "anupdatedprovidername" + client_id = "aclientid" + client_secret = "a secret" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +%s +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), + // ExpectNonEmptyPlan: true, + Check: resource.ComposeTestCheckFunc( + assignGetProviderByIDResponse(ctx, getProviderByIDResponse), + checkName("anupdatedprovidername", getProviderByIDResponse), + ), + }, { // Check client secret can be updated + Config: fmt.Sprintf(` +resource "zitadel_org_idp_github" "%s" { + org_id = "%s" + name = "anupdatedprovidername" + client_id = "aclientid" + client_secret = "another secret" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +%s +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), + // ExpectNonEmptyPlan: true, + }, { // No changes produce an empty plan + Config: fmt.Sprintf(` +resource "zitadel_org_idp_github" "%s" { + org_id = "%s" + name = "anupdatedprovidername" + client_id = "aclientid" + client_secret = "another secret" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +%s +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), + PlanOnly: true, + // ExpectNonEmptyPlan: false, + }, + }, + }) +} + +func checkName(expect string, getProviderByIDResponse *management.GetProviderByIDResponse) resource.TestCheckFunc { + return func(*terraform.State) error { + actual := getProviderByIDResponse.GetIdp().GetName() + if getProviderByIDResponse.GetIdp().GetName() != expect { + return fmt.Errorf("expected name %s, actual name: %s", expect, actual) + } + return nil + } +} + +func checkDestroy(ctx context.Context) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := assignGetProviderByIDResponse(ctx, new(management.GetProviderByIDResponse))(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} + +func assignGetProviderByIDResponse(ctx context.Context, assign *management.GetProviderByIDResponse) resource.TestCheckFunc { + return func(state *terraform.State) (err error) { + zitadelCtx := fromZitadelContext(ctx) + rs := state.RootModule().Resources[zitadelCtx.terraformName] + apiProvider, err := zitadelCtx.client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + *assign = *apiProvider //nolint:govet + return nil + } +} + +func checkStateHasIDSet(ctx context.Context) resource.TestCheckFunc { + // ZITADEL IDs have thirteen digits + idPattern := regexp.MustCompile(`\d{13}`) + return func(state *terraform.State) error { + zitadelCtx := fromZitadelContext(ctx) + return resource.TestMatchResourceAttr(zitadelCtx.terraformName, "id", idPattern)(state) + } +} + +func zitadelProviderFactories(ctx context.Context) map[string]func() (*schema.Provider, error) { + return map[string]func() (*schema.Provider, error){ + "zitadel": func() (*schema.Provider, error) { + zitadelCtx := fromZitadelContext(ctx) + return zitadelCtx.zitadelProvider, nil + }, + } +} From 1096c004835d625fd664632a45918244a0823a03 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 08:08:04 +0200 Subject: [PATCH 087/260] test plan diffs --- zitadel/v2/org_idp_github/resource_test.go | 85 +++++++++++----------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index ab1231ed..cf238de3 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -21,12 +21,7 @@ func TestAccZITADELOrgIdPGitHub(t *testing.T) { } zitadelCtx := fromZitadelContext(ctx) getProviderByIDResponse := new(management.GetProviderByIDResponse) - resource.Test(t, resource.TestCase{ - ProviderFactories: zitadelProviderFactories(ctx), - CheckDestroy: checkDestroy(ctx), - Steps: []resource.TestStep{ - { // Check resource can be created - Config: fmt.Sprintf(` + initialConfig := fmt.Sprintf(` resource "zitadel_org_idp_github" "%s" { org_id = "%s" name = "aninitialprovidername" @@ -39,18 +34,8 @@ resource "zitadel_org_idp_github" "%s" { is_auto_update = true } %s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), - RefreshState: false, - // ExpectNonEmptyPlan: true, - Check: resource.ComposeTestCheckFunc( - assignGetProviderByIDResponse(ctx, getProviderByIDResponse), - resource.ComposeAggregateTestCheckFunc( - checkStateHasIDSet(ctx), - checkName("aninitialprovidername", getProviderByIDResponse), - ), - ), - }, { // Check resource can be updated - Config: fmt.Sprintf(` +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) + updatedNameConfig := fmt.Sprintf(` resource "zitadel_org_idp_github" "%s" { org_id = "%s" name = "anupdatedprovidername" @@ -63,30 +48,8 @@ resource "zitadel_org_idp_github" "%s" { is_auto_update = true } %s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), - // ExpectNonEmptyPlan: true, - Check: resource.ComposeTestCheckFunc( - assignGetProviderByIDResponse(ctx, getProviderByIDResponse), - checkName("anupdatedprovidername", getProviderByIDResponse), - ), - }, { // Check client secret can be updated - Config: fmt.Sprintf(` -resource "zitadel_org_idp_github" "%s" { - org_id = "%s" - name = "anupdatedprovidername" - client_id = "aclientid" - client_secret = "another secret" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -} -%s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), - // ExpectNonEmptyPlan: true, - }, { // No changes produce an empty plan - Config: fmt.Sprintf(` +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) + updatedClientSecret := fmt.Sprintf(` resource "zitadel_org_idp_github" "%s" { org_id = "%s" name = "anupdatedprovidername" @@ -99,9 +62,43 @@ resource "zitadel_org_idp_github" "%s" { is_auto_update = true } %s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet), +`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) + resource.Test(t, resource.TestCase{ + ProviderFactories: zitadelProviderFactories(ctx), + CheckDestroy: checkDestroy(ctx), + Steps: []resource.TestStep{ + { // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, - // ExpectNonEmptyPlan: false, + }, { // Check resource is created + Config: initialConfig, + Check: resource.ComposeTestCheckFunc( + assignGetProviderByIDResponse(ctx, getProviderByIDResponse), + resource.ComposeAggregateTestCheckFunc( + checkStateHasIDSet(ctx), + checkName("aninitialprovidername", getProviderByIDResponse), + ), + ), + }, { // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check name can be updated + Config: updatedNameConfig, + Check: resource.ComposeTestCheckFunc( + assignGetProviderByIDResponse(ctx, getProviderByIDResponse), + checkName("anupdatedprovidername", getProviderByIDResponse), + ), + }, { // Check updating client secret has a diff + Config: updatedClientSecret, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check client secret can be updated + Config: updatedClientSecret, }, }, }) From 560c113a4886c31df208769cfb58ce13da95b95b Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 12:36:55 +0200 Subject: [PATCH 088/260] fix importing --- zitadel/v2/org_idp_github/funcs.go | 22 +++++++ zitadel/v2/org_idp_github/resource.go | 2 +- zitadel/v2/org_idp_github/resource_test.go | 67 ++++++++++++++++------ 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index 16429776..a00b598c 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -2,6 +2,8 @@ package org_idp_github import ( "context" + "fmt" + "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -127,3 +129,23 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(idp.Id) return nil } + +func importIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", idpIDVar) + } + parts := strings.SplitN(id, ":", 3) + if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected orgid:idpid:clientsecret", id) + } + if err := data.Set(orgIDVar, parts[0]); err != nil { + return nil, err + } + data.SetId(parts[1]) + if err := data.Set(clientSecretVar, parts[2]); err != nil { + return nil, err + } + return []*schema.ResourceData{data}, nil + +} diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index a74c5435..df72a00f 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -64,6 +64,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: &schema.ResourceImporter{StateContext: importIDPWithOrgAndClientSecret}, } } diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index cf238de3..a4705033 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -21,8 +21,8 @@ func TestAccZITADELOrgIdPGitHub(t *testing.T) { } zitadelCtx := fromZitadelContext(ctx) getProviderByIDResponse := new(management.GetProviderByIDResponse) - initialConfig := fmt.Sprintf(` -resource "zitadel_org_idp_github" "%s" { + initialConfig := fmt.Sprintf(`%s +resource "%s" "%s" { org_id = "%s" name = "aninitialprovidername" client_id = "aclientid" @@ -32,11 +32,9 @@ resource "zitadel_org_idp_github" "%s" { is_creation_allowed = true is_auto_creation = false is_auto_update = true -} -%s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) - updatedNameConfig := fmt.Sprintf(` -resource "zitadel_org_idp_github" "%s" { +}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID) + updatedNameConfig := fmt.Sprintf(`%s +resource "%s" "%s" { org_id = "%s" name = "anupdatedprovidername" client_id = "aclientid" @@ -46,23 +44,21 @@ resource "zitadel_org_idp_github" "%s" { is_creation_allowed = true is_auto_creation = false is_auto_update = true -} -%s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) - updatedClientSecret := fmt.Sprintf(` -resource "zitadel_org_idp_github" "%s" { +}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID) + updatedSecret := "another secret" + importedSecret := "an imported secret" + updatedClientSecretConfig := fmt.Sprintf(`%s +resource "%s" "%s" { org_id = "%s" name = "anupdatedprovidername" client_id = "aclientid" - client_secret = "another secret" + client_secret = "%s" scopes = ["two", "scopes"] is_linking_allowed = false is_creation_allowed = true is_auto_creation = false is_auto_update = true -} -%s -`, zitadelCtx.terraformID, zitadelCtx.orgID, zitadelCtx.providerSnippet) +}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID, updatedSecret) resource.Test(t, resource.TestCase{ ProviderFactories: zitadelProviderFactories(ctx), CheckDestroy: checkDestroy(ctx), @@ -93,12 +89,35 @@ resource "zitadel_org_idp_github" "%s" { checkName("anupdatedprovidername", getProviderByIDResponse), ), }, { // Check updating client secret has a diff - Config: updatedClientSecret, + Config: updatedClientSecretConfig, ExpectNonEmptyPlan: true, // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, }, { // Check client secret can be updated - Config: updatedClientSecret, + Config: updatedClientSecretConfig, + }, { // Expect import error if client secret is not given + ResourceName: zitadelCtx.terraformName, + ImportState: true, + ImportStateId: "123:456", + ExpectError: regexp.MustCompile(`123:456`), + }, { // Expect importing works + ResourceName: zitadelCtx.terraformName, + ImportState: true, + ImportStateIdFunc: func(state *terraform.State) (string, error) { + lastState := state.RootModule().Resources[zitadelCtx.terraformName].Primary + return fmt.Sprintf("%s:%s:%s", lastState.Attributes["org_id"], lastState.ID, importedSecret), nil + }, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"client_secret"}, + Check: func(state *terraform.State) error { + // Check the client_secret is imported correctly + currentState := state.RootModule().Resources[zitadelCtx.terraformName].Primary + actual := currentState.Attributes["client_secret"] + if actual != importedSecret { + return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) + } + return nil + }, }, }, }) @@ -114,6 +133,18 @@ func checkName(expect string, getProviderByIDResponse *management.GetProviderByI } } +func checkClientSecret(ctx context.Context, expectClientSecret string) resource.TestCheckFunc { + return func(state *terraform.State) error { + zitadelCtx := fromZitadelContext(ctx) + currentState := state.RootModule().Resources[zitadelCtx.terraformName].Primary + actual := currentState.Attributes["client_secret"] + if actual != expectClientSecret { + return fmt.Errorf("expected client_secret to be %s, but got %s", expectClientSecret, actual) + } + return nil + } +} + func checkDestroy(ctx context.Context) resource.TestCheckFunc { return func(state *terraform.State) error { err := assignGetProviderByIDResponse(ctx, new(management.GetProviderByIDResponse))(state) From b01c66a30c94b4ec1143bfd5baa2fc782d4854b1 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 18 Apr 2023 12:42:59 +0200 Subject: [PATCH 089/260] cleanup --- zitadel/v2/org_idp_github/resource_test.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index a4705033..809d1883 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -133,18 +133,6 @@ func checkName(expect string, getProviderByIDResponse *management.GetProviderByI } } -func checkClientSecret(ctx context.Context, expectClientSecret string) resource.TestCheckFunc { - return func(state *terraform.State) error { - zitadelCtx := fromZitadelContext(ctx) - currentState := state.RootModule().Resources[zitadelCtx.terraformName].Primary - actual := currentState.Attributes["client_secret"] - if actual != expectClientSecret { - return fmt.Errorf("expected client_secret to be %s, but got %s", expectClientSecret, actual) - } - return nil - } -} - func checkDestroy(ctx context.Context) resource.TestCheckFunc { return func(state *terraform.State) error { err := assignGetProviderByIDResponse(ctx, new(management.GetProviderByIDResponse))(state) From 7aa27c331c0bdef9cff90dca2a9c8eca9c968db4 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 09:34:40 +0200 Subject: [PATCH 090/260] feat: add GitHub instance idp --- zitadel/provider.go | 4 + zitadel/v2/helper/client.go | 4 + zitadel/v2/idp_github/datasource.go | 65 +++++++ zitadel/v2/idp_github/funcs.go | 111 ++++++++++++ zitadel/v2/idp_github/resource.go | 64 +++++++ zitadel/v2/idp_github/resource_test.go | 29 ++++ zitadel/v2/idp_utils/const.go | 13 ++ zitadel/v2/idp_utils/funcs.go | 45 +++++ zitadel/v2/idp_utils/test_utils/base_frame.go | 63 +++++++ zitadel/v2/idp_utils/test_utils/checks.go | 60 +++++++ .../v2/idp_utils/test_utils/instance_frame.go | 27 +++ .../v2/idp_utils/test_utils/lifecyletest.go | 93 ++++++++++ .../test_utils/provider_factories.go | 11 ++ zitadel/v2/org_idp_github/const.go | 14 -- zitadel/v2/org_idp_github/context_test.go | 92 ---------- zitadel/v2/org_idp_github/datasource.go | 24 +-- zitadel/v2/org_idp_github/funcs.go | 102 ++++------- zitadel/v2/org_idp_github/resource.go | 26 +-- zitadel/v2/org_idp_github/resource_test.go | 159 +----------------- zitadel/v2/org_idp_utils/const.go | 16 ++ zitadel/v2/org_idp_utils/funcs.go | 48 ++++++ zitadel/v2/org_idp_utils/test_utils/checks.go | 33 ++++ zitadel/v2/org_idp_utils/test_utils/frame.go | 50 ++++++ .../org_idp_utils/test_utils/lifecyletest.go | 93 ++++++++++ 24 files changed, 893 insertions(+), 353 deletions(-) create mode 100644 zitadel/v2/idp_github/datasource.go create mode 100644 zitadel/v2/idp_github/funcs.go create mode 100644 zitadel/v2/idp_github/resource.go create mode 100644 zitadel/v2/idp_github/resource_test.go create mode 100644 zitadel/v2/idp_utils/const.go create mode 100644 zitadel/v2/idp_utils/funcs.go create mode 100644 zitadel/v2/idp_utils/test_utils/base_frame.go create mode 100644 zitadel/v2/idp_utils/test_utils/checks.go create mode 100644 zitadel/v2/idp_utils/test_utils/instance_frame.go create mode 100644 zitadel/v2/idp_utils/test_utils/lifecyletest.go create mode 100644 zitadel/v2/idp_utils/test_utils/provider_factories.go delete mode 100644 zitadel/v2/org_idp_github/const.go delete mode 100644 zitadel/v2/org_idp_github/context_test.go create mode 100644 zitadel/v2/org_idp_utils/const.go create mode 100644 zitadel/v2/org_idp_utils/funcs.go create mode 100644 zitadel/v2/org_idp_utils/test_utils/checks.go create mode 100644 zitadel/v2/org_idp_utils/test_utils/frame.go create mode 100644 zitadel/v2/org_idp_utils/test_utils/lifecyletest.go diff --git a/zitadel/provider.go b/zitadel/provider.go index eb3efbcb..99e0b151 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" + "github.com/hashicorp/terraform-plugin-framework/datasource" fdiag "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/provider" @@ -188,6 +190,7 @@ func Provider() *schema.Provider { "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), "zitadel_org_idp_github": org_idp_github.GetDatasource(), + "zitadel_idp_github": idp_github.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -247,6 +250,7 @@ func Provider() *schema.Provider { "zitadel_trigger_actions": trigger_actions.GetResource(), "zitadel_personal_access_token": pat.GetResource(), "zitadel_machine_key": machine_key.GetResource(), + "zitadel_idp_github": idp_github.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 96955b67..6fedd1ba 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -77,6 +77,10 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st }, nil } +func (c *ClientInfo) GetAdminClient() { + +} + func GetAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( info.Issuer, info.Domain, diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go new file mode 100644 index 00000000..d9eabd01 --- /dev/null +++ b/zitadel/v2/idp_github/datasource.go @@ -0,0 +1,65 @@ +package idp_github + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_github/funcs.go b/zitadel/v2/idp_github/funcs.go new file mode 100644 index 00000000..958e93b9 --- /dev/null +++ b/zitadel/v2/idp_github/funcs.go @@ -0,0 +1,111 @@ +package idp_github + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitHubProvider(ctx, &admin.AddGitHubProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateGitHubProvider(ctx, &admin.UpdateGitHubProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGithub() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go new file mode 100644 index 00000000..66401f38 --- /dev/null +++ b/zitadel/v2/idp_github/resource.go @@ -0,0 +1,64 @@ +package idp_github + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + Sensitive: true, + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go new file mode 100644 index 00000000..3124ea94 --- /dev/null +++ b/zitadel/v2/idp_github/resource_test.go @@ -0,0 +1,29 @@ +package idp_github_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPGitHub(t *testing.T) { + resourceName := "zitadel_idp_github" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go new file mode 100644 index 00000000..7ffa7dae --- /dev/null +++ b/zitadel/v2/idp_utils/const.go @@ -0,0 +1,13 @@ +package idp_utils + +const ( + IdpIDVar = "id" + NameVar = "name" + ClientIDVar = "client_id" + ClientSecretVar = "client_secret" + ScopesVar = "scopes" + IsLinkingAllowedVar = "is_linking_allowed" + IsCreationAllowedVar = "is_creation_allowed" + IsAutoCreationVar = "is_auto_creation" + IsAutoUpdateVar = "is_auto_update" +) diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/v2/idp_utils/funcs.go new file mode 100644 index 00000000..98a2d86c --- /dev/null +++ b/zitadel/v2/idp_utils/funcs.go @@ -0,0 +1,45 @@ +package idp_utils + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" +) + +func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + _, err = client.DeleteProvider(ctx, &admin.DeleteProviderRequest{Id: d.Id()}) + if err != nil { + return diag.Errorf("failed to delete idp: %v", err) + } + return nil +} + +func ImportIDPWithClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", IdpIDVar) + } + parts := strings.SplitN(id, ":", 2) + if len(parts) != 2 || parts[0] == "" || parts[1] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected idpid:clientsecret", id) + } + data.SetId(parts[0]) + if err := data.Set(ClientSecretVar, parts[1]); err != nil { + return nil, err + } + return []*schema.ResourceData{data}, nil + +} diff --git a/zitadel/v2/idp_utils/test_utils/base_frame.go b/zitadel/v2/idp_utils/test_utils/base_frame.go new file mode 100644 index 00000000..b30850b2 --- /dev/null +++ b/zitadel/v2/idp_utils/test_utils/base_frame.go @@ -0,0 +1,63 @@ +package test_utils + +import ( + "context" + "fmt" + "os" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +const ( + Domain = "localhost" + insecure = true + port = "8080" +) + +type BaseTestFrame struct { + context.Context + ConfiguredProvider *schema.Provider + ClientInfo *helper.ClientInfo + ProviderSnippet, UniqueResourcesID string + TerraformName string +} + +func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { + ctx := context.Background() + tokenPath := os.Getenv("TF_ACC_ZITADEL_TOKEN") + zitadelProvider := zitadel.Provider() + diag := zitadelProvider.Configure(ctx, terraform.NewResourceConfigRaw(map[string]interface{}{ + "domain": Domain, + "insecure": insecure, + "port": port, + "token": tokenPath, + })) + providerSnippet := fmt.Sprintf(` +provider "zitadel" { + domain = "%s" + insecure = "%t" + port = "%s" + token = "%s" +} +`, Domain, insecure, port, tokenPath) + if diag.HasError() { + return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) + } + clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) + uniqueID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) + terraformName := fmt.Sprintf("%s.%s", resourceType, uniqueID) + + return &BaseTestFrame{ + Context: ctx, + ConfiguredProvider: zitadelProvider, + ProviderSnippet: providerSnippet, + ClientInfo: clientInfo, + UniqueResourcesID: uniqueID, + TerraformName: terraformName, + }, nil +} diff --git a/zitadel/v2/idp_utils/test_utils/checks.go b/zitadel/v2/idp_utils/test_utils/checks.go new file mode 100644 index 00000000..fa207fd2 --- /dev/null +++ b/zitadel/v2/idp_utils/test_utils/checks.go @@ -0,0 +1,60 @@ +package test_utils + +import ( + "fmt" + + "regexp" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +type ResponseProto interface { + GetIdp() *idp.Provider +} + +func CheckName(expect string, getProviderByIDResponse ResponseProto) resource.TestCheckFunc { + return func(*terraform.State) error { + actual := getProviderByIDResponse.GetIdp().GetName() + if actual != expect { + return fmt.Errorf("expected name %s, actual name: %s", expect, actual) + } + return nil + } +} + +func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { + // ZITADEL IDs have thirteen digits + idPattern := regexp.MustCompile(`\d{13}`) + return func(state *terraform.State) error { + return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) + } +} + +func CheckDestroy(ctx *InstanceTestFrame) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := AssignGetProviderByIDResponse(ctx, new(admin.GetProviderByIDResponse))(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} + +func AssignGetProviderByIDResponse(ctx *InstanceTestFrame, assign *admin.GetProviderByIDResponse) resource.TestCheckFunc { + return func(state *terraform.State) (err error) { + rs := state.RootModule().Resources[ctx.TerraformName] + apiProvider, err := ctx.Client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + *assign = *apiProvider //nolint:govet + return nil + } +} diff --git a/zitadel/v2/idp_utils/test_utils/instance_frame.go b/zitadel/v2/idp_utils/test_utils/instance_frame.go new file mode 100644 index 00000000..f65492bf --- /dev/null +++ b/zitadel/v2/idp_utils/test_utils/instance_frame.go @@ -0,0 +1,27 @@ +package test_utils + +import ( + "github.com/zitadel/zitadel-go/v2/pkg/client/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +type InstanceTestFrame struct { + BaseTestFrame + *admin.Client +} + +func NewInstanceTestFrame(resourceType string) (*InstanceTestFrame, error) { + baseFrame, err := NewBaseTestFrame(resourceType) + if err != nil { + return nil, err + } + adminClient, err := helper.GetAdminClient(baseFrame.ClientInfo) + if err != nil { + return nil, err + } + return &InstanceTestFrame{ + BaseTestFrame: *baseFrame, + Client: adminClient, + }, err +} diff --git a/zitadel/v2/idp_utils/test_utils/lifecyletest.go b/zitadel/v2/idp_utils/test_utils/lifecyletest.go new file mode 100644 index 00000000..67a88395 --- /dev/null +++ b/zitadel/v2/idp_utils/test_utils/lifecyletest.go @@ -0,0 +1,93 @@ +package test_utils + +import ( + "fmt" + "regexp" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +const ( + initialProviderName = "an initial provider name" + updatedProviderName = "an updated provider name" + initialSecret = "an initial secret" + updatedSecret = "an updated secret" + importedSecret = "an imported secret" +) + +func RunBasicLifecyleTest( + t *testing.T, + frame *InstanceTestFrame, + resourceFunc func(string, string) string, +) { + getProviderByIDResponse := new(admin.GetProviderByIDResponse) + initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) + updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, initialSecret)) + updatedClientSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) + resource.Test(t, resource.TestCase{ + ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), + CheckDestroy: CheckDestroy(frame), + Steps: []resource.TestStep{ + { // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check resource is created + Config: initialConfig, + Check: resource.ComposeTestCheckFunc( + AssignGetProviderByIDResponse(frame, getProviderByIDResponse), + resource.ComposeAggregateTestCheckFunc( + CheckStateHasIDSet(frame.BaseTestFrame), + CheckName(initialProviderName, getProviderByIDResponse), + ), + ), + }, { // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check name can be updated + Config: updatedNameConfig, + Check: resource.ComposeTestCheckFunc( + AssignGetProviderByIDResponse(frame, getProviderByIDResponse), + CheckName(updatedProviderName, getProviderByIDResponse), + ), + }, { // Check updating client secret has a diff + Config: updatedClientSecretConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check client secret can be updated + Config: updatedClientSecretConfig, + }, { // Expect import error if client secret is not given + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateId: "12345", + ExpectError: regexp.MustCompile(`12345`), + }, { // Expect importing works + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: func(state *terraform.State) (string, error) { + lastState := state.RootModule().Resources[frame.TerraformName].Primary + return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil + }, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"client_secret"}, + Check: func(state *terraform.State) error { + // Check the client_secret is imported correctly + currentState := state.RootModule().Resources[frame.TerraformName].Primary + actual := currentState.Attributes["client_secret"] + if actual != importedSecret { + return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) + } + return nil + }, + }, + }, + }) +} diff --git a/zitadel/v2/idp_utils/test_utils/provider_factories.go b/zitadel/v2/idp_utils/test_utils/provider_factories.go new file mode 100644 index 00000000..bb110c6d --- /dev/null +++ b/zitadel/v2/idp_utils/test_utils/provider_factories.go @@ -0,0 +1,11 @@ +package test_utils + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func ZitadelProviderFactories(provider *schema.Provider) map[string]func() (*schema.Provider, error) { + return map[string]func() (*schema.Provider, error){ + "zitadel": func() (*schema.Provider, error) { + return provider, nil + }, + } +} diff --git a/zitadel/v2/org_idp_github/const.go b/zitadel/v2/org_idp_github/const.go deleted file mode 100644 index 04588fd5..00000000 --- a/zitadel/v2/org_idp_github/const.go +++ /dev/null @@ -1,14 +0,0 @@ -package org_idp_github - -const ( - idpIDVar = "id" - orgIDVar = "org_id" - nameVar = "name" - clientIDVar = "client_id" - clientSecretVar = "client_secret" - scopesVar = "scopes" - isLinkingAllowedVar = "is_linking_allowed" - isCreationAllowedVar = "is_creation_allowed" - isAutoCreationVar = "is_auto_creation" - isAutoUpdateVar = "is_auto_update" -) diff --git a/zitadel/v2/org_idp_github/context_test.go b/zitadel/v2/org_idp_github/context_test.go deleted file mode 100644 index 8087d5cf..00000000 --- a/zitadel/v2/org_idp_github/context_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package org_idp_github_test - -import ( - "context" - "fmt" - "os" - - "github.com/zitadel/terraform-provider-zitadel/zitadel" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -const zitadelCtxKey = "zitadel" - -type zitadelContext struct { - client *mgmt.Client - orgID, - terraformType, terraformID, terraformName, - providerSnippet string - zitadelProvider *schema.Provider -} - -func fromZitadelContext(ctx context.Context) *zitadelContext { - return ctx.Value(zitadelCtxKey).(*zitadelContext) -} - -func toZitadelContext() (context.Context, error) { - const ( - orgName = "terraform-tests" - domain = "localhost" - insecure = true - port = "8080" - ) - ctx := context.Background() - tokenPath := os.Getenv("TF_ACC_ZITADEL_TOKEN") - zitadelProvider := zitadel.Provider() - diag := zitadelProvider.Configure(ctx, terraform.NewResourceConfigRaw(map[string]interface{}{ - "domain": domain, - "insecure": insecure, - "port": port, - "token": tokenPath, - })) - providerSnippet := fmt.Sprintf(` -provider "zitadel" { - domain = "%s" - insecure = "%t" - port = "%s" - token = "%s" -} -`, domain, insecure, port, tokenPath) - if diag.HasError() { - return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) - } - clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) - mgmtClient, err := helper.GetManagementClient(clientInfo, "") - if err != nil { - return nil, err - } - org, err := mgmtClient.GetOrgByDomainGlobal(ctx, &management.GetOrgByDomainGlobalRequest{Domain: fmt.Sprintf("%s.%s", orgName, domain)}) - orgID := org.GetOrg().GetId() - if status.Code(err) == codes.NotFound { - var newOrg *management.AddOrgResponse - newOrg, err = mgmtClient.AddOrg(ctx, &management.AddOrgRequest{Name: orgName}) - orgID = newOrg.GetId() - } - if err != nil { - return nil, err - } - mgmtClient, err = helper.GetManagementClient(clientInfo, orgID) - if err != nil { - return nil, err - } - terraformType := "zitadel_org_idp_github" - terraformID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) - terraformName := fmt.Sprintf("%s.%s", terraformType, terraformID) - return context.WithValue(ctx, zitadelCtxKey, &zitadelContext{ - client: mgmtClient, - orgID: orgID, - terraformType: terraformType, - terraformID: terraformID, - terraformName: terraformName, - providerSnippet: providerSnippet, - zitadelProvider: zitadelProvider, - }), err -} diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 5ef31b9d..1b488344 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -2,40 +2,40 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub IDP of the organization.", Schema: map[string]*schema.Schema{ - idpIDVar: { + org_idp_utils.IdpIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + org_idp_utils.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", }, - nameVar: { + org_idp_utils.NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the IDP", }, - clientIDVar: { + org_idp_utils.ClientIDVar: { Type: schema.TypeString, Computed: true, Description: "client id generated by the identity provider", - Sensitive: true, }, - clientSecretVar: { + org_idp_utils.ClientSecretVar: { Type: schema.TypeString, Computed: true, Description: "client secret generated by the identity provider", Sensitive: true, }, - scopesVar: { + org_idp_utils.ScopesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, @@ -43,28 +43,28 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - isLinkingAllowedVar: { + org_idp_utils.IsLinkingAllowedVar: { Type: schema.TypeBool, Computed: true, Description: "enable if users should be able to link an existing ZITADEL user with an external account", }, - isCreationAllowedVar: { + org_idp_utils.IsCreationAllowedVar: { Type: schema.TypeBool, Computed: true, Description: "enable if users should be able to create a new account in ZITADEL when using an external account", }, - isAutoCreationVar: { + org_idp_utils.IsAutoCreationVar: { Type: schema.TypeBool, Computed: true, Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", }, - isAutoUpdateVar: { + org_idp_utils.IsAutoUpdateVar: { Type: schema.TypeBool, Computed: true, Description: "enable if a the ZITADEL account fields should be updated automatically on each login", }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, } } diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index a00b598c..3d21e26a 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -2,8 +2,8 @@ package org_idp_github import ( "context" - "fmt" - "strings" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -13,43 +13,25 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) -func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - clientinfo, ok := m.(*helper.ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - _, err = client.DeleteProvider(ctx, &management.DeleteProviderRequest{ - Id: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete idp: %v", err) - } - return nil -} - func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGitHubProvider(ctx, &management.AddGitHubProviderRequest{ - Name: d.Get(nameVar).(string), - ClientId: d.Get(clientIDVar).(string), - ClientSecret: d.Get(clientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, scopesVar), + Name: d.Get(org_idp_utils.NameVar).(string), + ClientId: d.Get(org_idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(org_idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, org_idp_utils.ScopesVar), ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(isLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(isCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(isAutoUpdateVar).(bool), - IsAutoCreation: d.Get(isAutoCreationVar).(bool), + IsLinkingAllowed: d.Get(org_idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(org_idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(org_idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(org_idp_utils.IsAutoCreationVar).(bool), }, }) if err != nil { @@ -64,22 +46,22 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idpIDVar, orgIDVar) { + if d.HasChangesExcept(org_idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ Id: d.Id(), - Name: d.Get(nameVar).(string), - ClientId: d.Get(clientIDVar).(string), - ClientSecret: d.Get(clientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, scopesVar), + Name: d.Get(org_idp_utils.NameVar).(string), + ClientId: d.Get(org_idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(org_idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, org_idp_utils.ScopesVar), ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(isLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(isCreationAllowedVar).(bool), - IsAutoCreation: d.Get(isAutoCreationVar).(bool), - IsAutoUpdate: d.Get(isAutoUpdateVar).(bool), + IsLinkingAllowed: d.Get(org_idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(org_idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(org_idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(org_idp_utils.IsAutoUpdateVar).(bool), }, }) if err != nil { @@ -94,11 +76,11 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idpIDVar)}) + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, org_idp_utils.IdpIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -111,15 +93,15 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithub() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - orgIDVar: idp.GetDetails().GetResourceOwner(), - nameVar: idp.GetName(), - clientIDVar: specificCfg.GetClientId(), - clientSecretVar: d.Get(clientSecretVar).(string), - scopesVar: specificCfg.GetScopes(), - isLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - isCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - isAutoCreationVar: generalCfg.GetIsAutoCreation(), - isAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + org_idp_utils.NameVar: idp.GetName(), + org_idp_utils.ClientIDVar: specificCfg.GetClientId(), + org_idp_utils.ClientSecretVar: d.Get(org_idp_utils.ClientSecretVar).(string), + org_idp_utils.ScopesVar: specificCfg.GetScopes(), + org_idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + org_idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + org_idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + org_idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -129,23 +111,3 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(idp.Id) return nil } - -func importIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", idpIDVar) - } - parts := strings.SplitN(id, ":", 3) - if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected orgid:idpid:clientsecret", id) - } - if err := data.Set(orgIDVar, parts[0]); err != nil { - return nil, err - } - data.SetId(parts[1]) - if err := data.Set(clientSecretVar, parts[2]); err != nil { - return nil, err - } - return []*schema.ResourceData{data}, nil - -} diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index df72a00f..99ef6e41 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -2,36 +2,36 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP of the organization.", + Description: "Resource representing a OIDC IDP on the organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { + org_idp_utils.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", ForceNew: true, }, - nameVar: { + org_idp_utils.NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the IDP", }, - clientIDVar: { + org_idp_utils.ClientIDVar: { Type: schema.TypeString, Required: true, Description: "client id generated by the identity provider", - Sensitive: true, }, - clientSecretVar: { + org_idp_utils.ClientSecretVar: { Type: schema.TypeString, Required: true, Description: "client secret generated by the identity provider", Sensitive: true, }, - scopesVar: { + org_idp_utils.ScopesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, @@ -39,22 +39,22 @@ func GetResource() *schema.Resource { Required: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - isLinkingAllowedVar: { + org_idp_utils.IsLinkingAllowedVar: { Type: schema.TypeBool, Required: true, Description: "enable if users should be able to link an existing ZITADEL user with an external account", }, - isCreationAllowedVar: { + org_idp_utils.IsCreationAllowedVar: { Type: schema.TypeBool, Required: true, Description: "enable if users should be able to create a new account in ZITADEL when using an external account", }, - isAutoCreationVar: { + org_idp_utils.IsAutoCreationVar: { Type: schema.TypeBool, Required: true, Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", }, - isAutoUpdateVar: { + org_idp_utils.IsAutoUpdateVar: { Type: schema.TypeBool, Required: true, Description: "enable if a the ZITADEL account fields should be updated automatically on each login", @@ -63,7 +63,7 @@ func GetResource() *schema.Resource { ReadContext: read, UpdateContext: update, CreateContext: create, - DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: importIDPWithOrgAndClientSecret}, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, } } diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index 809d1883..265d3f95 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -1,56 +1,23 @@ package org_idp_github_test import ( - "context" "fmt" - "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) func TestAccZITADELOrgIdPGitHub(t *testing.T) { - ctx, err := toZitadelContext() + resourceName := "zitadel_org_idp_github" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - zitadelCtx := fromZitadelContext(ctx) - getProviderByIDResponse := new(management.GetProviderByIDResponse) - initialConfig := fmt.Sprintf(`%s + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" - name = "aninitialprovidername" - client_id = "aclientid" - client_secret = "a secret" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID) - updatedNameConfig := fmt.Sprintf(`%s -resource "%s" "%s" { - org_id = "%s" - name = "anupdatedprovidername" - client_id = "aclientid" - client_secret = "a secret" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID) - updatedSecret := "another secret" - importedSecret := "an imported secret" - updatedClientSecretConfig := fmt.Sprintf(`%s -resource "%s" "%s" { - org_id = "%s" - name = "anupdatedprovidername" + name = "%s" client_id = "aclientid" client_secret = "%s" scopes = ["two", "scopes"] @@ -58,118 +25,6 @@ resource "%s" "%s" { is_creation_allowed = true is_auto_creation = false is_auto_update = true -}`, zitadelCtx.providerSnippet, zitadelCtx.terraformType, zitadelCtx.terraformID, zitadelCtx.orgID, updatedSecret) - resource.Test(t, resource.TestCase{ - ProviderFactories: zitadelProviderFactories(ctx), - CheckDestroy: checkDestroy(ctx), - Steps: []resource.TestStep{ - { // Check first plan has a diff - Config: initialConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check resource is created - Config: initialConfig, - Check: resource.ComposeTestCheckFunc( - assignGetProviderByIDResponse(ctx, getProviderByIDResponse), - resource.ComposeAggregateTestCheckFunc( - checkStateHasIDSet(ctx), - checkName("aninitialprovidername", getProviderByIDResponse), - ), - ), - }, { // Check updating name has a diff - Config: updatedNameConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check name can be updated - Config: updatedNameConfig, - Check: resource.ComposeTestCheckFunc( - assignGetProviderByIDResponse(ctx, getProviderByIDResponse), - checkName("anupdatedprovidername", getProviderByIDResponse), - ), - }, { // Check updating client secret has a diff - Config: updatedClientSecretConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check client secret can be updated - Config: updatedClientSecretConfig, - }, { // Expect import error if client secret is not given - ResourceName: zitadelCtx.terraformName, - ImportState: true, - ImportStateId: "123:456", - ExpectError: regexp.MustCompile(`123:456`), - }, { // Expect importing works - ResourceName: zitadelCtx.terraformName, - ImportState: true, - ImportStateIdFunc: func(state *terraform.State) (string, error) { - lastState := state.RootModule().Resources[zitadelCtx.terraformName].Primary - return fmt.Sprintf("%s:%s:%s", lastState.Attributes["org_id"], lastState.ID, importedSecret), nil - }, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"client_secret"}, - Check: func(state *terraform.State) error { - // Check the client_secret is imported correctly - currentState := state.RootModule().Resources[zitadelCtx.terraformName].Primary - actual := currentState.Attributes["client_secret"] - if actual != importedSecret { - return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) - } - return nil - }, - }, - }, +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) }) } - -func checkName(expect string, getProviderByIDResponse *management.GetProviderByIDResponse) resource.TestCheckFunc { - return func(*terraform.State) error { - actual := getProviderByIDResponse.GetIdp().GetName() - if getProviderByIDResponse.GetIdp().GetName() != expect { - return fmt.Errorf("expected name %s, actual name: %s", expect, actual) - } - return nil - } -} - -func checkDestroy(ctx context.Context) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := assignGetProviderByIDResponse(ctx, new(management.GetProviderByIDResponse))(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - } -} - -func assignGetProviderByIDResponse(ctx context.Context, assign *management.GetProviderByIDResponse) resource.TestCheckFunc { - return func(state *terraform.State) (err error) { - zitadelCtx := fromZitadelContext(ctx) - rs := state.RootModule().Resources[zitadelCtx.terraformName] - apiProvider, err := zitadelCtx.client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) - if err != nil { - return err - } - *assign = *apiProvider //nolint:govet - return nil - } -} - -func checkStateHasIDSet(ctx context.Context) resource.TestCheckFunc { - // ZITADEL IDs have thirteen digits - idPattern := regexp.MustCompile(`\d{13}`) - return func(state *terraform.State) error { - zitadelCtx := fromZitadelContext(ctx) - return resource.TestMatchResourceAttr(zitadelCtx.terraformName, "id", idPattern)(state) - } -} - -func zitadelProviderFactories(ctx context.Context) map[string]func() (*schema.Provider, error) { - return map[string]func() (*schema.Provider, error){ - "zitadel": func() (*schema.Provider, error) { - zitadelCtx := fromZitadelContext(ctx) - return zitadelCtx.zitadelProvider, nil - }, - } -} diff --git a/zitadel/v2/org_idp_utils/const.go b/zitadel/v2/org_idp_utils/const.go new file mode 100644 index 00000000..53d2e050 --- /dev/null +++ b/zitadel/v2/org_idp_utils/const.go @@ -0,0 +1,16 @@ +package org_idp_utils + +import "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + +const ( + IdpIDVar = idp_utils.IdpIDVar + OrgIDVar = "org_id" + NameVar = idp_utils.NameVar + ClientIDVar = idp_utils.ClientIDVar + ClientSecretVar = idp_utils.ClientSecretVar + ScopesVar = idp_utils.ScopesVar + IsLinkingAllowedVar = idp_utils.IsLinkingAllowedVar + IsCreationAllowedVar = idp_utils.IsCreationAllowedVar + IsAutoCreationVar = idp_utils.IsAutoCreationVar + IsAutoUpdateVar = idp_utils.IsAutoUpdateVar +) diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go new file mode 100644 index 00000000..b4e8076f --- /dev/null +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -0,0 +1,48 @@ +package org_idp_utils + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + _, err = client.DeleteProvider(ctx, &management.DeleteProviderRequest{Id: d.Id()}) + if err != nil { + return diag.Errorf("failed to delete idp: %v", err) + } + return nil +} + +func ImportIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", IdpIDVar) + } + parts := strings.SplitN(id, ":", 3) + if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected orgid:idpid:clientsecret", id) + } + if err := data.Set(OrgIDVar, parts[0]); err != nil { + return nil, err + } + data.SetId(parts[1]) + if err := data.Set(ClientSecretVar, parts[2]); err != nil { + return nil, err + } + return []*schema.ResourceData{data}, nil + +} diff --git a/zitadel/v2/org_idp_utils/test_utils/checks.go b/zitadel/v2/org_idp_utils/test_utils/checks.go new file mode 100644 index 00000000..bf723964 --- /dev/null +++ b/zitadel/v2/org_idp_utils/test_utils/checks.go @@ -0,0 +1,33 @@ +package test_utils + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func CheckDestroy(frame *OrgTestFrame) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := AssignGetProviderByIDResponse(frame, new(management.GetProviderByIDResponse))(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} + +func AssignGetProviderByIDResponse(frame *OrgTestFrame, assign *management.GetProviderByIDResponse) resource.TestCheckFunc { + return func(state *terraform.State) (err error) { + rs := state.RootModule().Resources[frame.TerraformName] + apiProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + *assign = *apiProvider //nolint:govet + return nil + } +} diff --git a/zitadel/v2/org_idp_utils/test_utils/frame.go b/zitadel/v2/org_idp_utils/test_utils/frame.go new file mode 100644 index 00000000..bdf36237 --- /dev/null +++ b/zitadel/v2/org_idp_utils/test_utils/frame.go @@ -0,0 +1,50 @@ +package test_utils + +import ( + "fmt" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +const ( + orgName = "terraform-tests" + domain = test_utils.Domain +) + +type OrgTestFrame struct { + test_utils.BaseTestFrame + *mgmt.Client + OrgID string +} + +func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { + baseFrame, err := test_utils.NewBaseTestFrame(resourceType) + if err != nil { + return nil, err + } + mgmtClient, err := helper.GetManagementClient(baseFrame.ClientInfo, "") + if err != nil { + return nil, err + } + org, err := mgmtClient.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: fmt.Sprintf("%s.%s", orgName, domain)}) + orgID := org.GetOrg().GetId() + if status.Code(err) == codes.NotFound { + var newOrg *management.AddOrgResponse + newOrg, err = mgmtClient.AddOrg(baseFrame, &management.AddOrgRequest{Name: orgName}) + orgID = newOrg.GetId() + } + if err != nil { + return nil, err + } + mgmtClient, err = helper.GetManagementClient(baseFrame.ClientInfo, orgID) + return &OrgTestFrame{ + BaseTestFrame: *baseFrame, + Client: mgmtClient, + OrgID: orgID, + }, err +} diff --git a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go new file mode 100644 index 00000000..f6bfbe3a --- /dev/null +++ b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go @@ -0,0 +1,93 @@ +package test_utils + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +const ( + initialProviderName = "an initial provider name" + updatedProviderName = "an updated provider name" + initialSecret = "an initial secret" + updatedSecret = "an updated secret" + importedSecret = "an imported secret" +) + +func RunBasicLifecyleTest( + t *testing.T, + frame *OrgTestFrame, + resourceFunc func(string, string) string, +) { + getProviderByIDResponse := new(management.GetProviderByIDResponse) + initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) + updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, initialSecret)) + updatedClientSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) + resource.Test(t, resource.TestCase{ + ProviderFactories: test_utils.ZitadelProviderFactories(frame.ConfiguredProvider), + CheckDestroy: CheckDestroy(frame), + Steps: []resource.TestStep{ + { // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check resource is created + Config: initialConfig, + Check: resource.ComposeTestCheckFunc( + AssignGetProviderByIDResponse(frame, getProviderByIDResponse), + resource.ComposeAggregateTestCheckFunc( + test_utils.CheckStateHasIDSet(frame.BaseTestFrame), + test_utils.CheckName(initialProviderName, getProviderByIDResponse), + ), + ), + }, { // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check name can be updated + Config: updatedNameConfig, + Check: resource.ComposeTestCheckFunc( + AssignGetProviderByIDResponse(frame, getProviderByIDResponse), + test_utils.CheckName(updatedProviderName, getProviderByIDResponse), + ), + }, { // Check updating client secret has a diff + Config: updatedClientSecretConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check client secret can be updated + Config: updatedClientSecretConfig, + }, { // Expect import error if client secret is not given + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateId: "123:456", + ExpectError: regexp.MustCompile(`123:456`), + }, { // Expect importing works + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: func(state *terraform.State) (string, error) { + lastState := state.RootModule().Resources[frame.TerraformName].Primary + return fmt.Sprintf("%s:%s:%s", lastState.Attributes["org_id"], lastState.ID, importedSecret), nil + }, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"client_secret"}, + Check: func(state *terraform.State) error { + // Check the client_secret is imported correctly + currentState := state.RootModule().Resources[frame.TerraformName].Primary + actual := currentState.Attributes["client_secret"] + if actual != importedSecret { + return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) + } + return nil + }, + }, + }, + }) +} From 0b9adfdb36f929011c9a0db673e67e32fe8ea755 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 09:42:16 +0200 Subject: [PATCH 091/260] cleanup --- zitadel/v2/helper/client.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zitadel/v2/helper/client.go b/zitadel/v2/helper/client.go index 6fedd1ba..96955b67 100644 --- a/zitadel/v2/helper/client.go +++ b/zitadel/v2/helper/client.go @@ -77,10 +77,6 @@ func GetClientInfo(insecure bool, domain string, token string, jwtProfileFile st }, nil } -func (c *ClientInfo) GetAdminClient() { - -} - func GetAdminClient(info *ClientInfo) (*admin.Client, error) { client, err := admin.NewClient( info.Issuer, info.Domain, From b4a2d003538863272b70613010aac51bac73f617 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 09:58:18 +0200 Subject: [PATCH 092/260] remove redundant constants --- zitadel/v2/org_idp_github/datasource.go | 25 +++++------ zitadel/v2/org_idp_github/funcs.go | 56 +++++++++++++------------ zitadel/v2/org_idp_github/resource.go | 17 ++++---- zitadel/v2/org_idp_utils/const.go | 13 +----- zitadel/v2/org_idp_utils/funcs.go | 6 ++- 5 files changed, 56 insertions(+), 61 deletions(-) diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 1b488344..8512c698 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -2,6 +2,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -9,33 +10,33 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub IDP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.IdpIDVar: { + org_idp_utils.OrgIDVar: { Type: schema.TypeString, Required: true, - Description: "The ID of this resource.", + Description: "ID of the organization", }, - org_idp_utils.OrgIDVar: { + idp_utils.IdpIDVar: { Type: schema.TypeString, Required: true, - Description: "ID of the organization", + Description: "The ID of this resource.", }, - org_idp_utils.NameVar: { + idp_utils.NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the IDP", }, - org_idp_utils.ClientIDVar: { + idp_utils.ClientIDVar: { Type: schema.TypeString, Computed: true, Description: "client id generated by the identity provider", }, - org_idp_utils.ClientSecretVar: { + idp_utils.ClientSecretVar: { Type: schema.TypeString, Computed: true, Description: "client secret generated by the identity provider", Sensitive: true, }, - org_idp_utils.ScopesVar: { + idp_utils.ScopesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, @@ -43,22 +44,22 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - org_idp_utils.IsLinkingAllowedVar: { + idp_utils.IsLinkingAllowedVar: { Type: schema.TypeBool, Computed: true, Description: "enable if users should be able to link an existing ZITADEL user with an external account", }, - org_idp_utils.IsCreationAllowedVar: { + idp_utils.IsCreationAllowedVar: { Type: schema.TypeBool, Computed: true, Description: "enable if users should be able to create a new account in ZITADEL when using an external account", }, - org_idp_utils.IsAutoCreationVar: { + idp_utils.IsAutoCreationVar: { Type: schema.TypeBool, Computed: true, Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", }, - org_idp_utils.IsAutoUpdateVar: { + idp_utils.IsAutoUpdateVar: { Type: schema.TypeBool, Computed: true, Description: "enable if a the ZITADEL account fields should be updated automatically on each login", diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index 3d21e26a..e98ec6aa 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -3,6 +3,8 @@ package org_idp_github import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -23,15 +25,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitHubProvider(ctx, &management.AddGitHubProviderRequest{ - Name: d.Get(org_idp_utils.NameVar).(string), - ClientId: d.Get(org_idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(org_idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, org_idp_utils.ScopesVar), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(org_idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(org_idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(org_idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(org_idp_utils.IsAutoCreationVar).(bool), + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, }) if err != nil { @@ -50,18 +52,18 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(org_idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ Id: d.Id(), - Name: d.Get(org_idp_utils.NameVar).(string), - ClientId: d.Get(org_idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(org_idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, org_idp_utils.ScopesVar), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(org_idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(org_idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(org_idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(org_idp_utils.IsAutoUpdateVar).(bool), + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, }) if err != nil { @@ -80,7 +82,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { return diag.FromErr(err) } - resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, org_idp_utils.IdpIDVar)}) + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -93,15 +95,15 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithub() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), - org_idp_utils.NameVar: idp.GetName(), - org_idp_utils.ClientIDVar: specificCfg.GetClientId(), - org_idp_utils.ClientSecretVar: d.Get(org_idp_utils.ClientSecretVar).(string), - org_idp_utils.ScopesVar: specificCfg.GetScopes(), - org_idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - org_idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - org_idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - org_idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 99ef6e41..61b28b6e 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -2,6 +2,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -15,23 +16,23 @@ func GetResource() *schema.Resource { Description: "ID of the organization", ForceNew: true, }, - org_idp_utils.NameVar: { + idp_utils.NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the IDP", }, - org_idp_utils.ClientIDVar: { + idp_utils.ClientIDVar: { Type: schema.TypeString, Required: true, Description: "client id generated by the identity provider", }, - org_idp_utils.ClientSecretVar: { + idp_utils.ClientSecretVar: { Type: schema.TypeString, Required: true, Description: "client secret generated by the identity provider", Sensitive: true, }, - org_idp_utils.ScopesVar: { + idp_utils.ScopesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, @@ -39,22 +40,22 @@ func GetResource() *schema.Resource { Required: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - org_idp_utils.IsLinkingAllowedVar: { + idp_utils.IsLinkingAllowedVar: { Type: schema.TypeBool, Required: true, Description: "enable if users should be able to link an existing ZITADEL user with an external account", }, - org_idp_utils.IsCreationAllowedVar: { + idp_utils.IsCreationAllowedVar: { Type: schema.TypeBool, Required: true, Description: "enable if users should be able to create a new account in ZITADEL when using an external account", }, - org_idp_utils.IsAutoCreationVar: { + idp_utils.IsAutoCreationVar: { Type: schema.TypeBool, Required: true, Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", }, - org_idp_utils.IsAutoUpdateVar: { + idp_utils.IsAutoUpdateVar: { Type: schema.TypeBool, Required: true, Description: "enable if a the ZITADEL account fields should be updated automatically on each login", diff --git a/zitadel/v2/org_idp_utils/const.go b/zitadel/v2/org_idp_utils/const.go index 53d2e050..c3a14d49 100644 --- a/zitadel/v2/org_idp_utils/const.go +++ b/zitadel/v2/org_idp_utils/const.go @@ -1,16 +1,5 @@ package org_idp_utils -import "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - const ( - IdpIDVar = idp_utils.IdpIDVar - OrgIDVar = "org_id" - NameVar = idp_utils.NameVar - ClientIDVar = idp_utils.ClientIDVar - ClientSecretVar = idp_utils.ClientSecretVar - ScopesVar = idp_utils.ScopesVar - IsLinkingAllowedVar = idp_utils.IsLinkingAllowedVar - IsCreationAllowedVar = idp_utils.IsCreationAllowedVar - IsAutoCreationVar = idp_utils.IsAutoCreationVar - IsAutoUpdateVar = idp_utils.IsAutoUpdateVar + OrgIDVar = "org_id" ) diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index b4e8076f..452c8c2b 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -9,6 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -30,7 +32,7 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func ImportIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { id := data.Id() if id == "" { - return nil, fmt.Errorf("%s is not set", IdpIDVar) + return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) } parts := strings.SplitN(id, ":", 3) if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { @@ -40,7 +42,7 @@ func ImportIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceDat return nil, err } data.SetId(parts[1]) - if err := data.Set(ClientSecretVar, parts[2]); err != nil { + if err := data.Set(idp_utils.ClientSecretVar, parts[2]); err != nil { return nil, err } return []*schema.ResourceData{data}, nil From abfb29f7fdf7c655938cb17d207cb99a93cc2f78 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:03:52 +0200 Subject: [PATCH 093/260] fix sensitive attribute --- zitadel/v2/idp_github/resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index 66401f38..974e213f 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -19,12 +19,12 @@ func GetResource() *schema.Resource { Type: schema.TypeString, Required: true, Description: "client id generated by the identity provider", - Sensitive: true, }, idp_utils.ClientSecretVar: { Type: schema.TypeString, Required: true, Description: "client secret generated by the identity provider", + Sensitive: true, }, idp_utils.ScopesVar: { Type: schema.TypeSet, From ae05d3ecc900f131608ccbff40a414df29bb0bc7 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:17:17 +0200 Subject: [PATCH 094/260] feat: add GitHub ES instance IdP --- zitadel/provider.go | 4 + zitadel/v2/idp_github_es/datasource.go | 80 +++++++++++++++ zitadel/v2/idp_github_es/funcs.go | 120 ++++++++++++++++++++++ zitadel/v2/idp_github_es/resource.go | 79 ++++++++++++++ zitadel/v2/idp_github_es/resource_test.go | 32 ++++++ zitadel/v2/idp_utils/const.go | 21 ++-- 6 files changed, 327 insertions(+), 9 deletions(-) create mode 100644 zitadel/v2/idp_github_es/datasource.go create mode 100644 zitadel/v2/idp_github_es/funcs.go create mode 100644 zitadel/v2/idp_github_es/resource.go create mode 100644 zitadel/v2/idp_github_es/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 99e0b151..9d2b84fe 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -191,6 +193,7 @@ func Provider() *schema.Provider { "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), "zitadel_org_idp_github": org_idp_github.GetDatasource(), "zitadel_idp_github": idp_github.GetDatasource(), + "zitadel_idp_github_es": idp_github_es.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -251,6 +254,7 @@ func Provider() *schema.Provider { "zitadel_personal_access_token": pat.GetResource(), "zitadel_machine_key": machine_key.GetResource(), "zitadel_idp_github": idp_github.GetResource(), + "zitadel_idp_github_es": idp_github_es.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go new file mode 100644 index 00000000..b3de3814 --- /dev/null +++ b/zitadel/v2/idp_github_es/datasource.go @@ -0,0 +1,80 @@ +package idp_github_es + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.AuthorizationEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers authorization endpoint", + }, + idp_utils.TokenEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers token endpoint", + }, + idp_utils.UserEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers user endpoint", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_github_es/funcs.go b/zitadel/v2/idp_github_es/funcs.go new file mode 100644 index 00000000..0cbc6adc --- /dev/null +++ b/zitadel/v2/idp_github_es/funcs.go @@ -0,0 +1,120 @@ +package idp_github_es + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &admin.AddGitHubEnterpriseServerProviderRequest{ + ClientId: d.Get(idp_utils.ClientIDVar).(string), + Name: d.Get(idp_utils.NameVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &admin.UpdateGitHubEnterpriseServerProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGithubEs() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), + idp_utils.TokenEndpointVar: specificCfg.GetTokenEndpoint(), + idp_utils.UserEndpointVar: specificCfg.GetUserEndpoint(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/v2/idp_github_es/resource.go new file mode 100644 index 00000000..00c532d8 --- /dev/null +++ b/zitadel/v2/idp_github_es/resource.go @@ -0,0 +1,79 @@ +package idp_github_es + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.AuthorizationEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers authorization endpoint", + }, + idp_utils.TokenEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers token endpoint", + }, + idp_utils.UserEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers user endpoint", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go new file mode 100644 index 00000000..3c990e1d --- /dev/null +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -0,0 +1,32 @@ +package idp_github_es_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPGitHubES(t *testing.T) { + resourceName := "zitadel_idp_github_es" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go index 7ffa7dae..c727f28d 100644 --- a/zitadel/v2/idp_utils/const.go +++ b/zitadel/v2/idp_utils/const.go @@ -1,13 +1,16 @@ package idp_utils const ( - IdpIDVar = "id" - NameVar = "name" - ClientIDVar = "client_id" - ClientSecretVar = "client_secret" - ScopesVar = "scopes" - IsLinkingAllowedVar = "is_linking_allowed" - IsCreationAllowedVar = "is_creation_allowed" - IsAutoCreationVar = "is_auto_creation" - IsAutoUpdateVar = "is_auto_update" + IdpIDVar = "id" + NameVar = "name" + ClientIDVar = "client_id" + ClientSecretVar = "client_secret" + ScopesVar = "scopes" + IsLinkingAllowedVar = "is_linking_allowed" + IsCreationAllowedVar = "is_creation_allowed" + IsAutoCreationVar = "is_auto_creation" + IsAutoUpdateVar = "is_auto_update" + AuthorizationEndpointVar = "authorization_endpoint" + TokenEndpointVar = "token_endpoint" + UserEndpointVar = "user_endpoint" ) From 062fc88aed14af1e185718847dd5acfc7771708c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:25:28 +0200 Subject: [PATCH 095/260] feat: add GitHub ES org IdP --- zitadel/provider.go | 31 +++-- zitadel/v2/org_idp_github_es/datasource.go | 86 ++++++++++++ zitadel/v2/org_idp_github_es/funcs.go | 124 ++++++++++++++++++ zitadel/v2/org_idp_github_es/resource.go | 85 ++++++++++++ zitadel/v2/org_idp_github_es/resource_test.go | 33 +++++ 5 files changed, 345 insertions(+), 14 deletions(-) create mode 100644 zitadel/v2/org_idp_github_es/datasource.go create mode 100644 zitadel/v2/org_idp_github_es/funcs.go create mode 100644 zitadel/v2/org_idp_github_es/resource.go create mode 100644 zitadel/v2/org_idp_github_es/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 9d2b84fe..8d765f28 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -4,6 +4,7 @@ import ( "context" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" @@ -180,20 +181,21 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ - "zitadel_org": org.GetDatasource(), - "zitadel_human_user": human_user.GetDatasource(), - "zitadel_machine_user": machine_user.GetDatasource(), - "zitadel_project": project.GetDatasource(), - "zitadel_project_role": project_role.GetDatasource(), - "zitadel_action": action.GetDatasource(), - "zitadel_application_oidc": application_oidc.GetDatasource(), - "zitadel_application_api": application_api.GetDatasource(), - "zitadel_trigger_actions": trigger_actions.GetDatasource(), - "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), - "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), - "zitadel_org_idp_github": org_idp_github.GetDatasource(), - "zitadel_idp_github": idp_github.GetDatasource(), - "zitadel_idp_github_es": idp_github_es.GetDatasource(), + "zitadel_org": org.GetDatasource(), + "zitadel_human_user": human_user.GetDatasource(), + "zitadel_machine_user": machine_user.GetDatasource(), + "zitadel_project": project.GetDatasource(), + "zitadel_project_role": project_role.GetDatasource(), + "zitadel_action": action.GetDatasource(), + "zitadel_application_oidc": application_oidc.GetDatasource(), + "zitadel_application_api": application_api.GetDatasource(), + "zitadel_trigger_actions": trigger_actions.GetDatasource(), + "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), + "zitadel_org_idp_github": org_idp_github.GetDatasource(), + "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), + "zitadel_idp_github": idp_github.GetDatasource(), + "zitadel_idp_github_es": idp_github_es.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -258,6 +260,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), + "zitadel_org_idp_github_es": org_idp_github_es.GetResource(), "zitadel_default_label_policy": default_label_policy.GetResource(), "zitadel_default_login_policy": default_login_policy.GetResource(), "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go new file mode 100644 index 00000000..689ac55e --- /dev/null +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -0,0 +1,86 @@ +package org_idp_github_es + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.AuthorizationEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers authorization endpoint", + }, + idp_utils.TokenEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers token endpoint", + }, + idp_utils.UserEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers user endpoint", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/v2/org_idp_github_es/funcs.go new file mode 100644 index 00000000..3a2629c7 --- /dev/null +++ b/zitadel/v2/org_idp_github_es/funcs.go @@ -0,0 +1,124 @@ +package org_idp_github_es + +import ( + "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &management.AddGitHubEnterpriseServerProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &management.UpdateGitHubEnterpriseServerProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGithubEs() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), + idp_utils.TokenEndpointVar: specificCfg.GetTokenEndpoint(), + idp_utils.UserEndpointVar: specificCfg.GetUserEndpoint(), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go new file mode 100644 index 00000000..e47a47a1 --- /dev/null +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -0,0 +1,85 @@ +package org_idp_github_es + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.AuthorizationEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers authorization endpoint", + }, + idp_utils.TokenEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers token endpoint", + }, + idp_utils.UserEndpointVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers user endpoint", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go new file mode 100644 index 00000000..ee97753c --- /dev/null +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -0,0 +1,33 @@ +package org_idp_github_es_test + +import ( + "fmt" + "testing" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPGitHubES(t *testing.T) { + resourceName := "zitadel_org_idp_github_es" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }) +} From 8f0898014d75b5ed99fe833ca66d28014dee6190 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:41:56 +0200 Subject: [PATCH 096/260] feat: add GitLab instance idp --- zitadel/provider.go | 4 + zitadel/v2/idp_gitlab/datasource.go | 65 +++++++++++++++ zitadel/v2/idp_gitlab/funcs.go | 111 +++++++++++++++++++++++++ zitadel/v2/idp_gitlab/resource.go | 64 ++++++++++++++ zitadel/v2/idp_gitlab/resource_test.go | 29 +++++++ 5 files changed, 273 insertions(+) create mode 100644 zitadel/v2/idp_gitlab/datasource.go create mode 100644 zitadel/v2/idp_gitlab/funcs.go create mode 100644 zitadel/v2/idp_gitlab/resource.go create mode 100644 zitadel/v2/idp_gitlab/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 8d765f28..5451f110 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github_es" @@ -196,6 +198,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), "zitadel_idp_github": idp_github.GetDatasource(), "zitadel_idp_github_es": idp_github_es.GetDatasource(), + "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -257,6 +260,7 @@ func Provider() *schema.Provider { "zitadel_machine_key": machine_key.GetResource(), "zitadel_idp_github": idp_github.GetResource(), "zitadel_idp_github_es": idp_github_es.GetResource(), + "zitadel_idp_gitlab": idp_gitlab.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go new file mode 100644 index 00000000..2c7d6f9d --- /dev/null +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -0,0 +1,65 @@ +package idp_gitlab + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_gitlab/funcs.go b/zitadel/v2/idp_gitlab/funcs.go new file mode 100644 index 00000000..ee3ce76e --- /dev/null +++ b/zitadel/v2/idp_gitlab/funcs.go @@ -0,0 +1,111 @@ +package idp_gitlab + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitLabProvider(ctx, &admin.AddGitLabProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateGitLabProvider(ctx, &admin.UpdateGitLabProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGitlab() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/v2/idp_gitlab/resource.go new file mode 100644 index 00000000..6dc6d95a --- /dev/null +++ b/zitadel/v2/idp_gitlab/resource.go @@ -0,0 +1,64 @@ +package idp_gitlab + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go new file mode 100644 index 00000000..134ebbed --- /dev/null +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -0,0 +1,29 @@ +package idp_gitlab_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPGitLab(t *testing.T) { + resourceName := "zitadel_idp_gitlab" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} From 632fecbca9b54ceb90e91d9458840c5149b02269 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:48:52 +0200 Subject: [PATCH 097/260] feat: add GitLab Self Hosted instance idp --- zitadel/provider.go | 36 +++--- .../v2/idp_gitlab_self_hosted/datasource.go | 80 ++++++++++++ zitadel/v2/idp_gitlab_self_hosted/funcs.go | 114 ++++++++++++++++++ zitadel/v2/idp_gitlab_self_hosted/resource.go | 69 +++++++++++ .../idp_gitlab_self_hosted/resource_test.go | 30 +++++ zitadel/v2/idp_utils/const.go | 1 + 6 files changed, 314 insertions(+), 16 deletions(-) create mode 100644 zitadel/v2/idp_gitlab_self_hosted/datasource.go create mode 100644 zitadel/v2/idp_gitlab_self_hosted/funcs.go create mode 100644 zitadel/v2/idp_gitlab_self_hosted/resource.go create mode 100644 zitadel/v2/idp_gitlab_self_hosted/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 5451f110..d710c905 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" @@ -183,22 +185,23 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ - "zitadel_org": org.GetDatasource(), - "zitadel_human_user": human_user.GetDatasource(), - "zitadel_machine_user": machine_user.GetDatasource(), - "zitadel_project": project.GetDatasource(), - "zitadel_project_role": project_role.GetDatasource(), - "zitadel_action": action.GetDatasource(), - "zitadel_application_oidc": application_oidc.GetDatasource(), - "zitadel_application_api": application_api.GetDatasource(), - "zitadel_trigger_actions": trigger_actions.GetDatasource(), - "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), - "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), - "zitadel_org_idp_github": org_idp_github.GetDatasource(), - "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), - "zitadel_idp_github": idp_github.GetDatasource(), - "zitadel_idp_github_es": idp_github_es.GetDatasource(), - "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), + "zitadel_org": org.GetDatasource(), + "zitadel_human_user": human_user.GetDatasource(), + "zitadel_machine_user": machine_user.GetDatasource(), + "zitadel_project": project.GetDatasource(), + "zitadel_project_role": project_role.GetDatasource(), + "zitadel_action": action.GetDatasource(), + "zitadel_application_oidc": application_oidc.GetDatasource(), + "zitadel_application_api": application_api.GetDatasource(), + "zitadel_trigger_actions": trigger_actions.GetDatasource(), + "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), + "zitadel_org_idp_github": org_idp_github.GetDatasource(), + "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), + "zitadel_idp_github": idp_github.GetDatasource(), + "zitadel_idp_github_es": idp_github_es.GetDatasource(), + "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), + "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -261,6 +264,7 @@ func Provider() *schema.Provider { "zitadel_idp_github": idp_github.GetResource(), "zitadel_idp_github_es": idp_github_es.GetResource(), "zitadel_idp_gitlab": idp_gitlab.GetResource(), + "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go new file mode 100644 index 00000000..5dc48f33 --- /dev/null +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -0,0 +1,80 @@ +package idp_gitlab_self_hosted + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IssuerVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers issuer", + }, + idp_utils.TokenEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers token endpoint", + }, + idp_utils.UserEndpointVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers user endpoint", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_gitlab_self_hosted/funcs.go b/zitadel/v2/idp_gitlab_self_hosted/funcs.go new file mode 100644 index 00000000..48cc0b4b --- /dev/null +++ b/zitadel/v2/idp_gitlab_self_hosted/funcs.go @@ -0,0 +1,114 @@ +package idp_gitlab_self_hosted + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitLabSelfHostedProvider(ctx, &admin.AddGitLabSelfHostedProviderRequest{ + ClientId: d.Get(idp_utils.ClientIDVar).(string), + Name: d.Get(idp_utils.NameVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Issuer: d.Get(idp_utils.IssuerVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateGitLabSelfHostedProvider(ctx, &admin.UpdateGitLabSelfHostedProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Issuer: d.Get(idp_utils.IssuerVar).(string), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGitlabSelfHosted() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IssuerVar: specificCfg.GetIssuer(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/v2/idp_gitlab_self_hosted/resource.go new file mode 100644 index 00000000..62616c00 --- /dev/null +++ b/zitadel/v2/idp_gitlab_self_hosted/resource.go @@ -0,0 +1,69 @@ +package idp_gitlab_self_hosted + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IssuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers issuer", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go new file mode 100644 index 00000000..d6272783 --- /dev/null +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -0,0 +1,30 @@ +package idp_gitlab_self_hosted_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPGitLabSelfHosted(t *testing.T) { + resourceName := "zitadel_idp_gitlab_self_hosted" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + issuer = "https://issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go index c727f28d..045e3b7b 100644 --- a/zitadel/v2/idp_utils/const.go +++ b/zitadel/v2/idp_utils/const.go @@ -13,4 +13,5 @@ const ( AuthorizationEndpointVar = "authorization_endpoint" TokenEndpointVar = "token_endpoint" UserEndpointVar = "user_endpoint" + IssuerVar = "issuer" ) From 1e19cbb4d0b0007fb4fd043377d4371c004cf6e6 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 10:59:04 +0200 Subject: [PATCH 098/260] feat: add GitLab Self Hosted org idp --- zitadel/provider.go | 38 +++--- .../org_idp_gitlab_self_hosted/datasource.go | 76 +++++++++++ .../v2/org_idp_gitlab_self_hosted/funcs.go | 118 ++++++++++++++++++ .../v2/org_idp_gitlab_self_hosted/resource.go | 75 +++++++++++ .../resource_test.go | 31 +++++ 5 files changed, 321 insertions(+), 17 deletions(-) create mode 100644 zitadel/v2/org_idp_gitlab_self_hosted/datasource.go create mode 100644 zitadel/v2/org_idp_gitlab_self_hosted/funcs.go create mode 100644 zitadel/v2/org_idp_gitlab_self_hosted/resource.go create mode 100644 zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index d710c905..9f21c7fc 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" @@ -185,23 +187,24 @@ func (p *providerPV6) Resources(_ context.Context) []func() resource.Resource { func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ - "zitadel_org": org.GetDatasource(), - "zitadel_human_user": human_user.GetDatasource(), - "zitadel_machine_user": machine_user.GetDatasource(), - "zitadel_project": project.GetDatasource(), - "zitadel_project_role": project_role.GetDatasource(), - "zitadel_action": action.GetDatasource(), - "zitadel_application_oidc": application_oidc.GetDatasource(), - "zitadel_application_api": application_api.GetDatasource(), - "zitadel_trigger_actions": trigger_actions.GetDatasource(), - "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), - "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), - "zitadel_org_idp_github": org_idp_github.GetDatasource(), - "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), - "zitadel_idp_github": idp_github.GetDatasource(), - "zitadel_idp_github_es": idp_github_es.GetDatasource(), - "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), - "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), + "zitadel_org": org.GetDatasource(), + "zitadel_human_user": human_user.GetDatasource(), + "zitadel_machine_user": machine_user.GetDatasource(), + "zitadel_project": project.GetDatasource(), + "zitadel_project_role": project_role.GetDatasource(), + "zitadel_action": action.GetDatasource(), + "zitadel_application_oidc": application_oidc.GetDatasource(), + "zitadel_application_api": application_api.GetDatasource(), + "zitadel_trigger_actions": trigger_actions.GetDatasource(), + "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), + "zitadel_org_idp_github": org_idp_github.GetDatasource(), + "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), + "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), + "zitadel_idp_github": idp_github.GetDatasource(), + "zitadel_idp_github_es": idp_github_es.GetDatasource(), + "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), + "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -269,6 +272,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), "zitadel_org_idp_github_es": org_idp_github_es.GetResource(), + "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetResource(), "zitadel_default_label_policy": default_label_policy.GetResource(), "zitadel_default_login_policy": default_login_policy.GetResource(), "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go new file mode 100644 index 00000000..141ba79b --- /dev/null +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -0,0 +1,76 @@ +package org_idp_gitlab_self_hosted + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IssuerVar: { + Type: schema.TypeString, + Computed: true, + Description: "the providers issuer", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go new file mode 100644 index 00000000..628666be --- /dev/null +++ b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go @@ -0,0 +1,118 @@ +package org_idp_gitlab_self_hosted + +import ( + "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitLabSelfHostedProvider(ctx, &management.AddGitLabSelfHostedProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Issuer: d.Get(idp_utils.IssuerVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateGitLabSelfHostedProvider(ctx, &management.UpdateGitLabSelfHostedProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Issuer: d.Get(idp_utils.IssuerVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGitlabSelfHosted() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.IssuerVar: specificCfg.GetIssuer(), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go new file mode 100644 index 00000000..1eef0b44 --- /dev/null +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -0,0 +1,75 @@ +package org_idp_gitlab_self_hosted + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IssuerVar: { + Type: schema.TypeString, + Required: true, + Description: "the providers issuer", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go new file mode 100644 index 00000000..75dd831a --- /dev/null +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -0,0 +1,31 @@ +package org_idp_gitlab_self_hosted_test + +import ( + "fmt" + "testing" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPGitLabSelfHosted(t *testing.T) { + resourceName := "zitadel_org_idp_gitlab_self_hosted" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + issuer = "https://issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }) +} From 000a1a7f431b3ffa09732f577032a0a7ec42459c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 11:03:45 +0200 Subject: [PATCH 099/260] feat: add GitLab org idp --- zitadel/provider.go | 4 + zitadel/v2/org_idp_gitlab/datasource.go | 71 +++++++++++++ zitadel/v2/org_idp_gitlab/funcs.go | 115 +++++++++++++++++++++ zitadel/v2/org_idp_gitlab/resource.go | 70 +++++++++++++ zitadel/v2/org_idp_gitlab/resource_test.go | 30 ++++++ 5 files changed, 290 insertions(+) create mode 100644 zitadel/v2/org_idp_gitlab/datasource.go create mode 100644 zitadel/v2/org_idp_gitlab/funcs.go create mode 100644 zitadel/v2/org_idp_gitlab/resource.go create mode 100644 zitadel/v2/org_idp_gitlab/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 9f21c7fc..c2972cbe 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" @@ -200,6 +202,7 @@ func Provider() *schema.Provider { "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), "zitadel_org_idp_github": org_idp_github.GetDatasource(), "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), + "zitadel_org_idp_gitlab": org_idp_gitlab.GetDatasource(), "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), "zitadel_idp_github": idp_github.GetDatasource(), "zitadel_idp_github_es": idp_github_es.GetDatasource(), @@ -272,6 +275,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), "zitadel_org_idp_github_es": org_idp_github_es.GetResource(), + "zitadel_org_idp_gitlab": org_idp_gitlab.GetResource(), "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetResource(), "zitadel_default_label_policy": default_label_policy.GetResource(), "zitadel_default_login_policy": default_login_policy.GetResource(), diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go new file mode 100644 index 00000000..3662ddeb --- /dev/null +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -0,0 +1,71 @@ +package org_idp_gitlab + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_gitlab/funcs.go b/zitadel/v2/org_idp_gitlab/funcs.go new file mode 100644 index 00000000..ce54737a --- /dev/null +++ b/zitadel/v2/org_idp_gitlab/funcs.go @@ -0,0 +1,115 @@ +package org_idp_gitlab + +import ( + "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGitLabProvider(ctx, &management.AddGitLabProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateGitLabProvider(ctx, &management.UpdateGitLabProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGitlab() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go new file mode 100644 index 00000000..c5435beb --- /dev/null +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -0,0 +1,70 @@ +package org_idp_gitlab + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go new file mode 100644 index 00000000..7de04fd4 --- /dev/null +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -0,0 +1,30 @@ +package org_idp_gitlab_test + +import ( + "fmt" + "testing" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPGitLab(t *testing.T) { + resourceName := "zitadel_org_idp_gitlab" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }) +} From 359380ce41ee536762cb052081c8c0caa9bc0749 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 11:09:07 +0200 Subject: [PATCH 100/260] feat: add Google org idp --- zitadel/provider.go | 4 + zitadel/v2/idp_google/datasource.go | 65 +++++++++++++++ zitadel/v2/idp_google/funcs.go | 111 +++++++++++++++++++++++++ zitadel/v2/idp_google/resource.go | 64 ++++++++++++++ zitadel/v2/idp_google/resource_test.go | 29 +++++++ 5 files changed, 273 insertions(+) create mode 100644 zitadel/v2/idp_google/datasource.go create mode 100644 zitadel/v2/idp_google/funcs.go create mode 100644 zitadel/v2/idp_google/resource.go create mode 100644 zitadel/v2/idp_google/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index c2972cbe..99a7b3ba 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" @@ -208,6 +210,7 @@ func Provider() *schema.Provider { "zitadel_idp_github_es": idp_github_es.GetDatasource(), "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), + "zitadel_idp_google": idp_google.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -270,6 +273,7 @@ func Provider() *schema.Provider { "zitadel_idp_github": idp_github.GetResource(), "zitadel_idp_github_es": idp_github_es.GetResource(), "zitadel_idp_gitlab": idp_gitlab.GetResource(), + "zitadel_idp_google": idp_google.GetResource(), "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go new file mode 100644 index 00000000..228e202c --- /dev/null +++ b/zitadel/v2/idp_google/datasource.go @@ -0,0 +1,65 @@ +package idp_google + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_google/funcs.go b/zitadel/v2/idp_google/funcs.go new file mode 100644 index 00000000..7f680f8a --- /dev/null +++ b/zitadel/v2/idp_google/funcs.go @@ -0,0 +1,111 @@ +package idp_google + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGoogleProvider(ctx, &admin.AddGoogleProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateGoogleProvider(ctx, &admin.UpdateGoogleProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGoogle() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/v2/idp_google/resource.go new file mode 100644 index 00000000..4f95dc33 --- /dev/null +++ b/zitadel/v2/idp_google/resource.go @@ -0,0 +1,64 @@ +package idp_google + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go new file mode 100644 index 00000000..00f25a0a --- /dev/null +++ b/zitadel/v2/idp_google/resource_test.go @@ -0,0 +1,29 @@ +package idp_google_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPGoogle(t *testing.T) { + resourceName := "zitadel_idp_google" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} From 545d3c3e414509567bb67cdf096a0858587ffaea Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 12:05:38 +0200 Subject: [PATCH 101/260] feat: add Azure AD instance idp --- zitadel/provider.go | 4 + zitadel/v2/idp_azure_ad/datasource.go | 80 ++++++++++++++ zitadel/v2/idp_azure_ad/funcs.go | 133 +++++++++++++++++++++++ zitadel/v2/idp_azure_ad/resource.go | 82 ++++++++++++++ zitadel/v2/idp_azure_ad/resource_test.go | 32 ++++++ zitadel/v2/idp_utils/const.go | 3 + 6 files changed, 334 insertions(+) create mode 100644 zitadel/v2/idp_azure_ad/datasource.go create mode 100644 zitadel/v2/idp_azure_ad/funcs.go create mode 100644 zitadel/v2/idp_azure_ad/resource.go create mode 100644 zitadel/v2/idp_azure_ad/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 99a7b3ba..009dba82 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" @@ -211,6 +213,7 @@ func Provider() *schema.Provider { "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), "zitadel_idp_google": idp_google.GetDatasource(), + "zitadel_idp_azure_ad": idp_azure_ad.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -274,6 +277,7 @@ func Provider() *schema.Provider { "zitadel_idp_github_es": idp_github_es.GetResource(), "zitadel_idp_gitlab": idp_gitlab.GetResource(), "zitadel_idp_google": idp_google.GetResource(), + "zitadel_idp_azure_ad": idp_azure_ad.GetResource(), "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go new file mode 100644 index 00000000..ae88e2ca --- /dev/null +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -0,0 +1,80 @@ +package idp_azure_ad + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.TenantTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant type", + }, + idp_utils.TenantIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant id", + }, + idp_utils.EmailVerifiedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "automatically mark emails as verified", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go new file mode 100644 index 00000000..b72238ba --- /dev/null +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -0,0 +1,133 @@ +package idp_azure_ad + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddAzureADProvider(ctx, &admin.AddAzureADProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Tenant: constructTenant(d), + EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Tenant: constructTenant(d), + EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + respIdp := resp.GetIdp() + cfg := respIdp.GetConfig() + specificCfg := cfg.GetAzureAd() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: respIdp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.EmailVerifiedVar: specificCfg.GetEmailVerified(), + idp_utils.TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], + idp_utils.TenantIDVar: specificCfg.GetTenant().GetTenantId(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(respIdp.Id) + return nil +} + +func constructTenant(d *schema.ResourceData) *idp.AzureADTenant { + tenant := &idp.AzureADTenant{} + tenantId := d.Get(idp_utils.TenantIDVar).(string) + if tenantId != "" { + tenant.Type = &idp.AzureADTenant_TenantId{ + TenantId: tenantId, + } + } else { + tenant.Type = &idp.AzureADTenant_TenantType{ + TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[d.Get(idp_utils.TenantTypeVar).(string)]), + } + } + return tenant +} diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/v2/idp_azure_ad/resource.go new file mode 100644 index 00000000..ccfd8175 --- /dev/null +++ b/zitadel/v2/idp_azure_ad/resource.go @@ -0,0 +1,82 @@ +package idp_azure_ad + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.TenantTypeVar: { + Type: schema.TypeString, + Optional: true, + Default: "AZURE_AD_TENANT_TYPE_COMMON", + Description: "the azure ad tenant type", + }, + idp_utils.TenantIDVar: { + Type: schema.TypeString, + Optional: true, + Description: fmt.Sprintf("if %s is not set, the %s is used", idp_utils.TenantIDVar, idp_utils.TenantTypeVar), + }, + idp_utils.EmailVerifiedVar: { + Type: schema.TypeBool, + Required: true, + Description: "automatically mark emails as verified", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + } +} diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go new file mode 100644 index 00000000..cc6c65da --- /dev/null +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -0,0 +1,32 @@ +package idp_azure_ad_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPAzureAD(t *testing.T) { + resourceName := "zitadel_idp_azure_ad" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" + tenant_id = "atenantid" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }) +} diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go index 045e3b7b..a32fb40b 100644 --- a/zitadel/v2/idp_utils/const.go +++ b/zitadel/v2/idp_utils/const.go @@ -14,4 +14,7 @@ const ( TokenEndpointVar = "token_endpoint" UserEndpointVar = "user_endpoint" IssuerVar = "issuer" + TenantTypeVar = "tenant_type" + TenantIDVar = "tenant_id" + EmailVerifiedVar = "email_verified" ) From c06c52021f0258d95fa83869fef48e69e7fccccc Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 12:11:38 +0200 Subject: [PATCH 102/260] feat: add Google org idp --- .gitignore | 1 + zitadel/provider.go | 38 ++++--- zitadel/v2/org_idp_google/datasource.go | 71 +++++++++++++ zitadel/v2/org_idp_google/funcs.go | 115 +++++++++++++++++++++ zitadel/v2/org_idp_google/resource.go | 70 +++++++++++++ zitadel/v2/org_idp_google/resource_test.go | 30 ++++++ 6 files changed, 308 insertions(+), 17 deletions(-) create mode 100644 zitadel/v2/org_idp_google/datasource.go create mode 100644 zitadel/v2/org_idp_google/funcs.go create mode 100644 zitadel/v2/org_idp_google/resource.go create mode 100644 zitadel/v2/org_idp_google/resource_test.go diff --git a/.gitignore b/.gitignore index 85ff4cce..2200f7d0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ override.tf.json # IDEs .idea +.run # local binary terraform-provider-zitadel diff --git a/zitadel/provider.go b/zitadel/provider.go index 009dba82..1163c5d3 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" @@ -202,18 +204,19 @@ func Provider() *schema.Provider { "zitadel_application_oidc": application_oidc.GetDatasource(), "zitadel_application_api": application_api.GetDatasource(), "zitadel_trigger_actions": trigger_actions.GetDatasource(), - "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), - "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), - "zitadel_org_idp_github": org_idp_github.GetDatasource(), - "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), - "zitadel_org_idp_gitlab": org_idp_gitlab.GetDatasource(), - "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), "zitadel_idp_github": idp_github.GetDatasource(), "zitadel_idp_github_es": idp_github_es.GetDatasource(), "zitadel_idp_gitlab": idp_gitlab.GetDatasource(), "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), "zitadel_idp_google": idp_google.GetDatasource(), "zitadel_idp_azure_ad": idp_azure_ad.GetDatasource(), + "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), + "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), + "zitadel_org_idp_github": org_idp_github.GetDatasource(), + "zitadel_org_idp_github_es": org_idp_github_es.GetDatasource(), + "zitadel_org_idp_gitlab": org_idp_gitlab.GetDatasource(), + "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), + "zitadel_org_idp_google": org_idp_google.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -273,28 +276,29 @@ func Provider() *schema.Provider { "zitadel_trigger_actions": trigger_actions.GetResource(), "zitadel_personal_access_token": pat.GetResource(), "zitadel_machine_key": machine_key.GetResource(), + "zitadel_default_label_policy": default_label_policy.GetResource(), + "zitadel_default_login_policy": default_login_policy.GetResource(), + "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), + "zitadel_default_domain_policy": default_domain_policy.GetResource(), + "zitadel_default_privacy_policy": default_privacy_policy.GetResource(), + "zitadel_default_password_complexity_policy": default_password_complexity_policy.GetResource(), + "zitadel_sms_provider_twilio": sms_provider_twilio.GetResource(), + "zitadel_smtp_config": smtp_config.GetResource(), + "zitadel_default_notification_policy": default_notification_policy.GetResource(), + "zitadel_notification_policy": notification_policy.GetResource(), "zitadel_idp_github": idp_github.GetResource(), "zitadel_idp_github_es": idp_github_es.GetResource(), "zitadel_idp_gitlab": idp_gitlab.GetResource(), + "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_idp_google": idp_google.GetResource(), "zitadel_idp_azure_ad": idp_azure_ad.GetResource(), - "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), "zitadel_org_idp_github_es": org_idp_github_es.GetResource(), "zitadel_org_idp_gitlab": org_idp_gitlab.GetResource(), "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetResource(), - "zitadel_default_label_policy": default_label_policy.GetResource(), - "zitadel_default_login_policy": default_login_policy.GetResource(), - "zitadel_default_lockout_policy": default_lockout_policy.GetResource(), - "zitadel_default_domain_policy": default_domain_policy.GetResource(), - "zitadel_default_privacy_policy": default_privacy_policy.GetResource(), - "zitadel_default_password_complexity_policy": default_password_complexity_policy.GetResource(), - "zitadel_sms_provider_twilio": sms_provider_twilio.GetResource(), - "zitadel_smtp_config": smtp_config.GetResource(), - "zitadel_default_notification_policy": default_notification_policy.GetResource(), - "zitadel_notification_policy": notification_policy.GetResource(), + "zitadel_org_idp_google": org_idp_google.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go new file mode 100644 index 00000000..61526543 --- /dev/null +++ b/zitadel/v2/org_idp_google/datasource.go @@ -0,0 +1,71 @@ +package org_idp_google + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_google/funcs.go b/zitadel/v2/org_idp_google/funcs.go new file mode 100644 index 00000000..8fe8d86f --- /dev/null +++ b/zitadel/v2/org_idp_google/funcs.go @@ -0,0 +1,115 @@ +package org_idp_google + +import ( + "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddGoogleProvider(ctx, &management.AddGoogleProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateGoogleProvider(ctx, &management.UpdateGoogleProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetGoogle() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go new file mode 100644 index 00000000..5711ad32 --- /dev/null +++ b/zitadel/v2/org_idp_google/resource.go @@ -0,0 +1,70 @@ +package org_idp_google + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go new file mode 100644 index 00000000..4f9edcd6 --- /dev/null +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -0,0 +1,30 @@ +package org_idp_google_test + +import ( + "fmt" + "testing" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPGoogle(t *testing.T) { + resourceName := "zitadel_org_idp_google" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }) +} From 7a90a3fc0627b9b3e84b204ba1d8c1385ebe8040 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 15:08:44 +0200 Subject: [PATCH 103/260] feat: add Azure AD org idp --- zitadel/provider.go | 3 + zitadel/v2/idp_azure_ad/funcs.go | 6 +- zitadel/v2/org_idp_azure_ad/datasource.go | 86 +++++++++++++ zitadel/v2/org_idp_azure_ad/funcs.go | 124 +++++++++++++++++++ zitadel/v2/org_idp_azure_ad/resource.go | 88 +++++++++++++ zitadel/v2/org_idp_azure_ad/resource_test.go | 33 +++++ 6 files changed, 337 insertions(+), 3 deletions(-) create mode 100644 zitadel/v2/org_idp_azure_ad/datasource.go create mode 100644 zitadel/v2/org_idp_azure_ad/funcs.go create mode 100644 zitadel/v2/org_idp_azure_ad/resource.go create mode 100644 zitadel/v2/org_idp_azure_ad/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 1163c5d3..1d17dbf2 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -2,6 +2,7 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" @@ -217,6 +218,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_gitlab": org_idp_gitlab.GetDatasource(), "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), "zitadel_org_idp_google": org_idp_google.GetDatasource(), + "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -299,6 +301,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_gitlab": org_idp_gitlab.GetResource(), "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_google": org_idp_google.GetResource(), + "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go index b72238ba..a6d68df9 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -25,7 +25,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Name: d.Get(idp_utils.NameVar).(string), ClientId: d.Get(idp_utils.ClientIDVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Tenant: constructTenant(d), + Tenant: ConstructTenant(d), EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ @@ -58,7 +58,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientId: d.Get(idp_utils.ClientIDVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - Tenant: constructTenant(d), + Tenant: ConstructTenant(d), EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), @@ -117,7 +117,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } -func constructTenant(d *schema.ResourceData) *idp.AzureADTenant { +func ConstructTenant(d *schema.ResourceData) *idp.AzureADTenant { tenant := &idp.AzureADTenant{} tenantId := d.Get(idp_utils.TenantIDVar).(string) if tenantId != "" { diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go new file mode 100644 index 00000000..3579a047 --- /dev/null +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -0,0 +1,86 @@ +package org_idp_azure_ad + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing a GitHub IDP of the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.TenantTypeVar: { + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant type", + }, + idp_utils.TenantIDVar: { + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant id", + }, + idp_utils.EmailVerifiedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "automatically mark emails as verified", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go new file mode 100644 index 00000000..fa0eff68 --- /dev/null +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -0,0 +1,124 @@ +package org_idp_azure_ad + +import ( + "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddAzureADProvider(ctx, &management.AddAzureADProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + respIdp := resp.GetIdp() + cfg := respIdp.GetConfig() + specificCfg := cfg.GetAzureAd() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: respIdp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: respIdp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.EmailVerifiedVar: specificCfg.GetEmailVerified(), + idp_utils.TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], + idp_utils.TenantIDVar: specificCfg.GetTenant().GetTenantId(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(respIdp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go new file mode 100644 index 00000000..d1d9af35 --- /dev/null +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -0,0 +1,88 @@ +package org_idp_azure_ad + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing a OIDC IDP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ClientIDVar: { + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + }, + idp_utils.ClientSecretVar: { + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + }, + idp_utils.ScopesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + }, + idp_utils.TenantTypeVar: { + Type: schema.TypeString, + Optional: true, + Default: "AZURE_AD_TENANT_TYPE_COMMON", + Description: "the azure ad tenant type", + }, + idp_utils.TenantIDVar: { + Type: schema.TypeString, + Optional: true, + Description: fmt.Sprintf("if %s is not set, the %s is used", idp_utils.TenantIDVar, idp_utils.TenantTypeVar), + }, + idp_utils.EmailVerifiedVar: { + Type: schema.TypeBool, + Required: true, + Description: "automatically mark emails as verified", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + } +} diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go new file mode 100644 index 00000000..1f974b36 --- /dev/null +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -0,0 +1,33 @@ +package org_idp_azure_ad_test + +import ( + "fmt" + "testing" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPAzureAD(t *testing.T) { + resourceName := "zitadel_org_idp_azure_ad" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + scopes = ["two", "scopes"] + tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" + tenant_id = "atenantid" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }) +} From db9c4d400514575fe090a43fb1d9808da7411d42 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 18:26:48 +0200 Subject: [PATCH 104/260] feat: add LDAP instance idp --- go.mod | 10 +- go.sum | 22 +- zitadel/provider.go | 4 + zitadel/v2/idp_azure_ad/datasource.go | 4 +- zitadel/v2/idp_azure_ad/resource.go | 4 +- zitadel/v2/idp_azure_ad/resource_test.go | 2 +- zitadel/v2/idp_github/datasource.go | 2 +- zitadel/v2/idp_github/resource.go | 4 +- zitadel/v2/idp_github/resource_test.go | 2 +- zitadel/v2/idp_github_es/datasource.go | 4 +- zitadel/v2/idp_github_es/resource.go | 4 +- zitadel/v2/idp_github_es/resource_test.go | 2 +- zitadel/v2/idp_gitlab/datasource.go | 4 +- zitadel/v2/idp_gitlab/resource.go | 4 +- zitadel/v2/idp_gitlab/resource_test.go | 2 +- .../v2/idp_gitlab_self_hosted/datasource.go | 4 +- zitadel/v2/idp_gitlab_self_hosted/resource.go | 4 +- .../idp_gitlab_self_hosted/resource_test.go | 2 +- zitadel/v2/idp_google/datasource.go | 4 +- zitadel/v2/idp_google/resource.go | 4 +- zitadel/v2/idp_google/resource_test.go | 2 +- zitadel/v2/idp_ldap/datasource.go | 166 +++++++++++++++ zitadel/v2/idp_ldap/funcs.go | 194 ++++++++++++++++++ zitadel/v2/idp_ldap/resource.go | 165 +++++++++++++++ zitadel/v2/idp_ldap/resource_test.go | 38 ++++ zitadel/v2/idp_utils/const.go | 24 +++ zitadel/v2/idp_utils/funcs.go | 29 +-- .../v2/idp_utils/test_utils/lifecyletest.go | 21 +- zitadel/v2/org_idp_azure_ad/datasource.go | 2 +- zitadel/v2/org_idp_azure_ad/resource.go | 2 +- zitadel/v2/org_idp_github/datasource.go | 2 +- zitadel/v2/org_idp_github/resource.go | 2 +- zitadel/v2/org_idp_github_es/datasource.go | 2 +- zitadel/v2/org_idp_github_es/resource.go | 2 +- zitadel/v2/org_idp_gitlab/datasource.go | 2 +- zitadel/v2/org_idp_gitlab/resource.go | 2 +- .../org_idp_gitlab_self_hosted/datasource.go | 2 +- .../v2/org_idp_gitlab_self_hosted/resource.go | 2 +- zitadel/v2/org_idp_google/datasource.go | 2 +- zitadel/v2/org_idp_google/resource.go | 2 +- zitadel/v2/org_idp_jwt/datasource.go | 2 +- zitadel/v2/org_idp_jwt/resource.go | 2 +- zitadel/v2/org_idp_oidc/datasource.go | 2 +- zitadel/v2/org_idp_oidc/resource.go | 2 +- 44 files changed, 678 insertions(+), 85 deletions(-) create mode 100644 zitadel/v2/idp_ldap/datasource.go create mode 100644 zitadel/v2/idp_ldap/funcs.go create mode 100644 zitadel/v2/idp_ldap/resource.go create mode 100644 zitadel/v2/idp_ldap/resource_test.go diff --git a/go.mod b/go.mod index 395cec1a..899c4060 100644 --- a/go.mod +++ b/go.mod @@ -15,8 +15,8 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 github.com/zitadel/oidc v1.13.2 - github.com/zitadel/zitadel-go/v2 v2.0.12 - golang.org/x/oauth2 v0.6.0 + github.com/zitadel/zitadel-go/v2 v2.0.13 + golang.org/x/oauth2 v0.7.0 google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.30.0 ) @@ -73,9 +73,9 @@ require ( github.com/zclconf/go-cty v1.13.1 // indirect golang.org/x/crypto v0.7.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect diff --git a/go.sum b/go.sum index 2da5a601..bf0d8abe 100644 --- a/go.sum +++ b/go.sum @@ -341,8 +341,8 @@ github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4 github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.13.2 h1:DiwAgHtw1kKcngNzLjgv1/oRL1OjdYf3emEsFzQzraI= github.com/zitadel/oidc v1.13.2/go.mod h1:GUywRhXAiTvvjdRdXblmGknDOeMwrsdMxTRCypi6974= -github.com/zitadel/zitadel-go/v2 v2.0.12 h1:uLboL/Cx+1UG2evYiMNS7RHqkRbFOrooOBngbD2UN3A= -github.com/zitadel/zitadel-go/v2 v2.0.12/go.mod h1:pqPiKbTGSslWF7qv9T73zn/oK+AqTR/sq4MjbPRB0EQ= +github.com/zitadel/zitadel-go/v2 v2.0.13 h1:TZ44dgEJHtJKsiAW2CbBIYiEjyHSrH8qZ5Wi1qUAP50= +github.com/zitadel/zitadel-go/v2 v2.0.13/go.mod h1:T4tAZyYIsq+7dRzfnlJse1b60gjVczHJCMGE5Nqg0ak= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -433,16 +433,16 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -500,12 +500,12 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.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/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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= 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= @@ -514,8 +514,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/zitadel/provider.go b/zitadel/provider.go index 1d17dbf2..8bfed71b 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -2,6 +2,8 @@ package zitadel import ( "context" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" @@ -211,6 +213,7 @@ func Provider() *schema.Provider { "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetDatasource(), "zitadel_idp_google": idp_google.GetDatasource(), "zitadel_idp_azure_ad": idp_azure_ad.GetDatasource(), + "zitadel_idp_ldap": idp_ldap.GetDatasource(), "zitadel_org_jwt_idp": org_idp_jwt.GetDatasource(), "zitadel_org_oidc_idp": org_idp_oidc.GetDatasource(), "zitadel_org_idp_github": org_idp_github.GetDatasource(), @@ -294,6 +297,7 @@ func Provider() *schema.Provider { "zitadel_idp_gitlab_self_hosted": idp_gitlab_self_hosted.GetResource(), "zitadel_idp_google": idp_google.GetResource(), "zitadel_idp_azure_ad": idp_azure_ad.GetResource(), + "zitadel_idp_ldap": idp_ldap.GetResource(), "zitadel_org_idp_jwt": org_idp_jwt.GetResource(), "zitadel_org_idp_oidc": org_idp_oidc.GetResource(), "zitadel_org_idp_github": org_idp_github.GetResource(), diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go index ae88e2ca..54a7ac20 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -7,7 +7,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP on the instance.", + Description: "Datasource representing an Azure AD IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: { Type: schema.TypeString, @@ -75,6 +75,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/v2/idp_azure_ad/resource.go index ccfd8175..10897fd5 100644 --- a/zitadel/v2/idp_azure_ad/resource.go +++ b/zitadel/v2/idp_azure_ad/resource.go @@ -10,7 +10,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing an Azure AD IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -77,6 +77,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index cc6c65da..f50f0409 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -28,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go index d9eabd01..3d3f7733 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/v2/idp_github/datasource.go @@ -60,6 +60,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index 974e213f..cc4bbc5d 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing a GitHub IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -59,6 +59,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index 3124ea94..79a4ad2b 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -25,5 +25,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go index b3de3814..1773e7a8 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/v2/idp_github_es/datasource.go @@ -7,7 +7,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP on the instance.", + Description: "Datasource representing a GitHub Enterprise IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: { Type: schema.TypeString, @@ -75,6 +75,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/v2/idp_github_es/resource.go index 00c532d8..04627b6b 100644 --- a/zitadel/v2/idp_github_es/resource.go +++ b/zitadel/v2/idp_github_es/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing a GitHub Enterprise IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -74,6 +74,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index 3c990e1d..f3904769 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -28,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go index 2c7d6f9d..56ce45dd 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -7,7 +7,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP on the instance.", + Description: "Datasource representing a GitLab IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: { Type: schema.TypeString, @@ -60,6 +60,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/v2/idp_gitlab/resource.go index 6dc6d95a..21c8bb9a 100644 --- a/zitadel/v2/idp_gitlab/resource.go +++ b/zitadel/v2/idp_gitlab/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing a GitLab IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -59,6 +59,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index 134ebbed..8a71a9d0 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -25,5 +25,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go index 5dc48f33..f9f7b29b 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -7,7 +7,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP on the instance.", + Description: "Datasource representing a GitLab Self Hosted IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: { Type: schema.TypeString, @@ -75,6 +75,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/v2/idp_gitlab_self_hosted/resource.go index 62616c00..e1ce7efa 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing a GitLab Self Hosted IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -64,6 +64,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go index d6272783..b999ef22 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -26,5 +26,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go index 228e202c..68c6d6fa 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/v2/idp_google/datasource.go @@ -7,7 +7,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP on the instance.", + Description: "Datasource representing a Google IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: { Type: schema.TypeString, @@ -60,6 +60,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/v2/idp_google/resource.go index 4f95dc33..a8ebeb57 100644 --- a/zitadel/v2/idp_google/resource.go +++ b/zitadel/v2/idp_google/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the instance.", + Description: "Resource representing a Google IDP on the instance.", Schema: map[string]*schema.Schema{ idp_utils.NameVar: { Type: schema.TypeString, @@ -59,6 +59,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithClientSecret}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index 00f25a0a..e83bd625 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -25,5 +25,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }) + }, "client_secret") } diff --git a/zitadel/v2/idp_ldap/datasource.go b/zitadel/v2/idp_ldap/datasource.go new file mode 100644 index 00000000..4eaedf65 --- /dev/null +++ b/zitadel/v2/idp_ldap/datasource.go @@ -0,0 +1,166 @@ +package idp_ldap + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an LDAP IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ServersVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Servers to try in order for establishing LDAP connections", + }, + idp_utils.StartTLSVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Wether to use StartTLS for LDAP connections", + }, + idp_utils.BaseDNVar: { + Type: schema.TypeString, + Computed: true, + Description: "Base DN for LDAP connections", + }, + idp_utils.BindDNVar: { + Type: schema.TypeString, + Computed: true, + Description: "Bind DN for LDAP connections", + }, + idp_utils.BindPasswordVar: { + Type: schema.TypeString, + Computed: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + }, + idp_utils.UserBaseVar: { + Type: schema.TypeString, + Computed: true, + Description: "User base for LDAP connections", + }, + idp_utils.UserObjectClassesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User object classes for LDAP connections", + }, + idp_utils.UserFiltersVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User filters for LDAP connections", + }, + idp_utils.TimeoutVar: { + Type: schema.TypeString, + Computed: true, + Description: "Timeout for LDAP connections", + }, + idp_utils.IdAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the id", + }, + idp_utils.FirstNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the first name", + }, + idp_utils.LastNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the last name", + }, + idp_utils.DisplayNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the display name", + }, + idp_utils.NickNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the nick name", + }, + idp_utils.PreferredUsernameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred username", + }, + idp_utils.EmailAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email", + }, + idp_utils.EmailVerifiedAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email verified state", + }, + idp_utils.PhoneAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone", + }, + idp_utils.PhoneVerifiedAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone verified state", + }, + idp_utils.PreferredLanguageAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred language", + }, + idp_utils.AvatarURLAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the avatar url", + }, + idp_utils.ProfileAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the profile", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, + } +} diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/v2/idp_ldap/funcs.go new file mode 100644 index 00000000..90740360 --- /dev/null +++ b/zitadel/v2/idp_ldap/funcs.go @@ -0,0 +1,194 @@ +package idp_ldap + +import ( + "context" + "time" + + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + req := &admin.AddLDAPProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + Servers: interfaceToStringSlice(d.Get(idp_utils.ServersVar)), + StartTls: d.Get(idp_utils.StartTLSVar).(bool), + BaseDn: d.Get(idp_utils.BaseDNVar).(string), + BindDn: d.Get(idp_utils.BindDNVar).(string), + BindPassword: d.Get(idp_utils.BindPasswordVar).(string), + UserBase: d.Get(idp_utils.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), + Timeout: durationpb.New(timeout), + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), + }, + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + } + resp, err := client.AddLDAPProvider(ctx, req) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar) { + _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + Servers: interfaceToStringSlice(d.Get(idp_utils.ServersVar)), + StartTls: d.Get(idp_utils.StartTLSVar).(bool), + BaseDn: d.Get(idp_utils.BaseDNVar).(string), + BindDn: d.Get(idp_utils.BindDNVar).(string), + BindPassword: d.Get(idp_utils.BindPasswordVar).(string), + UserBase: d.Get(idp_utils.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), + Timeout: durationpb.New(timeout), + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), + }, + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetLdap() + attributesCfg := specificCfg.GetAttributes() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + idp_utils.NameVar: idp.GetName(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_utils.ServersVar: specificCfg.GetServers(), + idp_utils.StartTLSVar: specificCfg.GetStartTls(), + idp_utils.BaseDNVar: specificCfg.GetBaseDn(), + idp_utils.BindDNVar: specificCfg.GetBindDn(), + idp_utils.BindPasswordVar: d.Get(idp_utils.BindPasswordVar).(string), + idp_utils.UserBaseVar: specificCfg.GetUserBase(), + idp_utils.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), + idp_utils.UserFiltersVar: specificCfg.GetUserFilters(), + idp_utils.TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), + idp_utils.IdAttributeVar: attributesCfg.GetIdAttribute(), + idp_utils.FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), + idp_utils.LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), + idp_utils.DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), + idp_utils.NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), + idp_utils.PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), + idp_utils.EmailAttributeVar: attributesCfg.GetEmailAttribute(), + idp_utils.EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), + idp_utils.PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), + idp_utils.PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), + idp_utils.PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), + idp_utils.AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), + idp_utils.ProfileAttributeVar: attributesCfg.GetProfileAttribute(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} + +func interfaceToStringSlice(in interface{}) []string { + slice := in.([]interface{}) + ret := make([]string, 0) + for _, item := range slice { + ret = append(ret, item.(string)) + } + return ret +} diff --git a/zitadel/v2/idp_ldap/resource.go b/zitadel/v2/idp_ldap/resource.go new file mode 100644 index 00000000..3efb6470 --- /dev/null +++ b/zitadel/v2/idp_ldap/resource.go @@ -0,0 +1,165 @@ +package idp_ldap + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an LDAP IDP on the instance.", + Schema: map[string]*schema.Schema{ + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ServersVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "Servers to try in order for establishing LDAP connections", + }, + idp_utils.StartTLSVar: { + Type: schema.TypeBool, + Required: true, + Description: "Wether to use StartTLS for LDAP connections", + }, + idp_utils.BaseDNVar: { + Type: schema.TypeString, + Required: true, + Description: "Base DN for LDAP connections", + }, + idp_utils.BindDNVar: { + Type: schema.TypeString, + Required: true, + Description: "Bind DN for LDAP connections", + }, + idp_utils.BindPasswordVar: { + Type: schema.TypeString, + Required: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + }, + idp_utils.UserBaseVar: { + Type: schema.TypeString, + Required: true, + Description: "User base for LDAP connections", + }, + idp_utils.UserObjectClassesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User object classes for LDAP connections", + }, + idp_utils.UserFiltersVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User filters for LDAP connections", + }, + idp_utils.TimeoutVar: { + Type: schema.TypeString, + Required: true, + Description: "Timeout for LDAP connections", + }, + idp_utils.IdAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the id", + }, + idp_utils.FirstNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the first name", + }, + idp_utils.LastNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the last name", + }, + idp_utils.DisplayNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the display name", + }, + idp_utils.NickNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the nick name", + }, + idp_utils.PreferredUsernameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred username", + }, + idp_utils.EmailAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email", + }, + idp_utils.EmailVerifiedAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email verified state", + }, + idp_utils.PhoneAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone", + }, + idp_utils.PhoneVerifiedAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone verified state", + }, + idp_utils.PreferredLanguageAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred language", + }, + idp_utils.AvatarURLAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the avatar url", + }, + idp_utils.ProfileAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the profile", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.BindPasswordVar)}, + } +} diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/v2/idp_ldap/resource_test.go new file mode 100644 index 00000000..d5aea570 --- /dev/null +++ b/zitadel/v2/idp_ldap/resource_test.go @@ -0,0 +1,38 @@ +package idp_ldap_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" +) + +func TestAccZITADELInstanceIdPLDAP(t *testing.T) { + resourceName := "zitadel_idp_ldap" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" + servers = ["a server"] + start_tls = true + base_dn = "a base dn" + bind_dn = "a bind dn" + bind_password = "%s" + user_base = "a user base" + user_object_classes = ["a user object class"] + user_filters = ["a user filter"] + timeout = "5s" + id_attribute = "a id_attribute" + first_name_attribute = "a first name attribute" + last_name_attribute = "a last name attribute" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, name, secret) + }, "bind_password") +} diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go index a32fb40b..ed3ecbbc 100644 --- a/zitadel/v2/idp_utils/const.go +++ b/zitadel/v2/idp_utils/const.go @@ -17,4 +17,28 @@ const ( TenantTypeVar = "tenant_type" TenantIDVar = "tenant_id" EmailVerifiedVar = "email_verified" + // ServersVar is the first LDAP specific provider config property + ServersVar = "servers" + StartTLSVar = "start_tls" + BaseDNVar = "base_dn" + BindDNVar = "bind_dn" + BindPasswordVar = "bind_password" + UserBaseVar = "user_base" + UserObjectClassesVar = "user_object_classes" + UserFiltersVar = "user_filters" + TimeoutVar = "timeout" + IdAttributeVar = "id_attribute" + // FirstNameAttributeVar is the first LDAP specific user config property + FirstNameAttributeVar = "first_name_attribute" + LastNameAttributeVar = "last_name_attribute" + DisplayNameAttributeVar = "display_name_attribute" + NickNameAttributeVar = "nick_name_attribute" + PreferredUsernameAttributeVar = "preferred_username_attribute" + EmailAttributeVar = "email_attribute" + EmailVerifiedAttributeVar = "email_verified_attribute" + PhoneAttributeVar = "phone_attribute" + PhoneVerifiedAttributeVar = "phone_verified_attribute" + PreferredLanguageAttributeVar = "preferred_language_attribute" + AvatarURLAttributeVar = "avatar_url_attribute" + ProfileAttributeVar = "profile_attribute" ) diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/v2/idp_utils/funcs.go index 98a2d86c..d9986e21 100644 --- a/zitadel/v2/idp_utils/funcs.go +++ b/zitadel/v2/idp_utils/funcs.go @@ -27,19 +27,20 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } -func ImportIDPWithClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", IdpIDVar) +func ImportIDPWithSecret(secretVar string) schema.StateContextFunc { + return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", IdpIDVar) + } + parts := strings.SplitN(id, ":", 2) + if len(parts) != 2 || parts[0] == "" || parts[1] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, IdpIDVar, secretVar) + } + data.SetId(parts[0]) + if err := data.Set(secretVar, parts[1]); err != nil { + return nil, err + } + return []*schema.ResourceData{data}, nil } - parts := strings.SplitN(id, ":", 2) - if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected idpid:clientsecret", id) - } - data.SetId(parts[0]) - if err := data.Set(ClientSecretVar, parts[1]); err != nil { - return nil, err - } - return []*schema.ResourceData{data}, nil - } diff --git a/zitadel/v2/idp_utils/test_utils/lifecyletest.go b/zitadel/v2/idp_utils/test_utils/lifecyletest.go index 67a88395..88c16415 100644 --- a/zitadel/v2/idp_utils/test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/test_utils/lifecyletest.go @@ -23,11 +23,12 @@ func RunBasicLifecyleTest( t *testing.T, frame *InstanceTestFrame, resourceFunc func(string, string) string, + secretAttribute string, ) { getProviderByIDResponse := new(admin.GetProviderByIDResponse) initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, initialSecret)) - updatedClientSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) + updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) resource.Test(t, resource.TestCase{ ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), CheckDestroy: CheckDestroy(frame), @@ -57,14 +58,14 @@ func RunBasicLifecyleTest( AssignGetProviderByIDResponse(frame, getProviderByIDResponse), CheckName(updatedProviderName, getProviderByIDResponse), ), - }, { // Check updating client secret has a diff - Config: updatedClientSecretConfig, + }, { // Check updating secret has a diff + Config: updatedSecretConfig, ExpectNonEmptyPlan: true, // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, - }, { // Check client secret can be updated - Config: updatedClientSecretConfig, - }, { // Expect import error if client secret is not given + }, { // Check secret can be updated + Config: updatedSecretConfig, + }, { // Expect import error if secret is not given ResourceName: frame.TerraformName, ImportState: true, ImportStateId: "12345", @@ -77,13 +78,13 @@ func RunBasicLifecyleTest( return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil }, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"client_secret"}, + ImportStateVerifyIgnore: []string{secretAttribute}, Check: func(state *terraform.State) error { - // Check the client_secret is imported correctly + // Check the secret is imported correctly currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes["client_secret"] + actual := currentState.Attributes[secretAttribute] if actual != importedSecret { - return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) + return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) } return nil }, diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index 3579a047..d7c48c27 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing an Azure AD IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index d1d9af35..466a14f5 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -10,7 +10,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing an Azure AD IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 8512c698..fb23ffd7 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing a GitHub IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 61b28b6e..daff57d4 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing a GitHub IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index 689ac55e..b6d25dc8 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing a GitHub Enterprise IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index e47a47a1..fa8597de 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing a GitHub Enterprise IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index 3662ddeb..8946448f 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing a GitLab IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index c5435beb..aef20e1d 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing a GitLab IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index 141ba79b..d1cfff3b 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing a GitLab Self Hosted IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index 1eef0b44..3af843f7 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing a GitLab Self Hosted IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index 61526543..b532dec7 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -8,7 +8,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a GitHub IDP of the organization.", + Description: "Datasource representing a Google IdP of the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 5711ad32..196d3ebb 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -8,7 +8,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP on the organization.", + Description: "Resource representing a Google IdP on the organization.", Schema: map[string]*schema.Schema{ org_idp_utils.OrgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_jwt/datasource.go b/zitadel/v2/org_idp_jwt/datasource.go index 5c2993b2..009e7665 100644 --- a/zitadel/v2/org_idp_jwt/datasource.go +++ b/zitadel/v2/org_idp_jwt/datasource.go @@ -6,7 +6,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a domain of the organization.", + Description: "Datasource representing a generic JWT IdP on the organization.", Schema: map[string]*schema.Schema{ idpIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index 1d295089..64ef192a 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -11,7 +11,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a domain of the organization.", + Description: "Resource representing a generic JWT IdP of the organization.", Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go index d0b61ea9..87acf1c3 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -6,7 +6,7 @@ import ( func GetDatasource() *schema.Resource { return &schema.Resource{ - Description: "Datasource representing a OIDC IDP of the organization.", + Description: "Datasource representing a generic OIDC IdP on the organization.", Schema: map[string]*schema.Schema{ idpIDVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index dccef37d..9df43783 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -11,7 +11,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing a OIDC IDP of the organization.", + Description: "Resource representing a generic OIDC IdP on the organization.", Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, From 733fe964189d140bf9b025a57e426de440b81a1a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Apr 2023 19:04:28 +0200 Subject: [PATCH 105/260] feat: add LDAP org idp --- zitadel/provider.go | 4 + zitadel/v2/idp_ldap/funcs.go | 13 +- zitadel/v2/idp_utils/funcs.go | 9 + zitadel/v2/org_idp_azure_ad/datasource.go | 2 +- zitadel/v2/org_idp_azure_ad/resource.go | 2 +- zitadel/v2/org_idp_azure_ad/resource_test.go | 4 +- zitadel/v2/org_idp_github/datasource.go | 2 +- zitadel/v2/org_idp_github/resource.go | 2 +- zitadel/v2/org_idp_github/resource_test.go | 4 +- zitadel/v2/org_idp_github_es/datasource.go | 2 +- zitadel/v2/org_idp_github_es/resource.go | 2 +- zitadel/v2/org_idp_github_es/resource_test.go | 4 +- zitadel/v2/org_idp_gitlab/datasource.go | 2 +- zitadel/v2/org_idp_gitlab/resource.go | 2 +- zitadel/v2/org_idp_gitlab/resource_test.go | 4 +- .../org_idp_gitlab_self_hosted/datasource.go | 2 +- .../v2/org_idp_gitlab_self_hosted/resource.go | 2 +- .../resource_test.go | 4 +- zitadel/v2/org_idp_google/datasource.go | 2 +- zitadel/v2/org_idp_google/resource.go | 2 +- zitadel/v2/org_idp_google/resource_test.go | 4 +- zitadel/v2/org_idp_ldap/datasource.go | 172 ++++++++++++++++ zitadel/v2/org_idp_ldap/funcs.go | 188 ++++++++++++++++++ zitadel/v2/org_idp_ldap/resource.go | 171 ++++++++++++++++ zitadel/v2/org_idp_ldap/resource_test.go | 41 ++++ zitadel/v2/org_idp_utils/funcs.go | 35 ++-- .../org_idp_utils/test_utils/lifecyletest.go | 15 +- 27 files changed, 643 insertions(+), 53 deletions(-) create mode 100644 zitadel/v2/org_idp_ldap/datasource.go create mode 100644 zitadel/v2/org_idp_ldap/funcs.go create mode 100644 zitadel/v2/org_idp_ldap/resource.go create mode 100644 zitadel/v2/org_idp_ldap/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 8bfed71b..3d21486d 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,6 +3,8 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" @@ -222,6 +224,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetDatasource(), "zitadel_org_idp_google": org_idp_google.GetDatasource(), "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetDatasource(), + "zitadel_org_idp_ldap": org_idp_ldap.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { @@ -306,6 +309,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_gitlab_self_hosted": org_idp_gitlab_self_hosted.GetResource(), "zitadel_org_idp_google": org_idp_google.GetResource(), "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetResource(), + "zitadel_org_idp_ldap": org_idp_ldap.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/v2/idp_ldap/funcs.go index 90740360..bb7b1d7f 100644 --- a/zitadel/v2/idp_ldap/funcs.go +++ b/zitadel/v2/idp_ldap/funcs.go @@ -30,7 +30,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } req := &admin.AddLDAPProviderRequest{ Name: d.Get(idp_utils.NameVar).(string), - Servers: interfaceToStringSlice(d.Get(idp_utils.ServersVar)), + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), StartTls: d.Get(idp_utils.StartTLSVar).(bool), BaseDn: d.Get(idp_utils.BaseDNVar).(string), BindDn: d.Get(idp_utils.BindDNVar).(string), @@ -86,7 +86,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ Id: d.Id(), Name: d.Get(idp_utils.NameVar).(string), - Servers: interfaceToStringSlice(d.Get(idp_utils.ServersVar)), + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), StartTls: d.Get(idp_utils.StartTLSVar).(bool), BaseDn: d.Get(idp_utils.BaseDNVar).(string), BindDn: d.Get(idp_utils.BindDNVar).(string), @@ -183,12 +183,3 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(idp.Id) return nil } - -func interfaceToStringSlice(in interface{}) []string { - slice := in.([]interface{}) - ret := make([]string, 0) - for _, item := range slice { - ret = append(ret, item.(string)) - } - return ret -} diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/v2/idp_utils/funcs.go index d9986e21..d46aa992 100644 --- a/zitadel/v2/idp_utils/funcs.go +++ b/zitadel/v2/idp_utils/funcs.go @@ -44,3 +44,12 @@ func ImportIDPWithSecret(secretVar string) schema.StateContextFunc { return []*schema.ResourceData{data}, nil } } + +func InterfaceToStringSlice(in interface{}) []string { + slice := in.([]interface{}) + ret := make([]string, 0) + for _, item := range slice { + ret = append(ret, item.(string)) + } + return ret +} diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index d7c48c27..eb4fbb99 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -81,6 +81,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index 466a14f5..8c524834 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -83,6 +83,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 1f974b36..84b6dc32 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -29,5 +31,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index fb23ffd7..dfa87e49 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -66,6 +66,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index daff57d4..77050290 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -65,6 +65,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index 265d3f95..27c5625b 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -26,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index b6d25dc8..2d13f694 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -81,6 +81,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index fa8597de..f2ac63c3 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -80,6 +80,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go index ee97753c..81a6ee19 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -29,5 +31,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index 8946448f..495a3264 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -66,6 +66,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index aef20e1d..5d54ac0e 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -65,6 +65,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go index 7de04fd4..179c3f11 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -26,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index d1cfff3b..8762ba09 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -71,6 +71,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index 3af843f7..8f0588f9 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -70,6 +70,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go index 75dd831a..bf68894d 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -27,5 +29,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index b532dec7..7277b608 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -66,6 +66,6 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 196d3ebb..379c87c3 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -65,6 +65,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndClientSecret}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go index 4f9edcd6..06125397 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -26,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }) + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go new file mode 100644 index 00000000..ac745c6a --- /dev/null +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -0,0 +1,172 @@ +package org_idp_ldap + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an LDAP IdP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + }, + idp_utils.IdpIDVar: { + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + }, + idp_utils.ServersVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Servers to try in order for establishing LDAP connections", + }, + idp_utils.StartTLSVar: { + Type: schema.TypeBool, + Computed: true, + Description: "Wether to use StartTLS for LDAP connections", + }, + idp_utils.BaseDNVar: { + Type: schema.TypeString, + Computed: true, + Description: "Base DN for LDAP connections", + }, + idp_utils.BindDNVar: { + Type: schema.TypeString, + Computed: true, + Description: "Bind DN for LDAP connections", + }, + idp_utils.BindPasswordVar: { + Type: schema.TypeString, + Computed: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + }, + idp_utils.UserBaseVar: { + Type: schema.TypeString, + Computed: true, + Description: "User base for LDAP connections", + }, + idp_utils.UserObjectClassesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User object classes for LDAP connections", + }, + idp_utils.UserFiltersVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User filters for LDAP connections", + }, + idp_utils.TimeoutVar: { + Type: schema.TypeString, + Computed: true, + Description: "Timeout for LDAP connections", + }, + idp_utils.IdAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the id", + }, + idp_utils.FirstNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the first name", + }, + idp_utils.LastNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the last name", + }, + idp_utils.DisplayNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the display name", + }, + idp_utils.NickNameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the nick name", + }, + idp_utils.PreferredUsernameAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred username", + }, + idp_utils.EmailAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email", + }, + idp_utils.EmailVerifiedAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email verified state", + }, + idp_utils.PhoneAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone", + }, + idp_utils.PhoneVerifiedAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone verified state", + }, + idp_utils.PreferredLanguageAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred language", + }, + idp_utils.AvatarURLAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the avatar url", + }, + idp_utils.ProfileAttributeVar: { + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the profile", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Computed: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, + } +} diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/v2/org_idp_ldap/funcs.go new file mode 100644 index 00000000..d21134d2 --- /dev/null +++ b/zitadel/v2/org_idp_ldap/funcs.go @@ -0,0 +1,188 @@ +package org_idp_ldap + +import ( + "context" + "time" + + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.AddLDAPProvider(ctx, &management.AddLDAPProviderRequest{ + Name: d.Get(idp_utils.NameVar).(string), + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), + StartTls: d.Get(idp_utils.StartTLSVar).(bool), + BaseDn: d.Get(idp_utils.BaseDNVar).(string), + BindDn: d.Get(idp_utils.BindDNVar).(string), + BindPassword: d.Get(idp_utils.BindPasswordVar).(string), + UserBase: d.Get(idp_utils.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), + Timeout: durationpb.New(timeout), + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), + }, + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to create idp: %v", err) + } + d.SetId(resp.GetId()) + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + if err != nil { + return diag.FromErr(err) + } + if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { + _, err = client.UpdateLDAPProvider(ctx, &management.UpdateLDAPProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), + StartTls: d.Get(idp_utils.StartTLSVar).(bool), + BaseDn: d.Get(idp_utils.BaseDNVar).(string), + BindDn: d.Get(idp_utils.BindDNVar).(string), + BindPassword: d.Get(idp_utils.BindPasswordVar).(string), + UserBase: d.Get(idp_utils.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), + Timeout: durationpb.New(timeout), + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), + }, + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) + } + } + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get idp") + } + idp := resp.GetIdp() + cfg := idp.GetConfig() + specificCfg := cfg.GetLdap() + attributesCfg := specificCfg.GetAttributes() + generalCfg := cfg.GetOptions() + set := map[string]interface{}{ + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_utils.ServersVar: specificCfg.GetServers(), + idp_utils.StartTLSVar: specificCfg.GetStartTls(), + idp_utils.BaseDNVar: specificCfg.GetBaseDn(), + idp_utils.BindDNVar: specificCfg.GetBindDn(), + idp_utils.BindPasswordVar: d.Get(idp_utils.BindPasswordVar).(string), + idp_utils.UserBaseVar: specificCfg.GetUserBase(), + idp_utils.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), + idp_utils.UserFiltersVar: specificCfg.GetUserFilters(), + idp_utils.TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), + idp_utils.IdAttributeVar: attributesCfg.GetIdAttribute(), + idp_utils.FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), + idp_utils.LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), + idp_utils.DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), + idp_utils.NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), + idp_utils.PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), + idp_utils.EmailAttributeVar: attributesCfg.GetEmailAttribute(), + idp_utils.EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), + idp_utils.PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), + idp_utils.PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), + idp_utils.PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), + idp_utils.AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), + idp_utils.ProfileAttributeVar: attributesCfg.GetProfileAttribute(), + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of oidc idp: %v", k, err) + } + } + d.SetId(idp.Id) + return nil +} diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/v2/org_idp_ldap/resource.go new file mode 100644 index 00000000..ed560be3 --- /dev/null +++ b/zitadel/v2/org_idp_ldap/resource.go @@ -0,0 +1,171 @@ +package org_idp_ldap + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing an LDAP IdP on the organization.", + Schema: map[string]*schema.Schema{ + org_idp_utils.OrgIDVar: { + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + }, + idp_utils.NameVar: { + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + }, + idp_utils.ServersVar: { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "Servers to try in order for establishing LDAP connections", + }, + idp_utils.StartTLSVar: { + Type: schema.TypeBool, + Required: true, + Description: "Wether to use StartTLS for LDAP connections", + }, + idp_utils.BaseDNVar: { + Type: schema.TypeString, + Required: true, + Description: "Base DN for LDAP connections", + }, + idp_utils.BindDNVar: { + Type: schema.TypeString, + Required: true, + Description: "Bind DN for LDAP connections", + }, + idp_utils.BindPasswordVar: { + Type: schema.TypeString, + Required: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + }, + idp_utils.UserBaseVar: { + Type: schema.TypeString, + Required: true, + Description: "User base for LDAP connections", + }, + idp_utils.UserObjectClassesVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User object classes for LDAP connections", + }, + idp_utils.UserFiltersVar: { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User filters for LDAP connections", + }, + idp_utils.TimeoutVar: { + Type: schema.TypeString, + Required: true, + Description: "Timeout for LDAP connections", + }, + idp_utils.IdAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the id", + }, + idp_utils.FirstNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the first name", + }, + idp_utils.LastNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the last name", + }, + idp_utils.DisplayNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the display name", + }, + idp_utils.NickNameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the nick name", + }, + idp_utils.PreferredUsernameAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred username", + }, + idp_utils.EmailAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email", + }, + idp_utils.EmailVerifiedAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email verified state", + }, + idp_utils.PhoneAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone", + }, + idp_utils.PhoneVerifiedAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone verified state", + }, + idp_utils.PreferredLanguageAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred language", + }, + idp_utils.AvatarURLAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the avatar url", + }, + idp_utils.ProfileAttributeVar: { + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the profile", + }, + idp_utils.IsLinkingAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + }, + idp_utils.IsCreationAllowedVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + }, + idp_utils.IsAutoCreationVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", + }, + idp_utils.IsAutoUpdateVar: { + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + }, + }, + ReadContext: read, + UpdateContext: update, + CreateContext: create, + DeleteContext: org_idp_utils.Delete, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.BindPasswordVar)}, + } +} diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go new file mode 100644 index 00000000..e82ab490 --- /dev/null +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -0,0 +1,41 @@ +package org_idp_ldap_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + + test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" +) + +func TestAccZITADELOrgIdPLDAP(t *testing.T) { + resourceName := "zitadel_org_idp_ldap" + frame, err := test_utils_org.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + servers = ["a server"] + start_tls = true + base_dn = "a base dn" + bind_dn = "a bind dn" + bind_password = "%s" + user_base = "a user base" + user_object_classes = ["a user object class"] + user_filters = ["a user filter"] + timeout = "5s" + id_attribute = "a id_attribute" + first_name_attribute = "a first name attribute" + last_name_attribute = "a last name attribute" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }, idp_utils.BindPasswordVar) +} diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index 452c8c2b..d2b58f50 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -29,22 +29,23 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } -func ImportIDPWithOrgAndClientSecret(_ context.Context, data *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) +func ImportIDPWithOrgAndSecret(secretVar string) schema.StateContextFunc { + return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) + } + parts := strings.SplitN(id, ":", 3) + if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s:%s", id, OrgIDVar, idp_utils.IdpIDVar, secretVar) + } + if err := data.Set(OrgIDVar, parts[0]); err != nil { + return nil, err + } + data.SetId(parts[1]) + if err := data.Set(secretVar, parts[2]); err != nil { + return nil, err + } + return []*schema.ResourceData{data}, nil } - parts := strings.SplitN(id, ":", 3) - if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected orgid:idpid:clientsecret", id) - } - if err := data.Set(OrgIDVar, parts[0]); err != nil { - return nil, err - } - data.SetId(parts[1]) - if err := data.Set(idp_utils.ClientSecretVar, parts[2]); err != nil { - return nil, err - } - return []*schema.ResourceData{data}, nil - } diff --git a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go index f6bfbe3a..26f04c8a 100644 --- a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go @@ -23,6 +23,7 @@ func RunBasicLifecyleTest( t *testing.T, frame *OrgTestFrame, resourceFunc func(string, string) string, + secretAttribute string, ) { getProviderByIDResponse := new(management.GetProviderByIDResponse) initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) @@ -57,14 +58,14 @@ func RunBasicLifecyleTest( AssignGetProviderByIDResponse(frame, getProviderByIDResponse), test_utils.CheckName(updatedProviderName, getProviderByIDResponse), ), - }, { // Check updating client secret has a diff + }, { // Check updating secret has a diff Config: updatedClientSecretConfig, ExpectNonEmptyPlan: true, // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, - }, { // Check client secret can be updated + }, { // Check secret can be updated Config: updatedClientSecretConfig, - }, { // Expect import error if client secret is not given + }, { // Expect import error if secret is not given ResourceName: frame.TerraformName, ImportState: true, ImportStateId: "123:456", @@ -77,13 +78,13 @@ func RunBasicLifecyleTest( return fmt.Sprintf("%s:%s:%s", lastState.Attributes["org_id"], lastState.ID, importedSecret), nil }, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"client_secret"}, + ImportStateVerifyIgnore: []string{secretAttribute}, Check: func(state *terraform.State) error { - // Check the client_secret is imported correctly + // Check the secretAttribute is imported correctly currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes["client_secret"] + actual := currentState.Attributes[secretAttribute] if actual != importedSecret { - return fmt.Errorf("expected client_secret to be %s, but got %s", importedSecret, actual) + return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) } return nil }, From aca8d306a94d32a8d0aa83a026ea3b6c8674310d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 12:29:45 +0200 Subject: [PATCH 106/260] docs: document idps --- docs/data-sources/idp_azure_ad.md | 39 ++++++++++ docs/data-sources/idp_github.md | 36 +++++++++ docs/data-sources/idp_github_es.md | 39 ++++++++++ docs/data-sources/idp_gitlab.md | 36 +++++++++ docs/data-sources/idp_gitlab_self_hosted.md | 39 ++++++++++ docs/data-sources/idp_google.md | 36 +++++++++ docs/data-sources/idp_ldap.md | 55 ++++++++++++++ docs/data-sources/org_idp_azure_ad.md | 40 ++++++++++ docs/data-sources/org_idp_github.md | 37 +++++++++ docs/data-sources/org_idp_github_es.md | 40 ++++++++++ docs/data-sources/org_idp_gitlab.md | 37 +++++++++ .../org_idp_gitlab_self_hosted.md | 38 ++++++++++ docs/data-sources/org_idp_google.md | 37 +++++++++ docs/data-sources/org_idp_ldap.md | 56 ++++++++++++++ docs/data-sources/org_jwt_idp.md | 4 +- docs/data-sources/org_oidc_idp.md | 4 +- docs/resources/application_oidc.md | 6 +- docs/resources/human_user.md | 2 +- docs/resources/idp_azure_ad.md | 51 +++++++++++++ docs/resources/idp_github.md | 43 +++++++++++ docs/resources/idp_github_es.md | 49 ++++++++++++ docs/resources/idp_gitlab.md | 43 +++++++++++ docs/resources/idp_gitlab_self_hosted.md | 45 +++++++++++ docs/resources/idp_google.md | 43 +++++++++++ docs/resources/idp_ldap.md | 74 ++++++++++++++++++ docs/resources/machine_user.md | 2 +- docs/resources/org_idp_azure_ad.md | 53 +++++++++++++ docs/resources/org_idp_github.md | 45 +++++++++++ docs/resources/org_idp_github_es.md | 51 +++++++++++++ docs/resources/org_idp_gitlab.md | 45 +++++++++++ docs/resources/org_idp_gitlab_self_hosted.md | 47 ++++++++++++ docs/resources/org_idp_google.md | 45 +++++++++++ docs/resources/org_idp_jwt.md | 4 +- docs/resources/org_idp_ldap.md | 76 +++++++++++++++++++ docs/resources/org_idp_oidc.md | 6 +- docs/resources/project.md | 2 +- docs/resources/trigger_actions.md | 2 +- .../provider/data-sources/idp_azure_ad.tf | 3 + examples/provider/data-sources/idp_github.tf | 3 + .../provider/data-sources/idp_github_es.tf | 3 + examples/provider/data-sources/idp_gitlab.tf | 3 + .../data-sources/idp_gitlab_self_hosted.tf | 3 + examples/provider/data-sources/idp_google.tf | 3 + examples/provider/data-sources/idp_ldap.tf | 3 + .../provider/data-sources/org_idp_azure_ad.tf | 3 + .../provider/data-sources/org_idp_github.tf | 3 + .../data-sources/org_idp_github_es.tf | 3 + .../provider/data-sources/org_idp_gitlab.tf | 3 + .../org_idp_gitlab_self_hosted.tf | 3 + .../provider/data-sources/org_idp_google.tf | 3 + .../provider/data-sources/org_idp_ldap.tf | 3 + examples/provider/resources/idp_azure_ad.tf | 12 +++ examples/provider/resources/idp_github.tf | 10 +++ examples/provider/resources/idp_github_es.tf | 13 ++++ examples/provider/resources/idp_gitlab.tf | 10 +++ .../resources/idp_gitlab_self_hosted.tf | 11 +++ examples/provider/resources/idp_google.tf | 10 +++ examples/provider/resources/idp_ldap.tf | 21 +++++ .../provider/resources/org_idp_azure_ad.tf | 13 ++++ examples/provider/resources/org_idp_github.tf | 11 +++ .../provider/resources/org_idp_github_es.tf | 14 ++++ examples/provider/resources/org_idp_gitlab.tf | 11 +++ .../resources/org_idp_gitlab_self_hosted.tf | 12 +++ examples/provider/resources/org_idp_google.tf | 11 +++ examples/provider/resources/org_idp_ldap.tf | 22 ++++++ templates/data-sources/idp_azure_ad.md.tmpl | 16 ++++ templates/data-sources/idp_github.md.tmpl | 16 ++++ templates/data-sources/idp_github_es.md.tmpl | 16 ++++ templates/data-sources/idp_gitlab.md.tmpl | 16 ++++ .../idp_gitlab_self_hosted.md.tmpl | 16 ++++ templates/data-sources/idp_google.md.tmpl | 16 ++++ templates/data-sources/idp_ldap.md.tmpl | 16 ++++ .../data-sources/org_idp_azure_ad.md.tmpl | 16 ++++ templates/data-sources/org_idp_github.md.tmpl | 16 ++++ .../data-sources/org_idp_github_es.md.tmpl | 16 ++++ templates/data-sources/org_idp_gitlab.md.tmpl | 16 ++++ .../org_idp_gitlab_self_hosted.md.tmpl | 16 ++++ templates/data-sources/org_idp_google.md.tmpl | 16 ++++ templates/data-sources/org_idp_ldap.md.tmpl | 16 ++++ templates/resources/idp_azure_ad.md.tmpl | 16 ++++ templates/resources/idp_github.md.tmpl | 16 ++++ templates/resources/idp_github_es.md.tmpl | 16 ++++ templates/resources/idp_gitlab.md.tmpl | 16 ++++ .../resources/idp_gitlab_self_hosted.md.tmpl | 16 ++++ templates/resources/idp_google.md.tmpl | 16 ++++ templates/resources/idp_ldap.md.tmpl | 16 ++++ templates/resources/org_idp_azure_ad.md.tmpl | 16 ++++ templates/resources/org_idp_github.md.tmpl | 16 ++++ templates/resources/org_idp_github_es.md.tmpl | 16 ++++ templates/resources/org_idp_gitlab.md.tmpl | 16 ++++ .../org_idp_gitlab_self_hosted.md.tmpl | 16 ++++ templates/resources/org_idp_google.md.tmpl | 16 ++++ templates/resources/org_idp_ldap.md.tmpl | 16 ++++ 93 files changed, 1962 insertions(+), 16 deletions(-) create mode 100644 docs/data-sources/idp_azure_ad.md create mode 100644 docs/data-sources/idp_github.md create mode 100644 docs/data-sources/idp_github_es.md create mode 100644 docs/data-sources/idp_gitlab.md create mode 100644 docs/data-sources/idp_gitlab_self_hosted.md create mode 100644 docs/data-sources/idp_google.md create mode 100644 docs/data-sources/idp_ldap.md create mode 100644 docs/data-sources/org_idp_azure_ad.md create mode 100644 docs/data-sources/org_idp_github.md create mode 100644 docs/data-sources/org_idp_github_es.md create mode 100644 docs/data-sources/org_idp_gitlab.md create mode 100644 docs/data-sources/org_idp_gitlab_self_hosted.md create mode 100644 docs/data-sources/org_idp_google.md create mode 100644 docs/data-sources/org_idp_ldap.md create mode 100644 docs/resources/idp_azure_ad.md create mode 100644 docs/resources/idp_github.md create mode 100644 docs/resources/idp_github_es.md create mode 100644 docs/resources/idp_gitlab.md create mode 100644 docs/resources/idp_gitlab_self_hosted.md create mode 100644 docs/resources/idp_google.md create mode 100644 docs/resources/idp_ldap.md create mode 100644 docs/resources/org_idp_azure_ad.md create mode 100644 docs/resources/org_idp_github.md create mode 100644 docs/resources/org_idp_github_es.md create mode 100644 docs/resources/org_idp_gitlab.md create mode 100644 docs/resources/org_idp_gitlab_self_hosted.md create mode 100644 docs/resources/org_idp_google.md create mode 100644 docs/resources/org_idp_ldap.md create mode 100644 examples/provider/data-sources/idp_azure_ad.tf create mode 100644 examples/provider/data-sources/idp_github.tf create mode 100644 examples/provider/data-sources/idp_github_es.tf create mode 100644 examples/provider/data-sources/idp_gitlab.tf create mode 100644 examples/provider/data-sources/idp_gitlab_self_hosted.tf create mode 100644 examples/provider/data-sources/idp_google.tf create mode 100644 examples/provider/data-sources/idp_ldap.tf create mode 100644 examples/provider/data-sources/org_idp_azure_ad.tf create mode 100644 examples/provider/data-sources/org_idp_github.tf create mode 100644 examples/provider/data-sources/org_idp_github_es.tf create mode 100644 examples/provider/data-sources/org_idp_gitlab.tf create mode 100644 examples/provider/data-sources/org_idp_gitlab_self_hosted.tf create mode 100644 examples/provider/data-sources/org_idp_google.tf create mode 100644 examples/provider/data-sources/org_idp_ldap.tf create mode 100644 examples/provider/resources/idp_azure_ad.tf create mode 100644 examples/provider/resources/idp_github.tf create mode 100644 examples/provider/resources/idp_github_es.tf create mode 100644 examples/provider/resources/idp_gitlab.tf create mode 100644 examples/provider/resources/idp_gitlab_self_hosted.tf create mode 100644 examples/provider/resources/idp_google.tf create mode 100644 examples/provider/resources/idp_ldap.tf create mode 100644 examples/provider/resources/org_idp_azure_ad.tf create mode 100644 examples/provider/resources/org_idp_github.tf create mode 100644 examples/provider/resources/org_idp_github_es.tf create mode 100644 examples/provider/resources/org_idp_gitlab.tf create mode 100644 examples/provider/resources/org_idp_gitlab_self_hosted.tf create mode 100644 examples/provider/resources/org_idp_google.tf create mode 100644 examples/provider/resources/org_idp_ldap.tf create mode 100644 templates/data-sources/idp_azure_ad.md.tmpl create mode 100644 templates/data-sources/idp_github.md.tmpl create mode 100644 templates/data-sources/idp_github_es.md.tmpl create mode 100644 templates/data-sources/idp_gitlab.md.tmpl create mode 100644 templates/data-sources/idp_gitlab_self_hosted.md.tmpl create mode 100644 templates/data-sources/idp_google.md.tmpl create mode 100644 templates/data-sources/idp_ldap.md.tmpl create mode 100644 templates/data-sources/org_idp_azure_ad.md.tmpl create mode 100644 templates/data-sources/org_idp_github.md.tmpl create mode 100644 templates/data-sources/org_idp_github_es.md.tmpl create mode 100644 templates/data-sources/org_idp_gitlab.md.tmpl create mode 100644 templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl create mode 100644 templates/data-sources/org_idp_google.md.tmpl create mode 100644 templates/data-sources/org_idp_ldap.md.tmpl create mode 100644 templates/resources/idp_azure_ad.md.tmpl create mode 100644 templates/resources/idp_github.md.tmpl create mode 100644 templates/resources/idp_github_es.md.tmpl create mode 100644 templates/resources/idp_gitlab.md.tmpl create mode 100644 templates/resources/idp_gitlab_self_hosted.md.tmpl create mode 100644 templates/resources/idp_google.md.tmpl create mode 100644 templates/resources/idp_ldap.md.tmpl create mode 100644 templates/resources/org_idp_azure_ad.md.tmpl create mode 100644 templates/resources/org_idp_github.md.tmpl create mode 100644 templates/resources/org_idp_github_es.md.tmpl create mode 100644 templates/resources/org_idp_gitlab.md.tmpl create mode 100644 templates/resources/org_idp_gitlab_self_hosted.md.tmpl create mode 100644 templates/resources/org_idp_google.md.tmpl create mode 100644 templates/resources/org_idp_ldap.md.tmpl diff --git a/docs/data-sources/idp_azure_ad.md b/docs/data-sources/idp_azure_ad.md new file mode 100644 index 00000000..85cb8e38 --- /dev/null +++ b/docs/data-sources/idp_azure_ad.md @@ -0,0 +1,39 @@ +--- +page_title: "zitadel_idp_azure_ad Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an Azure AD IDP on the instance. +--- + +# zitadel_idp_azure_ad (Data Source) + +Datasource representing an Azure AD IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_azure_ad" "azure_ad" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `email_verified` (Boolean) automatically mark emails as verified +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `tenant_id` (String) the azure ad tenant id +- `tenant_type` (String) the azure ad tenant type diff --git a/docs/data-sources/idp_github.md b/docs/data-sources/idp_github.md new file mode 100644 index 00000000..354eb850 --- /dev/null +++ b/docs/data-sources/idp_github.md @@ -0,0 +1,36 @@ +--- +page_title: "zitadel_idp_github Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitHub IDP on the instance. +--- + +# zitadel_idp_github (Data Source) + +Datasource representing a GitHub IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_github" "github" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_github_es.md b/docs/data-sources/idp_github_es.md new file mode 100644 index 00000000..16cfd14e --- /dev/null +++ b/docs/data-sources/idp_github_es.md @@ -0,0 +1,39 @@ +--- +page_title: "zitadel_idp_github_es Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitHub Enterprise IDP on the instance. +--- + +# zitadel_idp_github_es (Data Source) + +Datasource representing a GitHub Enterprise IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_github_es" "github_es" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `authorization_endpoint` (String) the providers authorization endpoint +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `token_endpoint` (String) the providers token endpoint +- `user_endpoint` (String) the providers user endpoint diff --git a/docs/data-sources/idp_gitlab.md b/docs/data-sources/idp_gitlab.md new file mode 100644 index 00000000..3f6e98a7 --- /dev/null +++ b/docs/data-sources/idp_gitlab.md @@ -0,0 +1,36 @@ +--- +page_title: "zitadel_idp_gitlab Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitLab IDP on the instance. +--- + +# zitadel_idp_gitlab (Data Source) + +Datasource representing a GitLab IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_gitlab" "gitlab" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_gitlab_self_hosted.md b/docs/data-sources/idp_gitlab_self_hosted.md new file mode 100644 index 00000000..c649adb5 --- /dev/null +++ b/docs/data-sources/idp_gitlab_self_hosted.md @@ -0,0 +1,39 @@ +--- +page_title: "zitadel_idp_gitlab_self_hosted Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitLab Self Hosted IDP on the instance. +--- + +# zitadel_idp_gitlab_self_hosted (Data Source) + +Datasource representing a GitLab Self Hosted IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `issuer` (String) the providers issuer +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `token_endpoint` (String) the providers token endpoint +- `user_endpoint` (String) the providers user endpoint diff --git a/docs/data-sources/idp_google.md b/docs/data-sources/idp_google.md new file mode 100644 index 00000000..4b6954a8 --- /dev/null +++ b/docs/data-sources/idp_google.md @@ -0,0 +1,36 @@ +--- +page_title: "zitadel_idp_google Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a Google IDP on the instance. +--- + +# zitadel_idp_google (Data Source) + +Datasource representing a Google IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_google" "google" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_ldap.md b/docs/data-sources/idp_ldap.md new file mode 100644 index 00000000..a3810cae --- /dev/null +++ b/docs/data-sources/idp_ldap.md @@ -0,0 +1,55 @@ +--- +page_title: "zitadel_idp_ldap Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an LDAP IDP on the instance. +--- + +# zitadel_idp_ldap (Data Source) + +Datasource representing an LDAP IDP on the instance. + +## Example Usage + +```terraform +data "zitadel_idp_ldap" "ldap" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. + +### Read-Only + +- `avatar_url_attribute` (String) User attribute for the avatar url +- `base_dn` (String) Base DN for LDAP connections +- `bind_dn` (String) Bind DN for LDAP connections +- `bind_password` (String, Sensitive) Bind password for LDAP connections +- `display_name_attribute` (String) User attribute for the display name +- `email_attribute` (String) User attribute for the email +- `email_verified_attribute` (String) User attribute for the email verified state +- `first_name_attribute` (String) User attribute for the first name +- `id_attribute` (String) User attribute for the id +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `last_name_attribute` (String) User attribute for the last name +- `name` (String) Name of the IDP +- `nick_name_attribute` (String) User attribute for the nick name +- `phone_attribute` (String) User attribute for the phone +- `phone_verified_attribute` (String) User attribute for the phone verified state +- `preferred_language_attribute` (String) User attribute for the preferred language +- `preferred_username_attribute` (String) User attribute for the preferred username +- `profile_attribute` (String) User attribute for the profile +- `servers` (List of String) Servers to try in order for establishing LDAP connections +- `start_tls` (Boolean) Wether to use StartTLS for LDAP connections +- `timeout` (String) Timeout for LDAP connections +- `user_base` (String) User base for LDAP connections +- `user_filters` (Set of String) User filters for LDAP connections +- `user_object_classes` (Set of String) User object classes for LDAP connections diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md new file mode 100644 index 00000000..e621e2bd --- /dev/null +++ b/docs/data-sources/org_idp_azure_ad.md @@ -0,0 +1,40 @@ +--- +page_title: "zitadel_org_idp_azure_ad Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an Azure AD IdP of the organization. +--- + +# zitadel_org_idp_azure_ad (Data Source) + +Datasource representing an Azure AD IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_azure_ad" "azure_ad" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `email_verified` (Boolean) automatically mark emails as verified +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `tenant_id` (String) the azure ad tenant id +- `tenant_type` (String) the azure ad tenant type diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md new file mode 100644 index 00000000..ba9e4576 --- /dev/null +++ b/docs/data-sources/org_idp_github.md @@ -0,0 +1,37 @@ +--- +page_title: "zitadel_org_idp_github Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitHub IdP of the organization. +--- + +# zitadel_org_idp_github (Data Source) + +Datasource representing a GitHub IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_github" "github" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md new file mode 100644 index 00000000..328d107a --- /dev/null +++ b/docs/data-sources/org_idp_github_es.md @@ -0,0 +1,40 @@ +--- +page_title: "zitadel_org_idp_github_es Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitHub Enterprise IdP of the organization. +--- + +# zitadel_org_idp_github_es (Data Source) + +Datasource representing a GitHub Enterprise IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_github_es" "github_es" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `authorization_endpoint` (String) the providers authorization endpoint +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `token_endpoint` (String) the providers token endpoint +- `user_endpoint` (String) the providers user endpoint diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md new file mode 100644 index 00000000..06972ec6 --- /dev/null +++ b/docs/data-sources/org_idp_gitlab.md @@ -0,0 +1,37 @@ +--- +page_title: "zitadel_org_idp_gitlab Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitLab IdP of the organization. +--- + +# zitadel_org_idp_gitlab (Data Source) + +Datasource representing a GitLab IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_gitlab" "gitlab" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md new file mode 100644 index 00000000..736cd54a --- /dev/null +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -0,0 +1,38 @@ +--- +page_title: "zitadel_org_idp_gitlab_self_hosted Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a GitLab Self Hosted IdP of the organization. +--- + +# zitadel_org_idp_gitlab_self_hosted (Data Source) + +Datasource representing a GitLab Self Hosted IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `issuer` (String) the providers issuer +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md new file mode 100644 index 00000000..b7a6c47a --- /dev/null +++ b/docs/data-sources/org_idp_google.md @@ -0,0 +1,37 @@ +--- +page_title: "zitadel_org_idp_google Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing a Google IdP of the organization. +--- + +# zitadel_org_idp_google (Data Source) + +Datasource representing a Google IdP of the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_google" "google" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md new file mode 100644 index 00000000..50dcb6e9 --- /dev/null +++ b/docs/data-sources/org_idp_ldap.md @@ -0,0 +1,56 @@ +--- +page_title: "zitadel_org_idp_ldap Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing an LDAP IdP on the organization. +--- + +# zitadel_org_idp_ldap (Data Source) + +Datasource representing an LDAP IdP on the organization. + +## Example Usage + +```terraform +data "zitadel_org_idp_ldap" "ldap" { + id = "177073614158299139" +} +``` + + +## Schema + +### Required + +- `id` (String) The ID of this resource. +- `org_id` (String) ID of the organization + +### Read-Only + +- `avatar_url_attribute` (String) User attribute for the avatar url +- `base_dn` (String) Base DN for LDAP connections +- `bind_dn` (String) Bind DN for LDAP connections +- `bind_password` (String, Sensitive) Bind password for LDAP connections +- `display_name_attribute` (String) User attribute for the display name +- `email_attribute` (String) User attribute for the email +- `email_verified_attribute` (String) User attribute for the email verified state +- `first_name_attribute` (String) User attribute for the first name +- `id_attribute` (String) User attribute for the id +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `last_name_attribute` (String) User attribute for the last name +- `name` (String) Name of the IDP +- `nick_name_attribute` (String) User attribute for the nick name +- `phone_attribute` (String) User attribute for the phone +- `phone_verified_attribute` (String) User attribute for the phone verified state +- `preferred_language_attribute` (String) User attribute for the preferred language +- `preferred_username_attribute` (String) User attribute for the preferred username +- `profile_attribute` (String) User attribute for the profile +- `servers` (List of String) Servers to try in order for establishing LDAP connections +- `start_tls` (Boolean) Wether to use StartTLS for LDAP connections +- `timeout` (String) Timeout for LDAP connections +- `user_base` (String) User base for LDAP connections +- `user_filters` (Set of String) User filters for LDAP connections +- `user_object_classes` (Set of String) User object classes for LDAP connections diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md index 77798cda..8137ebd5 100644 --- a/docs/data-sources/org_jwt_idp.md +++ b/docs/data-sources/org_jwt_idp.md @@ -2,12 +2,12 @@ page_title: "zitadel_org_jwt_idp Data Source - terraform-provider-zitadel" subcategory: "" description: |- - Datasource representing a domain of the organization. + Datasource representing a generic JWT IdP on the organization. --- # zitadel_org_jwt_idp (Data Source) -Datasource representing a domain of the organization. +Datasource representing a generic JWT IdP on the organization. ## Example Usage diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md index f5a41dc1..4dfef712 100644 --- a/docs/data-sources/org_oidc_idp.md +++ b/docs/data-sources/org_oidc_idp.md @@ -2,12 +2,12 @@ page_title: "zitadel_org_oidc_idp Data Source - terraform-provider-zitadel" subcategory: "" description: |- - Datasource representing a OIDC IDP of the organization. + Datasource representing a generic OIDC IdP on the organization. --- # zitadel_org_oidc_idp (Data Source) -Datasource representing a OIDC IDP of the organization. +Datasource representing a generic OIDC IdP on the organization. ## Example Usage diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 15613ef7..a27efaf9 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -39,7 +39,7 @@ resource zitadel_application_oidc application_oidc { ### Required -- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT +- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_AUTHORIZATION_CODE - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project @@ -51,8 +51,8 @@ resource zitadel_application_oidc application_oidc { - `access_token_role_assertion` (Boolean) Access token role assertion - `access_token_type` (String) Access token type, supported values: OIDC_TOKEN_TYPE_BEARER, OIDC_TOKEN_TYPE_JWT - `additional_origins` (List of String) Additional origins -- `app_type` (String) App type, supported values: OIDC_APP_TYPE_NATIVE, OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT -- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, OIDC_AUTH_METHOD_TYPE_BASIC, OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE +- `app_type` (String) App type, supported values: OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT, OIDC_APP_TYPE_NATIVE +- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE, OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, OIDC_AUTH_METHOD_TYPE_BASIC - `clock_skew` (String) Clockskew - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index fe47c469..19348cc4 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -45,7 +45,7 @@ resource zitadel_human_user human_user { ### Optional - `display_name` (String) Display name of the user -- `gender` (String) Gender of the user, supported values: GENDER_UNSPECIFIED, GENDER_FEMALE, GENDER_MALE, GENDER_DIVERSE +- `gender` (String) Gender of the user, supported values: GENDER_MALE, GENDER_DIVERSE, GENDER_UNSPECIFIED, GENDER_FEMALE - `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user diff --git a/docs/resources/idp_azure_ad.md b/docs/resources/idp_azure_ad.md new file mode 100644 index 00000000..a06a9229 --- /dev/null +++ b/docs/resources/idp_azure_ad.md @@ -0,0 +1,51 @@ +--- +page_title: "zitadel_idp_azure_ad Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing an Azure AD IDP on the instance. +--- + +# zitadel_idp_azure_ad (Resource) + +Resource representing an Azure AD IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_azure_ad" "azure_ad" { + name = "Azure AD" + client_id = "9065bfc8-a08a..." + client_secret = "H2n***" + scopes = ["openid", "profile", "email", "User.Read"] + tenant_type = "AZURE_AD_TENANT_TYPE_ORGANISATIONS" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `email_verified` (Boolean) automatically mark emails as verified +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Optional + +- `tenant_id` (String) if tenant_id is not set, the tenant_type is used +- `tenant_type` (String) the azure ad tenant type + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_github.md b/docs/resources/idp_github.md new file mode 100644 index 00000000..3b003f43 --- /dev/null +++ b/docs/resources/idp_github.md @@ -0,0 +1,43 @@ +--- +page_title: "zitadel_idp_github Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitHub IDP on the instance. +--- + +# zitadel_idp_github (Resource) + +Resource representing a GitHub IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_github" "github" { + name = "GitHub" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_github_es.md b/docs/resources/idp_github_es.md new file mode 100644 index 00000000..7d423df5 --- /dev/null +++ b/docs/resources/idp_github_es.md @@ -0,0 +1,49 @@ +--- +page_title: "zitadel_idp_github_es Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitHub Enterprise IDP on the instance. +--- + +# zitadel_idp_github_es (Resource) + +Resource representing a GitHub Enterprise IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_github_es" "github_es" { + name = "GitHub Enterprise Server" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `authorization_endpoint` (String) the providers authorization endpoint +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `token_endpoint` (String) the providers token endpoint +- `user_endpoint` (String) the providers user endpoint + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_gitlab.md b/docs/resources/idp_gitlab.md new file mode 100644 index 00000000..ea8dda83 --- /dev/null +++ b/docs/resources/idp_gitlab.md @@ -0,0 +1,43 @@ +--- +page_title: "zitadel_idp_gitlab Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitLab IDP on the instance. +--- + +# zitadel_idp_gitlab (Resource) + +Resource representing a GitLab IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_gitlab" "gitlab" { + name = "GitLab" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_gitlab_self_hosted.md b/docs/resources/idp_gitlab_self_hosted.md new file mode 100644 index 00000000..44598165 --- /dev/null +++ b/docs/resources/idp_gitlab_self_hosted.md @@ -0,0 +1,45 @@ +--- +page_title: "zitadel_idp_gitlab_self_hosted Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitLab Self Hosted IDP on the instance. +--- + +# zitadel_idp_gitlab_self_hosted (Resource) + +Resource representing a GitLab Self Hosted IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { + name = "GitLab Self Hosted" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + issuer = "https://my.issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `issuer` (String) the providers issuer +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_google.md b/docs/resources/idp_google.md new file mode 100644 index 00000000..04a52e0c --- /dev/null +++ b/docs/resources/idp_google.md @@ -0,0 +1,43 @@ +--- +page_title: "zitadel_idp_google Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a Google IDP on the instance. +--- + +# zitadel_idp_google (Resource) + +Resource representing a Google IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_google" "google" { + name = "Google" + client_id = "182902..." + client_secret = "GOCSPX-*****" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/idp_ldap.md b/docs/resources/idp_ldap.md new file mode 100644 index 00000000..d1038025 --- /dev/null +++ b/docs/resources/idp_ldap.md @@ -0,0 +1,74 @@ +--- +page_title: "zitadel_idp_ldap Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing an LDAP IDP on the instance. +--- + +# zitadel_idp_ldap (Resource) + +Resource representing an LDAP IDP on the instance. + +## Example Usage + +```terraform +resource "zitadel_idp_ldap" "ldap" { + name = "LDAP" + servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] + start_tls = false + base_dn = "dc=example,dc=com" + bind_dn = "cn=admin,dc=example,dc=com" + bind_password = "Password1!" + user_base = "dn" + user_object_classes = ["inetOrgPerson"] + user_filters = ["uid", "email"] + timeout = "10s" + id_attribute = "uid" + first_name_attribute = "firstname" + last_name_attribute = "lastname" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `base_dn` (String) Base DN for LDAP connections +- `bind_dn` (String) Bind DN for LDAP connections +- `bind_password` (String, Sensitive) Bind password for LDAP connections +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `servers` (List of String) Servers to try in order for establishing LDAP connections +- `start_tls` (Boolean) Wether to use StartTLS for LDAP connections +- `timeout` (String) Timeout for LDAP connections +- `user_base` (String) User base for LDAP connections +- `user_filters` (Set of String) User filters for LDAP connections +- `user_object_classes` (Set of String) User object classes for LDAP connections + +### Optional + +- `avatar_url_attribute` (String) User attribute for the avatar url +- `display_name_attribute` (String) User attribute for the display name +- `email_attribute` (String) User attribute for the email +- `email_verified_attribute` (String) User attribute for the email verified state +- `first_name_attribute` (String) User attribute for the first name +- `id_attribute` (String) User attribute for the id +- `last_name_attribute` (String) User attribute for the last name +- `nick_name_attribute` (String) User attribute for the nick name +- `phone_attribute` (String) User attribute for the phone +- `phone_verified_attribute` (String) User attribute for the phone verified state +- `preferred_language_attribute` (String) User attribute for the preferred language +- `preferred_username_attribute` (String) User attribute for the preferred username +- `profile_attribute` (String) User attribute for the profile + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index edfadb3c..d6b7ed04 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -31,7 +31,7 @@ resource zitadel_machine_user machine_user { ### Optional -- `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_JWT, ACCESS_TOKEN_TYPE_BEARER +- `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT - `description` (String) Description of the user ### Read-Only diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md new file mode 100644 index 00000000..2c51a3fd --- /dev/null +++ b/docs/resources/org_idp_azure_ad.md @@ -0,0 +1,53 @@ +--- +page_title: "zitadel_org_idp_azure_ad Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing an Azure AD IdP on the organization. +--- + +# zitadel_org_idp_azure_ad (Resource) + +Resource representing an Azure AD IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_azure_ad" "azure_ad" { + org_id = zitadel_org.org.id + name = "Azure AD" + client_id = "9065bfc8-a08a..." + client_secret = "H2n***" + scopes = ["openid", "profile", "email", "User.Read"] + tenant_type = "AZURE_AD_TENANT_TYPE_ORGANISATIONS" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `email_verified` (Boolean) automatically mark emails as verified +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Optional + +- `tenant_id` (String) if tenant_id is not set, the tenant_type is used +- `tenant_type` (String) the azure ad tenant type + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md new file mode 100644 index 00000000..5c2d4c58 --- /dev/null +++ b/docs/resources/org_idp_github.md @@ -0,0 +1,45 @@ +--- +page_title: "zitadel_org_idp_github Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitHub IdP on the organization. +--- + +# zitadel_org_idp_github (Resource) + +Resource representing a GitHub IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_github" "github" { + org_id = zitadel_org.org.id + name = "GitHub" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md new file mode 100644 index 00000000..be604544 --- /dev/null +++ b/docs/resources/org_idp_github_es.md @@ -0,0 +1,51 @@ +--- +page_title: "zitadel_org_idp_github_es Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitHub Enterprise IdP on the organization. +--- + +# zitadel_org_idp_github_es (Resource) + +Resource representing a GitHub Enterprise IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_github_es" "github_es" { + org_id = zitadel_org.org.id + name = "GitHub Enterprise Server" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `authorization_endpoint` (String) the providers authorization endpoint +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider +- `token_endpoint` (String) the providers token endpoint +- `user_endpoint` (String) the providers user endpoint + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md new file mode 100644 index 00000000..46fc5cc5 --- /dev/null +++ b/docs/resources/org_idp_gitlab.md @@ -0,0 +1,45 @@ +--- +page_title: "zitadel_org_idp_gitlab Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitLab IdP on the organization. +--- + +# zitadel_org_idp_gitlab (Resource) + +Resource representing a GitLab IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_gitlab" "gitlab" { + org_id = zitadel_org.org.id + name = "GitLab" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md new file mode 100644 index 00000000..23c5b145 --- /dev/null +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -0,0 +1,47 @@ +--- +page_title: "zitadel_org_idp_gitlab_self_hosted Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a GitLab Self Hosted IdP on the organization. +--- + +# zitadel_org_idp_gitlab_self_hosted (Resource) + +Resource representing a GitLab Self Hosted IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { + org_id = zitadel_org.org.id + name = "GitLab Self Hosted" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + issuer = "https://my.issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `issuer` (String) the providers issuer +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md new file mode 100644 index 00000000..b7412788 --- /dev/null +++ b/docs/resources/org_idp_google.md @@ -0,0 +1,45 @@ +--- +page_title: "zitadel_org_idp_google Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing a Google IdP on the organization. +--- + +# zitadel_org_idp_google (Resource) + +Resource representing a Google IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_google" "google" { + org_id = zitadel_org.org.id + name = "Google" + client_id = "182902..." + client_secret = "GOCSPX-*****" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `client_id` (String) client id generated by the identity provider +- `client_secret` (String, Sensitive) client secret generated by the identity provider +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index aa18e126..0c355353 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -2,12 +2,12 @@ page_title: "zitadel_org_idp_jwt Resource - terraform-provider-zitadel" subcategory: "" description: |- - Resource representing a domain of the organization. + Resource representing a generic JWT IdP of the organization. --- # zitadel_org_idp_jwt (Resource) -Resource representing a domain of the organization. +Resource representing a generic JWT IdP of the organization. ## Example Usage diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md new file mode 100644 index 00000000..80e99893 --- /dev/null +++ b/docs/resources/org_idp_ldap.md @@ -0,0 +1,76 @@ +--- +page_title: "zitadel_org_idp_ldap Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing an LDAP IdP on the organization. +--- + +# zitadel_org_idp_ldap (Resource) + +Resource representing an LDAP IdP on the organization. + +## Example Usage + +```terraform +resource "zitadel_org_idp_ldap" "ldap" { + org_id = zitadel_org.org.id + name = "LDAP" + servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] + start_tls = false + base_dn = "dc=example,dc=com" + bind_dn = "cn=admin,dc=example,dc=com" + bind_password = "Password1!" + user_base = "dn" + user_object_classes = ["inetOrgPerson"] + user_filters = ["uid", "email"] + timeout = "10s" + id_attribute = "uid" + first_name_attribute = "firstname" + last_name_attribute = "lastname" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} +``` + + +## Schema + +### Required + +- `base_dn` (String) Base DN for LDAP connections +- `bind_dn` (String) Bind DN for LDAP connections +- `bind_password` (String, Sensitive) Bind password for LDAP connections +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `name` (String) Name of the IDP +- `org_id` (String) ID of the organization +- `servers` (List of String) Servers to try in order for establishing LDAP connections +- `start_tls` (Boolean) Wether to use StartTLS for LDAP connections +- `timeout` (String) Timeout for LDAP connections +- `user_base` (String) User base for LDAP connections +- `user_filters` (Set of String) User filters for LDAP connections +- `user_object_classes` (Set of String) User object classes for LDAP connections + +### Optional + +- `avatar_url_attribute` (String) User attribute for the avatar url +- `display_name_attribute` (String) User attribute for the display name +- `email_attribute` (String) User attribute for the email +- `email_verified_attribute` (String) User attribute for the email verified state +- `first_name_attribute` (String) User attribute for the first name +- `id_attribute` (String) User attribute for the id +- `last_name_attribute` (String) User attribute for the last name +- `nick_name_attribute` (String) User attribute for the nick name +- `phone_attribute` (String) User attribute for the phone +- `phone_verified_attribute` (String) User attribute for the phone verified state +- `preferred_language_attribute` (String) User attribute for the preferred language +- `preferred_username_attribute` (String) User attribute for the preferred username +- `profile_attribute` (String) User attribute for the profile + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index 7533176c..a334d636 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -2,12 +2,12 @@ page_title: "zitadel_org_idp_oidc Resource - terraform-provider-zitadel" subcategory: "" description: |- - Resource representing a OIDC IDP of the organization. + Resource representing a generic OIDC IdP on the organization. --- # zitadel_org_idp_oidc (Resource) -Resource representing a OIDC IDP of the organization. +Resource representing a generic OIDC IdP on the organization. ## Example Usage @@ -39,7 +39,7 @@ resource zitadel_org_idp_oidc oidc_idp { - `name` (String) Name of the IDP - `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE +- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_GOOGLE, STYLING_TYPE_UNSPECIFIED - `username_mapping` (String) definition which field is mapped to the email of the user ### Read-Only diff --git a/docs/resources/project.md b/docs/resources/project.md index 01a04552..b048430c 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -33,7 +33,7 @@ resource zitadel_project project { ### Optional - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project -- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_UNSPECIFIED - `project_role_assertion` (Boolean) describes if roles of user should be added in token - `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index aa78d662..fed30a80 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -26,7 +26,7 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_INTERNAL_AUTHENTICATION, FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION, FLOW_TYPE_EXTERNAL_AUTHENTICATION - `org_id` (String) ID of the organization - `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION diff --git a/examples/provider/data-sources/idp_azure_ad.tf b/examples/provider/data-sources/idp_azure_ad.tf new file mode 100644 index 00000000..6f64350e --- /dev/null +++ b/examples/provider/data-sources/idp_azure_ad.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_azure_ad" "azure_ad" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_github.tf b/examples/provider/data-sources/idp_github.tf new file mode 100644 index 00000000..800aba13 --- /dev/null +++ b/examples/provider/data-sources/idp_github.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_github" "github" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_github_es.tf b/examples/provider/data-sources/idp_github_es.tf new file mode 100644 index 00000000..6ffc7102 --- /dev/null +++ b/examples/provider/data-sources/idp_github_es.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_github_es" "github_es" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_gitlab.tf b/examples/provider/data-sources/idp_gitlab.tf new file mode 100644 index 00000000..71f2c1f2 --- /dev/null +++ b/examples/provider/data-sources/idp_gitlab.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_gitlab" "gitlab" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_gitlab_self_hosted.tf b/examples/provider/data-sources/idp_gitlab_self_hosted.tf new file mode 100644 index 00000000..22e3e773 --- /dev/null +++ b/examples/provider/data-sources/idp_gitlab_self_hosted.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_google.tf b/examples/provider/data-sources/idp_google.tf new file mode 100644 index 00000000..ba498b8e --- /dev/null +++ b/examples/provider/data-sources/idp_google.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_google" "google" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/idp_ldap.tf b/examples/provider/data-sources/idp_ldap.tf new file mode 100644 index 00000000..42caf7a7 --- /dev/null +++ b/examples/provider/data-sources/idp_ldap.tf @@ -0,0 +1,3 @@ +data "zitadel_idp_ldap" "ldap" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_azure_ad.tf b/examples/provider/data-sources/org_idp_azure_ad.tf new file mode 100644 index 00000000..2bea7d3c --- /dev/null +++ b/examples/provider/data-sources/org_idp_azure_ad.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_azure_ad" "azure_ad" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_github.tf b/examples/provider/data-sources/org_idp_github.tf new file mode 100644 index 00000000..f504ceb9 --- /dev/null +++ b/examples/provider/data-sources/org_idp_github.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_github" "github" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_github_es.tf b/examples/provider/data-sources/org_idp_github_es.tf new file mode 100644 index 00000000..a460b39c --- /dev/null +++ b/examples/provider/data-sources/org_idp_github_es.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_github_es" "github_es" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_gitlab.tf b/examples/provider/data-sources/org_idp_gitlab.tf new file mode 100644 index 00000000..94120b75 --- /dev/null +++ b/examples/provider/data-sources/org_idp_gitlab.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_gitlab" "gitlab" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf new file mode 100644 index 00000000..21707e8d --- /dev/null +++ b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_google.tf b/examples/provider/data-sources/org_idp_google.tf new file mode 100644 index 00000000..c5e1333d --- /dev/null +++ b/examples/provider/data-sources/org_idp_google.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_google" "google" { + id = "177073614158299139" +} diff --git a/examples/provider/data-sources/org_idp_ldap.tf b/examples/provider/data-sources/org_idp_ldap.tf new file mode 100644 index 00000000..03421a07 --- /dev/null +++ b/examples/provider/data-sources/org_idp_ldap.tf @@ -0,0 +1,3 @@ +data "zitadel_org_idp_ldap" "ldap" { + id = "177073614158299139" +} diff --git a/examples/provider/resources/idp_azure_ad.tf b/examples/provider/resources/idp_azure_ad.tf new file mode 100644 index 00000000..19f0a6fe --- /dev/null +++ b/examples/provider/resources/idp_azure_ad.tf @@ -0,0 +1,12 @@ +resource "zitadel_idp_azure_ad" "azure_ad" { + name = "Azure AD" + client_id = "9065bfc8-a08a..." + client_secret = "H2n***" + scopes = ["openid", "profile", "email", "User.Read"] + tenant_type = "AZURE_AD_TENANT_TYPE_ORGANISATIONS" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_github.tf b/examples/provider/resources/idp_github.tf new file mode 100644 index 00000000..3760e21b --- /dev/null +++ b/examples/provider/resources/idp_github.tf @@ -0,0 +1,10 @@ +resource "zitadel_idp_github" "github" { + name = "GitHub" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_github_es.tf b/examples/provider/resources/idp_github_es.tf new file mode 100644 index 00000000..290aeed3 --- /dev/null +++ b/examples/provider/resources/idp_github_es.tf @@ -0,0 +1,13 @@ +resource "zitadel_idp_github_es" "github_es" { + name = "GitHub Enterprise Server" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_gitlab.tf b/examples/provider/resources/idp_gitlab.tf new file mode 100644 index 00000000..1dd0bc60 --- /dev/null +++ b/examples/provider/resources/idp_gitlab.tf @@ -0,0 +1,10 @@ +resource "zitadel_idp_gitlab" "gitlab" { + name = "GitLab" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_gitlab_self_hosted.tf b/examples/provider/resources/idp_gitlab_self_hosted.tf new file mode 100644 index 00000000..c41343b8 --- /dev/null +++ b/examples/provider/resources/idp_gitlab_self_hosted.tf @@ -0,0 +1,11 @@ +resource "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { + name = "GitLab Self Hosted" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + issuer = "https://my.issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_google.tf b/examples/provider/resources/idp_google.tf new file mode 100644 index 00000000..a15e7e39 --- /dev/null +++ b/examples/provider/resources/idp_google.tf @@ -0,0 +1,10 @@ +resource "zitadel_idp_google" "google" { + name = "Google" + client_id = "182902..." + client_secret = "GOCSPX-*****" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/idp_ldap.tf b/examples/provider/resources/idp_ldap.tf new file mode 100644 index 00000000..580f5d29 --- /dev/null +++ b/examples/provider/resources/idp_ldap.tf @@ -0,0 +1,21 @@ +resource "zitadel_idp_ldap" "ldap" { + name = "LDAP" + servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] + start_tls = false + base_dn = "dc=example,dc=com" + bind_dn = "cn=admin,dc=example,dc=com" + bind_password = "Password1!" + user_base = "dn" + user_object_classes = ["inetOrgPerson"] + user_filters = ["uid", "email"] + timeout = "10s" + id_attribute = "uid" + first_name_attribute = "firstname" + last_name_attribute = "lastname" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} + + diff --git a/examples/provider/resources/org_idp_azure_ad.tf b/examples/provider/resources/org_idp_azure_ad.tf new file mode 100644 index 00000000..ddfa162e --- /dev/null +++ b/examples/provider/resources/org_idp_azure_ad.tf @@ -0,0 +1,13 @@ +resource "zitadel_org_idp_azure_ad" "azure_ad" { + org_id = zitadel_org.org.id + name = "Azure AD" + client_id = "9065bfc8-a08a..." + client_secret = "H2n***" + scopes = ["openid", "profile", "email", "User.Read"] + tenant_type = "AZURE_AD_TENANT_TYPE_ORGANISATIONS" + email_verified = true + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_github.tf b/examples/provider/resources/org_idp_github.tf new file mode 100644 index 00000000..0a4ae584 --- /dev/null +++ b/examples/provider/resources/org_idp_github.tf @@ -0,0 +1,11 @@ +resource "zitadel_org_idp_github" "github" { + org_id = zitadel_org.org.id + name = "GitHub" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_github_es.tf b/examples/provider/resources/org_idp_github_es.tf new file mode 100644 index 00000000..e0898653 --- /dev/null +++ b/examples/provider/resources/org_idp_github_es.tf @@ -0,0 +1,14 @@ +resource "zitadel_org_idp_github_es" "github_es" { + org_id = zitadel_org.org.id + name = "GitHub Enterprise Server" + client_id = "86a165..." + client_secret = "*****afdbac18" + scopes = ["openid", "profile", "email"] + authorization_endpoint = "https://auth.endpoint" + token_endpoint = "https://token.endpoint" + user_endpoint = "https://user.endpoint" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_gitlab.tf b/examples/provider/resources/org_idp_gitlab.tf new file mode 100644 index 00000000..7dd6174e --- /dev/null +++ b/examples/provider/resources/org_idp_gitlab.tf @@ -0,0 +1,11 @@ +resource "zitadel_org_idp_gitlab" "gitlab" { + org_id = zitadel_org.org.id + name = "GitLab" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_gitlab_self_hosted.tf b/examples/provider/resources/org_idp_gitlab_self_hosted.tf new file mode 100644 index 00000000..59ddcf9c --- /dev/null +++ b/examples/provider/resources/org_idp_gitlab_self_hosted.tf @@ -0,0 +1,12 @@ +resource "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { + org_id = zitadel_org.org.id + name = "GitLab Self Hosted" + client_id = "15765e..." + client_secret = "*****abcxyz" + scopes = ["openid", "profile", "email"] + issuer = "https://my.issuer" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_google.tf b/examples/provider/resources/org_idp_google.tf new file mode 100644 index 00000000..c53a7df7 --- /dev/null +++ b/examples/provider/resources/org_idp_google.tf @@ -0,0 +1,11 @@ +resource "zitadel_org_idp_google" "google" { + org_id = zitadel_org.org.id + name = "Google" + client_id = "182902..." + client_secret = "GOCSPX-*****" + scopes = ["openid", "profile", "email"] + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} diff --git a/examples/provider/resources/org_idp_ldap.tf b/examples/provider/resources/org_idp_ldap.tf new file mode 100644 index 00000000..dfc647b4 --- /dev/null +++ b/examples/provider/resources/org_idp_ldap.tf @@ -0,0 +1,22 @@ +resource "zitadel_org_idp_ldap" "ldap" { + org_id = zitadel_org.org.id + name = "LDAP" + servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] + start_tls = false + base_dn = "dc=example,dc=com" + bind_dn = "cn=admin,dc=example,dc=com" + bind_password = "Password1!" + user_base = "dn" + user_object_classes = ["inetOrgPerson"] + user_filters = ["uid", "email"] + timeout = "10s" + id_attribute = "uid" + first_name_attribute = "firstname" + last_name_attribute = "lastname" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true +} + + diff --git a/templates/data-sources/idp_azure_ad.md.tmpl b/templates/data-sources/idp_azure_ad.md.tmpl new file mode 100644 index 00000000..0aaf0c0d --- /dev/null +++ b/templates/data-sources/idp_azure_ad.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_azure_ad.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_github.md.tmpl b/templates/data-sources/idp_github.md.tmpl new file mode 100644 index 00000000..94baab8e --- /dev/null +++ b/templates/data-sources/idp_github.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_github.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_github_es.md.tmpl b/templates/data-sources/idp_github_es.md.tmpl new file mode 100644 index 00000000..2f07f6b3 --- /dev/null +++ b/templates/data-sources/idp_github_es.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_github_es.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_gitlab.md.tmpl b/templates/data-sources/idp_gitlab.md.tmpl new file mode 100644 index 00000000..48bdafc4 --- /dev/null +++ b/templates/data-sources/idp_gitlab.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_gitlab.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl new file mode 100644 index 00000000..8475746d --- /dev/null +++ b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_gitlab_self_hosted.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_google.md.tmpl b/templates/data-sources/idp_google.md.tmpl new file mode 100644 index 00000000..dde90fce --- /dev/null +++ b/templates/data-sources/idp_google.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_google.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/idp_ldap.md.tmpl b/templates/data-sources/idp_ldap.md.tmpl new file mode 100644 index 00000000..362dd199 --- /dev/null +++ b/templates/data-sources/idp_ldap.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/idp_ldap.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_azure_ad.md.tmpl b/templates/data-sources/org_idp_azure_ad.md.tmpl new file mode 100644 index 00000000..90084566 --- /dev/null +++ b/templates/data-sources/org_idp_azure_ad.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_azure_ad.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_github.md.tmpl b/templates/data-sources/org_idp_github.md.tmpl new file mode 100644 index 00000000..245ccbc9 --- /dev/null +++ b/templates/data-sources/org_idp_github.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_github.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_github_es.md.tmpl b/templates/data-sources/org_idp_github_es.md.tmpl new file mode 100644 index 00000000..c75102e7 --- /dev/null +++ b/templates/data-sources/org_idp_github_es.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_github_es.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_gitlab.md.tmpl b/templates/data-sources/org_idp_gitlab.md.tmpl new file mode 100644 index 00000000..570d85b2 --- /dev/null +++ b/templates/data-sources/org_idp_gitlab.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_gitlab.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl new file mode 100644 index 00000000..58f3624b --- /dev/null +++ b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_gitlab_self_hosted.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_google.md.tmpl b/templates/data-sources/org_idp_google.md.tmpl new file mode 100644 index 00000000..a7c65747 --- /dev/null +++ b/templates/data-sources/org_idp_google.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_google.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/data-sources/org_idp_ldap.md.tmpl b/templates/data-sources/org_idp_ldap.md.tmpl new file mode 100644 index 00000000..832967e7 --- /dev/null +++ b/templates/data-sources/org_idp_ldap.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/org_idp_ldap.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_azure_ad.md.tmpl b/templates/resources/idp_azure_ad.md.tmpl new file mode 100644 index 00000000..43de3de7 --- /dev/null +++ b/templates/resources/idp_azure_ad.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_azure_ad.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_github.md.tmpl b/templates/resources/idp_github.md.tmpl new file mode 100644 index 00000000..d75e98b3 --- /dev/null +++ b/templates/resources/idp_github.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_github.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_github_es.md.tmpl b/templates/resources/idp_github_es.md.tmpl new file mode 100644 index 00000000..2640893a --- /dev/null +++ b/templates/resources/idp_github_es.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_github_es.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_gitlab.md.tmpl b/templates/resources/idp_gitlab.md.tmpl new file mode 100644 index 00000000..a796bb07 --- /dev/null +++ b/templates/resources/idp_gitlab.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_gitlab.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_gitlab_self_hosted.md.tmpl b/templates/resources/idp_gitlab_self_hosted.md.tmpl new file mode 100644 index 00000000..a3a5cecd --- /dev/null +++ b/templates/resources/idp_gitlab_self_hosted.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_gitlab_self_hosted.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_google.md.tmpl b/templates/resources/idp_google.md.tmpl new file mode 100644 index 00000000..e9d3574d --- /dev/null +++ b/templates/resources/idp_google.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_google.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/idp_ldap.md.tmpl b/templates/resources/idp_ldap.md.tmpl new file mode 100644 index 00000000..3b655dbb --- /dev/null +++ b/templates/resources/idp_ldap.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/idp_ldap.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_azure_ad.md.tmpl b/templates/resources/org_idp_azure_ad.md.tmpl new file mode 100644 index 00000000..7a690c29 --- /dev/null +++ b/templates/resources/org_idp_azure_ad.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_azure_ad.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_github.md.tmpl b/templates/resources/org_idp_github.md.tmpl new file mode 100644 index 00000000..2caaa886 --- /dev/null +++ b/templates/resources/org_idp_github.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_github.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_github_es.md.tmpl b/templates/resources/org_idp_github_es.md.tmpl new file mode 100644 index 00000000..d759d9c3 --- /dev/null +++ b/templates/resources/org_idp_github_es.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_github_es.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_gitlab.md.tmpl b/templates/resources/org_idp_gitlab.md.tmpl new file mode 100644 index 00000000..deed4ae5 --- /dev/null +++ b/templates/resources/org_idp_gitlab.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_gitlab.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_gitlab_self_hosted.md.tmpl b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl new file mode 100644 index 00000000..331a1350 --- /dev/null +++ b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_gitlab_self_hosted.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_google.md.tmpl b/templates/resources/org_idp_google.md.tmpl new file mode 100644 index 00000000..2e92ca59 --- /dev/null +++ b/templates/resources/org_idp_google.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_google.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/org_idp_ldap.md.tmpl b/templates/resources/org_idp_ldap.md.tmpl new file mode 100644 index 00000000..f5f06697 --- /dev/null +++ b/templates/resources/org_idp_ldap.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/org_idp_ldap.tf" }} + +{{ .SchemaMarkdown | trimspace }} From 25775f77491d879f505ffb9e5b1313b44b24971a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 12:43:08 +0200 Subject: [PATCH 107/260] deterministic enum ordering --- docs/resources/application_oidc.md | 4 ++-- docs/resources/human_user.md | 2 +- docs/resources/org_idp_oidc.md | 2 +- docs/resources/project.md | 2 +- docs/resources/trigger_actions.md | 4 ++-- zitadel/v2/helper/helper.go | 6 ++---- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index a27efaf9..3569be6b 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -39,7 +39,7 @@ resource zitadel_application_oidc application_oidc { ### Required -- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_AUTHORIZATION_CODE +- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project @@ -52,7 +52,7 @@ resource zitadel_application_oidc application_oidc { - `access_token_type` (String) Access token type, supported values: OIDC_TOKEN_TYPE_BEARER, OIDC_TOKEN_TYPE_JWT - `additional_origins` (List of String) Additional origins - `app_type` (String) App type, supported values: OIDC_APP_TYPE_WEB, OIDC_APP_TYPE_USER_AGENT, OIDC_APP_TYPE_NATIVE -- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE, OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, OIDC_AUTH_METHOD_TYPE_BASIC +- `auth_method_type` (String) Auth method type, supported values: OIDC_AUTH_METHOD_TYPE_BASIC, OIDC_AUTH_METHOD_TYPE_POST, OIDC_AUTH_METHOD_TYPE_NONE, OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT - `clock_skew` (String) Clockskew - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 19348cc4..fe47c469 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -45,7 +45,7 @@ resource zitadel_human_user human_user { ### Optional - `display_name` (String) Display name of the user -- `gender` (String) Gender of the user, supported values: GENDER_MALE, GENDER_DIVERSE, GENDER_UNSPECIFIED, GENDER_FEMALE +- `gender` (String) Gender of the user, supported values: GENDER_UNSPECIFIED, GENDER_FEMALE, GENDER_MALE, GENDER_DIVERSE - `initial_password` (String, Sensitive) Initially set password for the user, not changeable after creation - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index a334d636..7d217b59 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -39,7 +39,7 @@ resource zitadel_org_idp_oidc oidc_idp { - `name` (String) Name of the IDP - `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_GOOGLE, STYLING_TYPE_UNSPECIFIED +- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE - `username_mapping` (String) definition which field is mapped to the email of the user ### Read-Only diff --git a/docs/resources/project.md b/docs/resources/project.md index b048430c..88612eea 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -33,7 +33,7 @@ resource zitadel_project project { ### Optional - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project -- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_UNSPECIFIED +- `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY - `project_role_assertion` (Boolean) describes if roles of user should be added in token - `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index fed30a80..c2ca5fa0 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -26,9 +26,9 @@ resource zitadel_trigger_actions trigger_actions { ### Required - `action_ids` (Set of String) IDs of the triggered actions -- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: FLOW_TYPE_CUSTOMISE_TOKEN, FLOW_TYPE_INTERNAL_AUTHENTICATION, FLOW_TYPE_EXTERNAL_AUTHENTICATION +- `flow_type` (String) Type of the flow to which the action triggers belong, supported values: , FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN - `org_id` (String) ID of the organization -- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION, TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION +- `trigger_type` (String) Trigger type on when the actions get triggered, supported values: , TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION ### Read-Only diff --git a/zitadel/v2/helper/helper.go b/zitadel/v2/helper/helper.go index df6ee2d7..85a54e52 100644 --- a/zitadel/v2/helper/helper.go +++ b/zitadel/v2/helper/helper.go @@ -124,10 +124,8 @@ func GetStringFromAttr(ctx context.Context, attrs map[string]attr.Value, key str func DescriptionEnumValuesList(enum map[int32]string) string { str := ", supported values: " values := make([]string, len(enum)) - i := 0 - for k := range enum { - values[i] = enum[k] - i++ + for i := 0; i < len(enum); i++ { + values[i] = enum[int32(i)] } str += strings.Join(values, ", ") return str From 0752bab19d5b59fd78a89e6757798c6afb0781f0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 13:12:32 +0200 Subject: [PATCH 108/260] document imports --- docs/data-sources/idp_azure_ad.md | 8 ++++++++ docs/data-sources/idp_github.md | 8 ++++++++ docs/data-sources/idp_github_es.md | 8 ++++++++ docs/data-sources/idp_gitlab.md | 8 ++++++++ docs/data-sources/idp_gitlab_self_hosted.md | 8 ++++++++ docs/data-sources/idp_google.md | 8 ++++++++ docs/data-sources/idp_ldap.md | 8 ++++++++ docs/data-sources/org_idp_azure_ad.md | 8 ++++++++ docs/data-sources/org_idp_github.md | 8 ++++++++ docs/data-sources/org_idp_github_es.md | 8 ++++++++ docs/data-sources/org_idp_gitlab.md | 8 ++++++++ docs/data-sources/org_idp_gitlab_self_hosted.md | 8 ++++++++ docs/data-sources/org_idp_google.md | 8 ++++++++ docs/data-sources/org_idp_ldap.md | 8 ++++++++ templates/data-sources/idp_azure_ad.md.tmpl | 8 ++++++++ templates/data-sources/idp_github.md.tmpl | 8 ++++++++ templates/data-sources/idp_github_es.md.tmpl | 8 ++++++++ templates/data-sources/idp_gitlab.md.tmpl | 8 ++++++++ templates/data-sources/idp_gitlab_self_hosted.md.tmpl | 8 ++++++++ templates/data-sources/idp_google.md.tmpl | 8 ++++++++ templates/data-sources/idp_ldap.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_azure_ad.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_github.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_github_es.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_gitlab.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_google.md.tmpl | 8 ++++++++ templates/data-sources/org_idp_ldap.md.tmpl | 8 ++++++++ 28 files changed, 224 insertions(+) diff --git a/docs/data-sources/idp_azure_ad.md b/docs/data-sources/idp_azure_ad.md index 85cb8e38..8c5bb97a 100644 --- a/docs/data-sources/idp_azure_ad.md +++ b/docs/data-sources/idp_azure_ad.md @@ -37,3 +37,11 @@ data "zitadel_idp_azure_ad" "azure_ad" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id - `tenant_type` (String) the azure ad tenant type + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_azure_ad 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_github.md b/docs/data-sources/idp_github.md index 354eb850..f99e9a42 100644 --- a/docs/data-sources/idp_github.md +++ b/docs/data-sources/idp_github.md @@ -34,3 +34,11 @@ data "zitadel_idp_github" "github" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_github 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_github_es.md b/docs/data-sources/idp_github_es.md index 16cfd14e..adfe659a 100644 --- a/docs/data-sources/idp_github_es.md +++ b/docs/data-sources/idp_github_es.md @@ -37,3 +37,11 @@ data "zitadel_idp_github_es" "github_es" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_github_es 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_gitlab.md b/docs/data-sources/idp_gitlab.md index 3f6e98a7..3555eaa9 100644 --- a/docs/data-sources/idp_gitlab.md +++ b/docs/data-sources/idp_gitlab.md @@ -34,3 +34,11 @@ data "zitadel_idp_gitlab" "gitlab" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_gitlab 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_gitlab_self_hosted.md b/docs/data-sources/idp_gitlab_self_hosted.md index c649adb5..f5097acb 100644 --- a/docs/data-sources/idp_gitlab_self_hosted.md +++ b/docs/data-sources/idp_gitlab_self_hosted.md @@ -37,3 +37,11 @@ data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_gitlab_self_hosted 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_google.md b/docs/data-sources/idp_google.md index 4b6954a8..60330e6c 100644 --- a/docs/data-sources/idp_google.md +++ b/docs/data-sources/idp_google.md @@ -34,3 +34,11 @@ data "zitadel_idp_google" "google" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_idp_google 210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/idp_ldap.md b/docs/data-sources/idp_ldap.md index a3810cae..22f747d7 100644 --- a/docs/data-sources/idp_ldap.md +++ b/docs/data-sources/idp_ldap.md @@ -53,3 +53,11 @@ data "zitadel_idp_ldap" "ldap" { - `user_base` (String) User base for LDAP connections - `user_filters` (Set of String) User filters for LDAP connections - `user_object_classes` (Set of String) User object classes for LDAP connections + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs bind_password. + +``` +terraform import zitadel_idp_ldap 210210971312980331:mybindpassword +``` diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md index e621e2bd..7b4617fa 100644 --- a/docs/data-sources/org_idp_azure_ad.md +++ b/docs/data-sources/org_idp_azure_ad.md @@ -38,3 +38,11 @@ data "zitadel_org_idp_azure_ad" "azure_ad" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id - `tenant_type` (String) the azure ad tenant type + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_azure_ad 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md index ba9e4576..34852344 100644 --- a/docs/data-sources/org_idp_github.md +++ b/docs/data-sources/org_idp_github.md @@ -35,3 +35,11 @@ data "zitadel_org_idp_github" "github" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_github 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md index 328d107a..80bdf92e 100644 --- a/docs/data-sources/org_idp_github_es.md +++ b/docs/data-sources/org_idp_github_es.md @@ -38,3 +38,11 @@ data "zitadel_org_idp_github_es" "github_es" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_github_es 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md index 06972ec6..c20ac113 100644 --- a/docs/data-sources/org_idp_gitlab.md +++ b/docs/data-sources/org_idp_gitlab.md @@ -35,3 +35,11 @@ data "zitadel_org_idp_gitlab" "gitlab" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_gitlab 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md index 736cd54a..dd2149da 100644 --- a/docs/data-sources/org_idp_gitlab_self_hosted.md +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -36,3 +36,11 @@ data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `issuer` (String) the providers issuer - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_gitlab_self_hosted 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md index b7a6c47a..073ae6bf 100644 --- a/docs/data-sources/org_idp_google.md +++ b/docs/data-sources/org_idp_google.md @@ -35,3 +35,11 @@ data "zitadel_org_idp_google" "google" { - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import zitadel_org_idp_google 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md index 50dcb6e9..7dea2cfb 100644 --- a/docs/data-sources/org_idp_ldap.md +++ b/docs/data-sources/org_idp_ldap.md @@ -54,3 +54,11 @@ data "zitadel_org_idp_ldap" "ldap" { - `user_base` (String) User base for LDAP connections - `user_filters` (Set of String) User filters for LDAP connections - `user_object_classes` (Set of String) User object classes for LDAP connections + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs bind_password. + +``` +terraform import zitadel_org_idp_ldap 210148218065912171:210210971312980331:mybindpassword +``` diff --git a/templates/data-sources/idp_azure_ad.md.tmpl b/templates/data-sources/idp_azure_ad.md.tmpl index 0aaf0c0d..ff8f9b47 100644 --- a/templates/data-sources/idp_azure_ad.md.tmpl +++ b/templates/data-sources/idp_azure_ad.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_github.md.tmpl b/templates/data-sources/idp_github.md.tmpl index 94baab8e..16f0accc 100644 --- a/templates/data-sources/idp_github.md.tmpl +++ b/templates/data-sources/idp_github.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_github_es.md.tmpl b/templates/data-sources/idp_github_es.md.tmpl index 2f07f6b3..0a039ecf 100644 --- a/templates/data-sources/idp_github_es.md.tmpl +++ b/templates/data-sources/idp_github_es.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_gitlab.md.tmpl b/templates/data-sources/idp_gitlab.md.tmpl index 48bdafc4..bcd296f8 100644 --- a/templates/data-sources/idp_gitlab.md.tmpl +++ b/templates/data-sources/idp_gitlab.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl index 8475746d..168464ac 100644 --- a/templates/data-sources/idp_gitlab_self_hosted.md.tmpl +++ b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_google.md.tmpl b/templates/data-sources/idp_google.md.tmpl index dde90fce..b3299fda 100644 --- a/templates/data-sources/idp_google.md.tmpl +++ b/templates/data-sources/idp_google.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/idp_ldap.md.tmpl b/templates/data-sources/idp_ldap.md.tmpl index 362dd199..698fb77a 100644 --- a/templates/data-sources/idp_ldap.md.tmpl +++ b/templates/data-sources/idp_ldap.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs bind_password. + +``` +terraform import {{.Name}} 210210971312980331:mybindpassword +``` diff --git a/templates/data-sources/org_idp_azure_ad.md.tmpl b/templates/data-sources/org_idp_azure_ad.md.tmpl index 90084566..42628fb3 100644 --- a/templates/data-sources/org_idp_azure_ad.md.tmpl +++ b/templates/data-sources/org_idp_azure_ad.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_github.md.tmpl b/templates/data-sources/org_idp_github.md.tmpl index 245ccbc9..8d4a5329 100644 --- a/templates/data-sources/org_idp_github.md.tmpl +++ b/templates/data-sources/org_idp_github.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_github_es.md.tmpl b/templates/data-sources/org_idp_github_es.md.tmpl index c75102e7..88d13bc3 100644 --- a/templates/data-sources/org_idp_github_es.md.tmpl +++ b/templates/data-sources/org_idp_github_es.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_gitlab.md.tmpl b/templates/data-sources/org_idp_gitlab.md.tmpl index 570d85b2..cc03d0f1 100644 --- a/templates/data-sources/org_idp_gitlab.md.tmpl +++ b/templates/data-sources/org_idp_gitlab.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl index 58f3624b..086534ac 100644 --- a/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl +++ b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_google.md.tmpl b/templates/data-sources/org_idp_google.md.tmpl index a7c65747..13e21bd1 100644 --- a/templates/data-sources/org_idp_google.md.tmpl +++ b/templates/data-sources/org_idp_google.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret +``` diff --git a/templates/data-sources/org_idp_ldap.md.tmpl b/templates/data-sources/org_idp_ldap.md.tmpl index 832967e7..0a7ea503 100644 --- a/templates/data-sources/org_idp_ldap.md.tmpl +++ b/templates/data-sources/org_idp_ldap.md.tmpl @@ -14,3 +14,11 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs bind_password. + +``` +terraform import {{.Name}} 210148218065912171:210210971312980331:mybindpassword +``` From b8c3386ad53bd1da0923b098ecebb5792ca1c1c7 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 13:20:23 +0200 Subject: [PATCH 109/260] cleanup provider --- zitadel/provider.go | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index 3d21486d..3867bb27 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,30 +3,6 @@ package zitadel import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_ldap" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github_es" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" - "github.com/hashicorp/terraform-plugin-framework/datasource" fdiag "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/provider" @@ -58,6 +34,13 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" @@ -68,8 +51,14 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/notification_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" From 6109de40aea78387cf871a499b5fef7eea4c8c6f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 13:57:10 +0200 Subject: [PATCH 110/260] docs: make readme concise --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71057acd..f7ab2e94 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # WIP terraform-provider-zitadel -First steps to a ZITADEL terraform provider, which should handle the migration part between different ZITADEL instances and different ZITADEL versions in addition to the creation of different resources with the help of the ZITADEL API. +The ZITADEL terraform provider enables you to +- Migrate resources between ZITADEL instances and versions +- Manage reproducible ZITADEL resources declaratively + From 4bce558f8762f066559a2c44cc93c8555d251841 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 13:57:50 +0200 Subject: [PATCH 111/260] docs: add CONTRIBUTING.md --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..54f6f0f1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# Debug + +1. Run the local plugin code with your debugging IDE of choice with something similar to `go run ./... -debug`. +2. Set breakpoints in your IDE. +3. In your shell, apply the resource you are working on. + ``` + # export the printed environment variable from the go run ./... -debug command above. E.g. + export TF_REATTACH_PROVIDERS='{"registry.terraform.io/zitadel/zitadel":{"Protocol":"grpc","ProtocolVersion":6,"Pid":8123,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin275634719"}}}' + + # go to a directory containing .tf files. + cd /my-zitadel-terraform-files + + # apply them + terraform apply + ``` +4. The execution stops at your breakpoints. + +# Run Acceptance Tests + +```bash +TF_ACC=1 TF_ACC_ZITADEL_TOKEN=/my-token.json go test ./... +``` + +The tests are flaky when resources should be cleaned up. +This results in dangling resources. From c97f3d663b2e4b502abe8a50168cdbefc42a0aae Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 14:02:48 +0200 Subject: [PATCH 112/260] docs: code block bash --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 54f6f0f1..a2610b18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ 1. Run the local plugin code with your debugging IDE of choice with something similar to `go run ./... -debug`. 2. Set breakpoints in your IDE. 3. In your shell, apply the resource you are working on. - ``` + ```bash # export the printed environment variable from the go run ./... -debug command above. E.g. export TF_REATTACH_PROVIDERS='{"registry.terraform.io/zitadel/zitadel":{"Protocol":"grpc","ProtocolVersion":6,"Pid":8123,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin275634719"}}}' From 61320c3189ed734d49699d14072b181a3ddd593b Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 14:05:38 +0200 Subject: [PATCH 113/260] docs: v1 is not relevant anymore --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index f7ab2e94..ff413bfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ # WIP terraform-provider-zitadel -The ZITADEL terraform provider enables you to -- Migrate resources between ZITADEL instances and versions -- Manage reproducible ZITADEL resources declaratively +The ZITADEL terraform provider enables you to manage reproducible ZITADEL resources declaratively From 8ace8c863722c4c101edc3185cc3b18e57c0d8cc Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 14:13:23 +0200 Subject: [PATCH 114/260] docs: increment provider version --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 8a6fc06e..8dad0999 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,7 +31,7 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.14" + version = "1.0.0-alpha.16" } } } @@ -62,4 +62,4 @@ provider zitadel { ## Limitations -The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file +The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. From 8df1dca9e00092468d7039b5f96529bfa79fbe4c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Apr 2023 22:40:15 +0200 Subject: [PATCH 115/260] refactor: make lifecycle test reusable --- .../test_utils/base_frame.go | 6 +- zitadel/v2/helper/test_utils/checks.go | 16 +++ .../test_utils/instance_frame.go | 0 zitadel/v2/helper/test_utils/lifecyletest.go | 83 +++++++++++++ .../test_utils/org_frame.go} | 6 +- .../test_utils/provider_factories.go | 0 zitadel/v2/idp_azure_ad/resource_test.go | 5 +- zitadel/v2/idp_github/resource_test.go | 5 +- zitadel/v2/idp_github_es/resource_test.go | 5 +- zitadel/v2/idp_gitlab/resource_test.go | 5 +- .../idp_gitlab_self_hosted/resource_test.go | 6 +- zitadel/v2/idp_google/resource_test.go | 5 +- zitadel/v2/idp_ldap/resource_test.go | 5 +- zitadel/v2/idp_utils/idp_test_utils/checks.go | 39 +++++++ .../idp_utils/idp_test_utils/lifecyletest.go | 43 +++++++ zitadel/v2/idp_utils/test_utils/checks.go | 60 ---------- .../v2/idp_utils/test_utils/lifecyletest.go | 94 --------------- zitadel/v2/org_idp_azure_ad/resource_test.go | 5 +- zitadel/v2/org_idp_github/resource_test.go | 6 +- zitadel/v2/org_idp_github_es/resource_test.go | 6 +- zitadel/v2/org_idp_gitlab/resource_test.go | 6 +- .../resource_test.go | 6 +- zitadel/v2/org_idp_google/resource_test.go | 5 +- zitadel/v2/org_idp_ldap/resource_test.go | 6 +- zitadel/v2/org_idp_utils/test_utils/checks.go | 33 +++--- .../org_idp_utils/test_utils/lifecyletest.go | 109 +++++------------- 26 files changed, 284 insertions(+), 281 deletions(-) rename zitadel/v2/{idp_utils => helper}/test_utils/base_frame.go (95%) create mode 100644 zitadel/v2/helper/test_utils/checks.go rename zitadel/v2/{idp_utils => helper}/test_utils/instance_frame.go (100%) create mode 100644 zitadel/v2/helper/test_utils/lifecyletest.go rename zitadel/v2/{org_idp_utils/test_utils/frame.go => helper/test_utils/org_frame.go} (86%) rename zitadel/v2/{idp_utils => helper}/test_utils/provider_factories.go (100%) create mode 100644 zitadel/v2/idp_utils/idp_test_utils/checks.go create mode 100644 zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go delete mode 100644 zitadel/v2/idp_utils/test_utils/checks.go delete mode 100644 zitadel/v2/idp_utils/test_utils/lifecyletest.go diff --git a/zitadel/v2/idp_utils/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go similarity index 95% rename from zitadel/v2/idp_utils/test_utils/base_frame.go rename to zitadel/v2/helper/test_utils/base_frame.go index b30850b2..64275d38 100644 --- a/zitadel/v2/idp_utils/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -14,7 +14,7 @@ import ( ) const ( - Domain = "localhost" + domain = "localhost" insecure = true port = "8080" ) @@ -32,7 +32,7 @@ func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { tokenPath := os.Getenv("TF_ACC_ZITADEL_TOKEN") zitadelProvider := zitadel.Provider() diag := zitadelProvider.Configure(ctx, terraform.NewResourceConfigRaw(map[string]interface{}{ - "domain": Domain, + "domain": domain, "insecure": insecure, "port": port, "token": tokenPath, @@ -44,7 +44,7 @@ provider "zitadel" { port = "%s" token = "%s" } -`, Domain, insecure, port, tokenPath) +`, domain, insecure, port, tokenPath) if diag.HasError() { return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) } diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go new file mode 100644 index 00000000..ddce8f5b --- /dev/null +++ b/zitadel/v2/helper/test_utils/checks.go @@ -0,0 +1,16 @@ +package test_utils + +import ( + "regexp" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { + // ZITADEL IDs have thirteen digits + idPattern := regexp.MustCompile(`\d{13}`) + return func(state *terraform.State) error { + return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) + } +} diff --git a/zitadel/v2/idp_utils/test_utils/instance_frame.go b/zitadel/v2/helper/test_utils/instance_frame.go similarity index 100% rename from zitadel/v2/idp_utils/test_utils/instance_frame.go rename to zitadel/v2/helper/test_utils/instance_frame.go diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go new file mode 100644 index 00000000..4c350770 --- /dev/null +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -0,0 +1,83 @@ +package test_utils + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func RunLifecyleTest( + t *testing.T, + frame BaseTestFrame, + resourceFunc func(string, string) string, + initialProperty, updatedProperty, + initialSecret, updatedSecret string, + checkRemoteProperty func(expect string) resource.TestCheckFunc, + checkDestroy, checkImportState resource.TestCheckFunc, + importStateIdFunc resource.ImportStateIdFunc, + wrongImportID, + secretAttribute string, +) { + var importStateVerifyIgnore []string + initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProperty, initialSecret)) + updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) + updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) + steps := []resource.TestStep{ + { // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check resource is created + Config: initialConfig, + Check: resource.ComposeAggregateTestCheckFunc( + checkRemoteProperty(initialProperty), + CheckStateHasIDSet(frame), + ), + }, { // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check remote state can be updated + Config: updatedNameConfig, + Check: checkRemoteProperty(updatedProperty), + }, + } + if secretAttribute != "" { + steps = append(steps, resource.TestStep{ // Check that secret has a diff + Config: updatedSecretConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, resource.TestStep{ // Check secret can be updated + Config: updatedSecretConfig, + }) + importStateVerifyIgnore = []string{secretAttribute} + } + if wrongImportID != "" { + steps = append(steps, resource.TestStep{ // Expect import error if secret is not given + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateId: wrongImportID, + ExpectError: regexp.MustCompile(wrongImportID), + }) + } + if checkImportState != nil { + steps = append(steps, resource.TestStep{ // Expect importing works + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: importStateIdFunc, + ImportStateVerify: true, + ImportStateVerifyIgnore: importStateVerifyIgnore, + Check: checkImportState, + }) + } + resource.Test(t, resource.TestCase{ + ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), + CheckDestroy: checkDestroy, + Steps: steps, + }) +} diff --git a/zitadel/v2/org_idp_utils/test_utils/frame.go b/zitadel/v2/helper/test_utils/org_frame.go similarity index 86% rename from zitadel/v2/org_idp_utils/test_utils/frame.go rename to zitadel/v2/helper/test_utils/org_frame.go index bdf36237..27b9d61f 100644 --- a/zitadel/v2/org_idp_utils/test_utils/frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/grpc/codes" @@ -13,17 +12,16 @@ import ( const ( orgName = "terraform-tests" - domain = test_utils.Domain ) type OrgTestFrame struct { - test_utils.BaseTestFrame + BaseTestFrame *mgmt.Client OrgID string } func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { - baseFrame, err := test_utils.NewBaseTestFrame(resourceType) + baseFrame, err := NewBaseTestFrame(resourceType) if err != nil { return nil, err } diff --git a/zitadel/v2/idp_utils/test_utils/provider_factories.go b/zitadel/v2/helper/test_utils/provider_factories.go similarity index 100% rename from zitadel/v2/idp_utils/test_utils/provider_factories.go rename to zitadel/v2/helper/test_utils/provider_factories.go diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index f50f0409..adb033e2 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPAzureAD(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPAzureAD(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index 79a4ad2b..f51f505e 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPGitHub(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPGitHub(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index f3904769..90f9d2ba 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPGitHubES(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPGitHubES(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index 8a71a9d0..d7da8d80 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPGitLab(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPGitLab(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go index b999ef22..605869d4 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -4,7 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPGitLabSelfHosted(t *testing.T) { @@ -13,7 +15,7 @@ func TestAccZITADELInstanceIdPGitLabSelfHosted(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index e83bd625..2f42c4a2 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPGoogle(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPGoogle(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/v2/idp_ldap/resource_test.go index d5aea570..5f3dffc2 100644 --- a/zitadel/v2/idp_ldap/resource_test.go +++ b/zitadel/v2/idp_ldap/resource_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccZITADELInstanceIdPLDAP(t *testing.T) { @@ -13,7 +14,7 @@ func TestAccZITADELInstanceIdPLDAP(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go new file mode 100644 index 00000000..f9a92f80 --- /dev/null +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -0,0 +1,39 @@ +package idp_test_utils + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expectName string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + actual := remoteProvider.GetIdp().GetName() + if actual != expectName { + return fmt.Errorf("expected name %s, actual name: %s", expectName, actual) + } + return nil + } + } +} + +func CheckDestroy(frame test_utils.InstanceTestFrame) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go new file mode 100644 index 00000000..c6a4fa39 --- /dev/null +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -0,0 +1,43 @@ +package idp_test_utils + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func RunInstanceIDPLifecyleTest( + t *testing.T, + frame test_utils.InstanceTestFrame, + resourceFunc func(string, string) string, + secretAttribute string, +) { + const importedSecret = "an_imported_secret" + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + resourceFunc, + "an initial provider name", "an updated provider name", + "an_initial_secret", "an_updated_secret", + CheckProviderName(frame), + CheckDestroy(frame), + func(state *terraform.State) error { + // Check the secret is imported correctly + currentState := state.RootModule().Resources[frame.TerraformName].Primary + actual := currentState.Attributes[secretAttribute] + if actual != importedSecret { + return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) + } + return nil + }, + func(state *terraform.State) (string, error) { + lastState := state.RootModule().Resources[frame.TerraformName].Primary + return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil + }, + "12345", + secretAttribute, + ) +} diff --git a/zitadel/v2/idp_utils/test_utils/checks.go b/zitadel/v2/idp_utils/test_utils/checks.go deleted file mode 100644 index fa207fd2..00000000 --- a/zitadel/v2/idp_utils/test_utils/checks.go +++ /dev/null @@ -1,60 +0,0 @@ -package test_utils - -import ( - "fmt" - - "regexp" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -type ResponseProto interface { - GetIdp() *idp.Provider -} - -func CheckName(expect string, getProviderByIDResponse ResponseProto) resource.TestCheckFunc { - return func(*terraform.State) error { - actual := getProviderByIDResponse.GetIdp().GetName() - if actual != expect { - return fmt.Errorf("expected name %s, actual name: %s", expect, actual) - } - return nil - } -} - -func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { - // ZITADEL IDs have thirteen digits - idPattern := regexp.MustCompile(`\d{13}`) - return func(state *terraform.State) error { - return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) - } -} - -func CheckDestroy(ctx *InstanceTestFrame) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := AssignGetProviderByIDResponse(ctx, new(admin.GetProviderByIDResponse))(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - } -} - -func AssignGetProviderByIDResponse(ctx *InstanceTestFrame, assign *admin.GetProviderByIDResponse) resource.TestCheckFunc { - return func(state *terraform.State) (err error) { - rs := state.RootModule().Resources[ctx.TerraformName] - apiProvider, err := ctx.Client.GetProviderByID(ctx, &admin.GetProviderByIDRequest{Id: rs.Primary.ID}) - if err != nil { - return err - } - *assign = *apiProvider //nolint:govet - return nil - } -} diff --git a/zitadel/v2/idp_utils/test_utils/lifecyletest.go b/zitadel/v2/idp_utils/test_utils/lifecyletest.go deleted file mode 100644 index 88c16415..00000000 --- a/zitadel/v2/idp_utils/test_utils/lifecyletest.go +++ /dev/null @@ -1,94 +0,0 @@ -package test_utils - -import ( - "fmt" - "regexp" - "testing" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -const ( - initialProviderName = "an initial provider name" - updatedProviderName = "an updated provider name" - initialSecret = "an initial secret" - updatedSecret = "an updated secret" - importedSecret = "an imported secret" -) - -func RunBasicLifecyleTest( - t *testing.T, - frame *InstanceTestFrame, - resourceFunc func(string, string) string, - secretAttribute string, -) { - getProviderByIDResponse := new(admin.GetProviderByIDResponse) - initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) - updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, initialSecret)) - updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) - resource.Test(t, resource.TestCase{ - ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), - CheckDestroy: CheckDestroy(frame), - Steps: []resource.TestStep{ - { // Check first plan has a diff - Config: initialConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check resource is created - Config: initialConfig, - Check: resource.ComposeTestCheckFunc( - AssignGetProviderByIDResponse(frame, getProviderByIDResponse), - resource.ComposeAggregateTestCheckFunc( - CheckStateHasIDSet(frame.BaseTestFrame), - CheckName(initialProviderName, getProviderByIDResponse), - ), - ), - }, { // Check updating name has a diff - Config: updatedNameConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check name can be updated - Config: updatedNameConfig, - Check: resource.ComposeTestCheckFunc( - AssignGetProviderByIDResponse(frame, getProviderByIDResponse), - CheckName(updatedProviderName, getProviderByIDResponse), - ), - }, { // Check updating secret has a diff - Config: updatedSecretConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check secret can be updated - Config: updatedSecretConfig, - }, { // Expect import error if secret is not given - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateId: "12345", - ExpectError: regexp.MustCompile(`12345`), - }, { // Expect importing works - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateIdFunc: func(state *terraform.State) (string, error) { - lastState := state.RootModule().Resources[frame.TerraformName].Primary - return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil - }, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{secretAttribute}, - Check: func(state *terraform.State) error { - // Check the secret is imported correctly - currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes[secretAttribute] - if actual != importedSecret { - return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) - } - return nil - }, - }, - }, - }) -} diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 84b6dc32..87295626 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -2,6 +2,7 @@ package org_idp_azure_ad_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -11,11 +12,11 @@ import ( func TestAccZITADELOrgIdPAzureAD(t *testing.T) { resourceName := "zitadel_org_idp_azure_ad" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index 27c5625b..33467f30 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" @@ -11,11 +13,11 @@ import ( func TestAccZITADELOrgIdPGitHub(t *testing.T) { resourceName := "zitadel_org_idp_github" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go index 81a6ee19..1f8e4fa1 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" @@ -11,11 +13,11 @@ import ( func TestAccZITADELOrgIdPGitHubES(t *testing.T) { resourceName := "zitadel_org_idp_github_es" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go index 179c3f11..d65e7e51 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" @@ -11,11 +13,11 @@ import ( func TestAccZITADELOrgIdPGitLab(t *testing.T) { resourceName := "zitadel_org_idp_gitlab" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go index bf68894d..afec033b 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" @@ -11,11 +13,11 @@ import ( func TestAccZITADELOrgIdPGitLabSelfHosted(t *testing.T) { resourceName := "zitadel_org_idp_gitlab_self_hosted" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go index 06125397..5ae1adba 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -2,6 +2,7 @@ package org_idp_google_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -11,11 +12,11 @@ import ( func TestAccZITADELOrgIdPGoogle(t *testing.T) { resourceName := "zitadel_org_idp_google" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index e82ab490..834d3d74 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" @@ -11,11 +13,11 @@ import ( func TestAccZITADELOrgIdPLDAP(t *testing.T) { resourceName := "zitadel_org_idp_ldap" - frame, err := test_utils_org.NewOrgTestFrame(resourceName) + frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunBasicLifecyleTest(t, frame, func(name, secret string) string { + test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_utils/test_utils/checks.go b/zitadel/v2/org_idp_utils/test_utils/checks.go index bf723964..036446b3 100644 --- a/zitadel/v2/org_idp_utils/test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/test_utils/checks.go @@ -3,6 +3,8 @@ package test_utils import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" @@ -10,24 +12,29 @@ import ( "google.golang.org/grpc/status" ) -func CheckDestroy(frame *OrgTestFrame) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := AssignGetProviderByIDResponse(frame, new(management.GetProviderByIDResponse))(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) +func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expectName string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + actual := remoteProvider.GetIdp().GetName() + if actual != expectName { + return fmt.Errorf("expected name %s, actual name: %s", expectName, actual) + } + return nil } - return nil } } -func AssignGetProviderByIDResponse(frame *OrgTestFrame, assign *management.GetProviderByIDResponse) resource.TestCheckFunc { - return func(state *terraform.State) (err error) { - rs := state.RootModule().Resources[frame.TerraformName] - apiProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) - if err != nil { - return err +func CheckDestroy(frame test_utils.OrgTestFrame) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) } - *assign = *apiProvider //nolint:govet return nil } } diff --git a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go index 26f04c8a..77b56726 100644 --- a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go @@ -2,93 +2,44 @@ package test_utils import ( "fmt" - "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" -const ( - initialProviderName = "an initial provider name" - updatedProviderName = "an updated provider name" - initialSecret = "an initial secret" - updatedSecret = "an updated secret" - importedSecret = "an imported secret" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func RunBasicLifecyleTest( +func RunOrgLifecyleTest( t *testing.T, - frame *OrgTestFrame, + frame test_utils.OrgTestFrame, resourceFunc func(string, string) string, secretAttribute string, ) { - getProviderByIDResponse := new(management.GetProviderByIDResponse) - initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProviderName, initialSecret)) - updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, initialSecret)) - updatedClientSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProviderName, updatedSecret)) - resource.Test(t, resource.TestCase{ - ProviderFactories: test_utils.ZitadelProviderFactories(frame.ConfiguredProvider), - CheckDestroy: CheckDestroy(frame), - Steps: []resource.TestStep{ - { // Check first plan has a diff - Config: initialConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check resource is created - Config: initialConfig, - Check: resource.ComposeTestCheckFunc( - AssignGetProviderByIDResponse(frame, getProviderByIDResponse), - resource.ComposeAggregateTestCheckFunc( - test_utils.CheckStateHasIDSet(frame.BaseTestFrame), - test_utils.CheckName(initialProviderName, getProviderByIDResponse), - ), - ), - }, { // Check updating name has a diff - Config: updatedNameConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check name can be updated - Config: updatedNameConfig, - Check: resource.ComposeTestCheckFunc( - AssignGetProviderByIDResponse(frame, getProviderByIDResponse), - test_utils.CheckName(updatedProviderName, getProviderByIDResponse), - ), - }, { // Check updating secret has a diff - Config: updatedClientSecretConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check secret can be updated - Config: updatedClientSecretConfig, - }, { // Expect import error if secret is not given - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateId: "123:456", - ExpectError: regexp.MustCompile(`123:456`), - }, { // Expect importing works - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateIdFunc: func(state *terraform.State) (string, error) { - lastState := state.RootModule().Resources[frame.TerraformName].Primary - return fmt.Sprintf("%s:%s:%s", lastState.Attributes["org_id"], lastState.ID, importedSecret), nil - }, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{secretAttribute}, - Check: func(state *terraform.State) error { - // Check the secretAttribute is imported correctly - currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes[secretAttribute] - if actual != importedSecret { - return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) - } - return nil - }, - }, + const importedSecret = "an_imported_secret" + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + resourceFunc, + "an initial provider name", "an updated provider name", + "an_initial_secret", "an_updated_secret", + CheckProviderName(frame), + CheckDestroy(frame), + func(state *terraform.State) error { + // Check the secretAttribute is imported correctly + currentState := state.RootModule().Resources[frame.TerraformName].Primary + actual := currentState.Attributes[secretAttribute] + if actual != importedSecret { + return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) + } + return nil + }, + func(state *terraform.State) (string, error) { + lastState := state.RootModule().Resources[frame.TerraformName].Primary + return fmt.Sprintf("%s:%s:%s", lastState.Attributes[org_idp_utils.OrgIDVar], lastState.ID, importedSecret), nil }, - }) + "123:456", + secretAttribute, + ) } From 859f097452ad980ea593b4001b62d15a99089a95 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Apr 2023 10:01:57 +0200 Subject: [PATCH 116/260] test: reproduce trigger resource not working --- zitadel/v2/org_idp_azure_ad/resource_test.go | 8 +- zitadel/v2/org_idp_github/resource_test.go | 6 +- zitadel/v2/org_idp_github_es/resource_test.go | 6 +- zitadel/v2/org_idp_gitlab/resource_test.go | 6 +- .../resource_test.go | 6 +- zitadel/v2/org_idp_google/resource_test.go | 7 +- zitadel/v2/org_idp_ldap/resource_test.go | 6 +- .../checks.go | 2 +- .../lifecyletest.go | 2 +- zitadel/v2/trigger_actions/resource_test.go | 87 +++++++++++++++++++ 10 files changed, 106 insertions(+), 30 deletions(-) rename zitadel/v2/org_idp_utils/{test_utils => org_idp_test_utils}/checks.go (97%) rename zitadel/v2/org_idp_utils/{test_utils => org_idp_test_utils}/lifecyletest.go (97%) create mode 100644 zitadel/v2/trigger_actions/resource_test.go diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 87295626..056985e9 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -2,12 +2,12 @@ package org_idp_azure_ad_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func TestAccZITADELOrgIdPAzureAD(t *testing.T) { @@ -16,7 +16,7 @@ func TestAccZITADELOrgIdPAzureAD(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index 33467f30..5848e498 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPGitHub(t *testing.T) { @@ -17,7 +15,7 @@ func TestAccZITADELOrgIdPGitHub(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go index 1f8e4fa1..babd9d88 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPGitHubES(t *testing.T) { @@ -17,7 +15,7 @@ func TestAccZITADELOrgIdPGitHubES(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go index d65e7e51..fcca111a 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPGitLab(t *testing.T) { @@ -17,7 +15,7 @@ func TestAccZITADELOrgIdPGitLab(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go index afec033b..d975b5de 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPGitLabSelfHosted(t *testing.T) { @@ -17,7 +15,7 @@ func TestAccZITADELOrgIdPGitLabSelfHosted(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go index 5ae1adba..326849d5 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -2,12 +2,11 @@ package org_idp_google_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPGoogle(t *testing.T) { @@ -16,7 +15,7 @@ func TestAccZITADELOrgIdPGoogle(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index 834d3d74..d0313125 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPLDAP(t *testing.T) { @@ -17,7 +15,7 @@ func TestAccZITADELOrgIdPLDAP(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils_org.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" diff --git a/zitadel/v2/org_idp_utils/test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go similarity index 97% rename from zitadel/v2/org_idp_utils/test_utils/checks.go rename to zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 036446b3..55a5dcaa 100644 --- a/zitadel/v2/org_idp_utils/test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -1,4 +1,4 @@ -package test_utils +package org_idp_test_utils import ( "fmt" diff --git a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go similarity index 97% rename from zitadel/v2/org_idp_utils/test_utils/lifecyletest.go rename to zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 77b56726..5a55587e 100644 --- a/zitadel/v2/org_idp_utils/test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -1,4 +1,4 @@ -package test_utils +package org_idp_test_utils import ( "fmt" diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go new file mode 100644 index 00000000..8fc0470f --- /dev/null +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -0,0 +1,87 @@ +package trigger_actions_test + +import ( + "errors" + "fmt" + "testing" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccTriggerActions(t *testing.T) { + resourceName := "zitadel_trigger_actions" + flowType := "FLOW_TYPE_CUSTOMISE_TOKEN" + initialTriggerType := "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION" + updatedTriggerType := "TRIGGER_TYPE_POST_AUTHENTICATION" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + // Always creates a new action + action, err := frame.CreateAction(frame, &management.CreateActionRequest{ + Name: frame.UniqueResourcesID, + Script: "not a script", + Timeout: durationpb.New(10 * time.Second), + AllowedToFail: true, + }) + if err != nil { + t.Fatalf("failed to create action: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(name, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" +flow_type = "%s" + trigger_type = "%s" + action_ids = ["%s"] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, flowType, name, action.GetId()) + }, + initialTriggerType, updatedTriggerType, + "", "", + CheckTriggerType(*frame, flowType), + CheckDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), + nil, nil, "", "", + ) +} + +var errTriggerTypeNotFound = errors.New("trigger type not found") + +func CheckTriggerType(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { + return func(expectTriggerType string) resource.TestCheckFunc { + return func(state *terraform.State) error { + triggerTypes, err := frame.ListFlowTriggerTypes(frame, &management.ListFlowTriggerTypesRequest{Type: flowType}) + if err != nil { + return err + } + result := triggerTypes.GetResult() + for _, actual := range result { + if actual.GetId() == expectTriggerType { + return nil + } + } + return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, result, errTriggerTypeNotFound) + } + } +} + +func CheckDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []string) resource.TestCheckFunc { + return func(state *terraform.State) error { + for _, testTriggerType := range testTypes { + if err := CheckTriggerType(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { + return fmt.Errorf("expected error %v, but got %v", errTriggerTypeNotFound, err) + } + } + return nil + } +} From 3f90b9a025e41ce1ab59709ed51b19807b8f2e88 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Apr 2023 12:24:54 +0200 Subject: [PATCH 117/260] fix: store action ids in trigger state --- zitadel/v2/trigger_actions/funcs.go | 57 +++++++++++++++------ zitadel/v2/trigger_actions/resource.go | 12 ++--- zitadel/v2/trigger_actions/resource_test.go | 31 +++++++---- 3 files changed, 67 insertions(+), 33 deletions(-) diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index 2b180156..df3cbc2d 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -26,9 +26,9 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } flowType := d.Get(flowTypeVar).(string) - flowTypeValues := helper.EnumValueMap(flowTypes()) + flowTypeValues := helper.EnumValueMap(FlowTypes()) triggerType := d.Get(triggerTypeVar).(string) - triggerTypeValues := helper.EnumValueMap(triggerTypes()) + triggerTypeValues := helper.EnumValueMap(TriggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: strconv.Itoa(int(flowTypeValues[flowType])), TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), @@ -42,21 +42,18 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) if err != nil { return diag.FromErr(err) } - flowType := d.Get(flowTypeVar).(string) - flowTypeValues := helper.EnumValueMap(flowTypes()) + flowTypeValues := helper.EnumValueMap(FlowTypes()) triggerType := d.Get(triggerTypeVar).(string) - triggerTypeValues := helper.EnumValueMap(triggerTypes()) + triggerTypeValues := helper.EnumValueMap(TriggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: strconv.Itoa(int(flowTypeValues[flowType])), TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), @@ -65,44 +62,72 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.Errorf("failed to update trigger actions: %v", err) } - return nil } func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) } - flowType := d.Get(flowTypeVar).(string) - flowTypeValues := helper.EnumValueMap(flowTypes()) + flowTypeValues := helper.EnumValueMap(FlowTypes()) triggerType := d.Get(triggerTypeVar).(string) - triggerTypeValues := helper.EnumValueMap(triggerTypes()) + triggerTypeValues := helper.EnumValueMap(TriggerTypes()) + actionIDs := helper.GetOkSetToStringSlice(d, actionsVar) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: strconv.Itoa(int(flowTypeValues[flowType])), TriggerType: strconv.Itoa(int(triggerTypeValues[triggerType])), - ActionIds: helper.GetOkSetToStringSlice(d, actionsVar), + ActionIds: actionIDs, }) + if err != nil { + return diag.Errorf("failed to create trigger actions: %v", err) + } d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) - return nil } func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } orgID := d.Get(orgIDVar).(string) flowType := d.Get(flowTypeVar).(string) triggerType := d.Get(triggerTypeVar).(string) + client, err := helper.GetManagementClient(clientinfo, orgID) + if err != nil { + return diag.FromErr(err) + } + flowTypeValues := helper.EnumValueMap(FlowTypes()) + triggerTypeNames := TriggerTypes() + resp, err := client.GetFlow(ctx, &management.GetFlowRequest{Type: strconv.Itoa(int(flowTypeValues[flowType]))}) + if err != nil { + return diag.FromErr(err) + } + var actionIDs []string + for _, triggerAction := range resp.GetFlow().GetTriggerActions() { + triggerTypeID, err := strconv.Atoi(triggerAction.GetTriggerType().GetId()) + if err != nil { + return diag.FromErr(err) + } + if triggerTypeNames[int32(triggerTypeID)] != triggerType { + continue + } + for _, action := range triggerAction.GetActions() { + actionIDs = append(actionIDs, action.GetId()) + } + } + if err = d.Set(actionsVar, actionIDs); err != nil { + return diag.Errorf("setting action ids %s to property %s failed: %v", actionIDs, actionsVar, err) + } d.SetId(getTriggerActionsID(orgID, flowType, triggerType)) return nil } diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 364efdbb..abce8254 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -21,18 +21,18 @@ func GetResource() *schema.Resource { flowTypeVar: { Type: schema.TypeString, Required: true, - Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(flowTypes()), + Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(FlowTypes()), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(flowTypeVar, value, helper.EnumValueMap(flowTypes())) + return helper.EnumValueValidation(flowTypeVar, value, helper.EnumValueMap(FlowTypes())) }, ForceNew: true, }, triggerTypeVar: { Type: schema.TypeString, Required: true, - Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(triggerTypes()), + Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(TriggerTypes()), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(triggerTypeVar, value, helper.EnumValueMap(triggerTypes())) + return helper.EnumValueValidation(triggerTypeVar, value, helper.EnumValueMap(TriggerTypes())) }, ForceNew: true, }, @@ -53,14 +53,14 @@ func GetResource() *schema.Resource { } } -func flowTypes() map[int32]string { +func FlowTypes() map[int32]string { return map[int32]string{ 1: "FLOW_TYPE_EXTERNAL_AUTHENTICATION", 2: "FLOW_TYPE_CUSTOMISE_TOKEN", 3: "FLOW_TYPE_INTERNAL_AUTHENTICATION", } } -func triggerTypes() map[int32]string { +func TriggerTypes() map[int32]string { return map[int32]string{ 1: "TRIGGER_TYPE_POST_AUTHENTICATION", 2: "TRIGGER_TYPE_PRE_CREATION", diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 8fc0470f..32f04d69 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -3,24 +3,25 @@ package trigger_actions_test import ( "errors" "fmt" + "strconv" "testing" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/durationpb" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" ) func TestAccTriggerActions(t *testing.T) { resourceName := "zitadel_trigger_actions" flowType := "FLOW_TYPE_CUSTOMISE_TOKEN" initialTriggerType := "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION" - updatedTriggerType := "TRIGGER_TYPE_POST_AUTHENTICATION" + updatedTriggerType := "TRIGGER_TYPE_PRE_USERINFO_CREATION" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) @@ -60,17 +61,25 @@ var errTriggerTypeNotFound = errors.New("trigger type not found") func CheckTriggerType(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { return func(expectTriggerType string) resource.TestCheckFunc { return func(state *terraform.State) error { - triggerTypes, err := frame.ListFlowTriggerTypes(frame, &management.ListFlowTriggerTypesRequest{Type: flowType}) + flowTypeValues := helper.EnumValueMap(trigger_actions.FlowTypes()) + resp, err := frame.GetFlow(frame, &management.GetFlowRequest{Type: strconv.Itoa(int(flowTypeValues[flowType]))}) if err != nil { - return err + return fmt.Errorf("flow type not found: %w", err) } - result := triggerTypes.GetResult() - for _, actual := range result { - if actual.GetId() == expectTriggerType { + typesMapping := trigger_actions.TriggerTypes() + var foundTypes []string + for _, actual := range resp.GetFlow().GetTriggerActions() { + idInt, err := strconv.Atoi(actual.GetTriggerType().GetId()) + if err != nil { + return err + } + foundType := typesMapping[int32(idInt)] + foundTypes = append(foundTypes, foundType) + if foundType == expectTriggerType { return nil } } - return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, result, errTriggerTypeNotFound) + return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, foundTypes, errTriggerTypeNotFound) } } } @@ -79,7 +88,7 @@ func CheckDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []st return func(state *terraform.State) error { for _, testTriggerType := range testTypes { if err := CheckTriggerType(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { - return fmt.Errorf("expected error %v, but got %v", errTriggerTypeNotFound, err) + return fmt.Errorf("expected error %v, but got %w", errTriggerTypeNotFound, err) } } return nil From b469664f76317bc59cbe114c58039b091da2fd54 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 05:06:59 +0200 Subject: [PATCH 118/260] describe executing tests against http://localhost:8080 --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a2610b18..a0b6deef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,9 @@ # Run Acceptance Tests +Ensure ZITADEL listens at http://localhost:8080 and you have a service account key in your local filesystem. +The easiest way to achieve that is [to follow this guide](https://zitadel.com/docs/self-hosting/deploy/compose#docker-compose-with-service-account). + ```bash TF_ACC=1 TF_ACC_ZITADEL_TOKEN=/my-token.json go test ./... ``` From ec9ac2db8b923ab3c7c3ecb5bc82a959b062d2ff Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 06:57:51 +0200 Subject: [PATCH 119/260] clean schema definitions --- zitadel/v2/idp_azure_ad/datasource.go | 76 +---- zitadel/v2/idp_azure_ad/funcs.go | 36 +-- zitadel/v2/idp_azure_ad/resource.go | 73 +---- zitadel/v2/idp_azure_ad/resource_test.go | 3 +- zitadel/v2/idp_azure_ad/schema.go | 47 +++ zitadel/v2/idp_github/datasource.go | 58 +--- zitadel/v2/idp_github/resource.go | 53 +--- zitadel/v2/idp_github/resource_test.go | 3 +- zitadel/v2/idp_github_es/datasource.go | 76 +---- zitadel/v2/idp_github_es/funcs.go | 52 ++-- zitadel/v2/idp_github_es/resource.go | 70 +---- zitadel/v2/idp_github_es/resource_test.go | 3 +- zitadel/v2/idp_github_es/schema.go | 42 +++ zitadel/v2/idp_gitlab/datasource.go | 58 +--- zitadel/v2/idp_gitlab/resource.go | 52 +--- zitadel/v2/idp_gitlab/resource_test.go | 3 +- .../v2/idp_gitlab_self_hosted/datasource.go | 74 +---- zitadel/v2/idp_gitlab_self_hosted/funcs.go | 6 +- zitadel/v2/idp_gitlab_self_hosted/resource.go | 58 +--- .../idp_gitlab_self_hosted/resource_test.go | 4 +- zitadel/v2/idp_gitlab_self_hosted/schema.go | 18 ++ zitadel/v2/idp_google/datasource.go | 58 +--- zitadel/v2/idp_google/resource.go | 52 +--- zitadel/v2/idp_google/resource_test.go | 3 +- zitadel/v2/idp_ldap/datasource.go | 182 ++---------- zitadel/v2/idp_ldap/funcs.go | 166 ++++++----- zitadel/v2/idp_ldap/resource.go | 176 ++--------- zitadel/v2/idp_ldap/resource_test.go | 4 +- zitadel/v2/idp_ldap/schema.go | 273 ++++++++++++++++++ zitadel/v2/idp_utils/const.go | 44 --- zitadel/v2/idp_utils/schema.go | 111 +++++++ zitadel/v2/org_idp_azure_ad/datasource.go | 83 +----- zitadel/v2/org_idp_azure_ad/funcs.go | 32 +- zitadel/v2/org_idp_azure_ad/resource.go | 80 +---- zitadel/v2/org_idp_github/datasource.go | 64 +--- zitadel/v2/org_idp_github/resource.go | 59 +--- zitadel/v2/org_idp_github_es/datasource.go | 83 +----- zitadel/v2/org_idp_github_es/funcs.go | 56 ++-- zitadel/v2/org_idp_github_es/resource.go | 78 +---- zitadel/v2/org_idp_gitlab/datasource.go | 64 +--- zitadel/v2/org_idp_gitlab/resource.go | 59 +--- .../org_idp_gitlab_self_hosted/datasource.go | 71 +---- .../v2/org_idp_gitlab_self_hosted/funcs.go | 26 +- .../v2/org_idp_gitlab_self_hosted/resource.go | 66 +---- zitadel/v2/org_idp_google/datasource.go | 64 +--- zitadel/v2/org_idp_google/resource.go | 59 +--- zitadel/v2/org_idp_ldap/datasource.go | 187 ++---------- zitadel/v2/org_idp_ldap/funcs.go | 170 +++++------ zitadel/v2/org_idp_ldap/resource.go | 184 ++---------- zitadel/v2/org_idp_ldap/resource_test.go | 4 +- zitadel/v2/org_idp_utils/const.go | 5 - zitadel/v2/org_idp_utils/resource.go | 1 + zitadel/v2/org_idp_utils/schema.go | 21 ++ 53 files changed, 1187 insertions(+), 2263 deletions(-) create mode 100644 zitadel/v2/idp_azure_ad/schema.go create mode 100644 zitadel/v2/idp_github_es/schema.go create mode 100644 zitadel/v2/idp_gitlab_self_hosted/schema.go create mode 100644 zitadel/v2/idp_ldap/schema.go delete mode 100644 zitadel/v2/idp_utils/const.go create mode 100644 zitadel/v2/idp_utils/schema.go delete mode 100644 zitadel/v2/org_idp_utils/const.go create mode 100644 zitadel/v2/org_idp_utils/resource.go create mode 100644 zitadel/v2/org_idp_utils/schema.go diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go index 54a7ac20..ae38d569 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -9,70 +9,18 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an Azure AD IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.TenantTypeVar: { - Type: schema.TypeString, - Computed: true, - Description: "the azure ad tenant type", - }, - idp_utils.TenantIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "the azure ad tenant id", - }, - idp_utils.EmailVerifiedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "automatically mark emails as verified", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + TenantTypeVar: TenantTypeDataSourceField, + TenantIDVar: TenantIDDataSourceField, + EmailVerifiedVar: EmailVerifiedDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go index a6d68df9..e8ecb3c2 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -22,18 +22,18 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddAzureADProvider(ctx, &admin.AddAzureADProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Tenant: ConstructTenant(d), - EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + Tenant: ConstructTenant(d), + EmailVerified: d.Get(EmailVerifiedVar).(bool), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -53,19 +53,19 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChangesExcept(idp_utils.IdpIDVar) { _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - Tenant: ConstructTenant(d), - EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + Tenant: ConstructTenant(d), + EmailVerified: d.Get(EmailVerifiedVar).(bool), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -100,13 +100,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.EmailVerifiedVar: specificCfg.GetEmailVerified(), - idp_utils.TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], - idp_utils.TenantIDVar: specificCfg.GetTenant().GetTenantId(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + EmailVerifiedVar: specificCfg.GetEmailVerified(), + TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], + TenantIDVar: specificCfg.GetTenant().GetTenantId(), } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -119,14 +119,14 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn func ConstructTenant(d *schema.ResourceData) *idp.AzureADTenant { tenant := &idp.AzureADTenant{} - tenantId := d.Get(idp_utils.TenantIDVar).(string) + tenantId := d.Get(TenantIDVar).(string) if tenantId != "" { tenant.Type = &idp.AzureADTenant_TenantId{ TenantId: tenantId, } } else { tenant.Type = &idp.AzureADTenant_TenantType{ - TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[d.Get(idp_utils.TenantTypeVar).(string)]), + TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[d.Get(TenantTypeVar).(string)]), } } return tenant diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/v2/idp_azure_ad/resource.go index 10897fd5..9b310a85 100644 --- a/zitadel/v2/idp_azure_ad/resource.go +++ b/zitadel/v2/idp_azure_ad/resource.go @@ -1,8 +1,6 @@ package idp_azure_ad import ( - "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,66 +10,17 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an Azure AD IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.TenantTypeVar: { - Type: schema.TypeString, - Optional: true, - Default: "AZURE_AD_TENANT_TYPE_COMMON", - Description: "the azure ad tenant type", - }, - idp_utils.TenantIDVar: { - Type: schema.TypeString, - Optional: true, - Description: fmt.Sprintf("if %s is not set, the %s is used", idp_utils.TenantIDVar, idp_utils.TenantTypeVar), - }, - idp_utils.EmailVerifiedVar: { - Type: schema.TypeBool, - Required: true, - Description: "automatically mark emails as verified", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + TenantTypeVar: TenantTypeResourceField, + TenantIDVar: TenantIDResourceField, + EmailVerifiedVar: EmailVerifiedResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index f50f0409..a4dd5597 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -2,6 +2,7 @@ package idp_azure_ad_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" @@ -28,5 +29,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_azure_ad/schema.go b/zitadel/v2/idp_azure_ad/schema.go new file mode 100644 index 00000000..2106106f --- /dev/null +++ b/zitadel/v2/idp_azure_ad/schema.go @@ -0,0 +1,47 @@ +package idp_azure_ad + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +const ( + TenantTypeVar = "tenant_type" + TenantIDVar = "tenant_id" + EmailVerifiedVar = "email_verified" +) + +var ( + TenantTypeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "AZURE_AD_TENANT_TYPE_COMMON", + Description: "the azure ad tenant type", + } + TenantTypeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant type", + } + TenantIDResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: fmt.Sprintf("if %s is not set, the %s is used", TenantIDVar, TenantTypeVar), + } + TenantIDDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the azure ad tenant id", + } + EmailVerifiedResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "automatically mark emails as verified", + } + EmailVerifiedDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "automatically mark emails as verified", + } +) diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go index 3d3f7733..a8ec803b 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/v2/idp_github/datasource.go @@ -9,55 +9,15 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index cc4bbc5d..f3212694 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -2,7 +2,6 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -10,50 +9,14 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index 79a4ad2b..c3cd69f6 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -2,6 +2,7 @@ package idp_github_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" @@ -25,5 +26,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go index 1773e7a8..f0556d16 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/v2/idp_github_es/datasource.go @@ -9,70 +9,18 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub Enterprise IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.AuthorizationEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers authorization endpoint", - }, - idp_utils.TokenEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers token endpoint", - }, - idp_utils.UserEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers user endpoint", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + AuthorizationEndpointVar: AuthorizationEndpointDataSourceField, + TokenEndpointVar: TokenEndpointDataSourceField, + UserEndpointVar: UserEndpointDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_github_es/funcs.go b/zitadel/v2/idp_github_es/funcs.go index 0cbc6adc..ce2de08d 100644 --- a/zitadel/v2/idp_github_es/funcs.go +++ b/zitadel/v2/idp_github_es/funcs.go @@ -22,19 +22,19 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &admin.AddGitHubEnterpriseServerProviderRequest{ - ClientId: d.Get(idp_utils.ClientIDVar).(string), - Name: d.Get(idp_utils.NameVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + Name: d.Get(idp_utils.NameVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(TokenEndpointVar).(string), + UserEndpoint: d.Get(UserEndpointVar).(string), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -54,20 +54,20 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChangesExcept(idp_utils.IdpIDVar) { _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &admin.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(TokenEndpointVar).(string), + UserEndpoint: d.Get(UserEndpointVar).(string), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -98,17 +98,17 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithubEs() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - idp_utils.NameVar: idp.GetName(), - idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), - idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), - idp_utils.TokenEndpointVar: specificCfg.GetTokenEndpoint(), - idp_utils.UserEndpointVar: specificCfg.GetUserEndpoint(), - idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), + TokenEndpointVar: specificCfg.GetTokenEndpoint(), + UserEndpointVar: specificCfg.GetUserEndpoint(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/v2/idp_github_es/resource.go index 04627b6b..c2bf6e76 100644 --- a/zitadel/v2/idp_github_es/resource.go +++ b/zitadel/v2/idp_github_es/resource.go @@ -10,65 +10,17 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub Enterprise IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.AuthorizationEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers authorization endpoint", - }, - idp_utils.TokenEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers token endpoint", - }, - idp_utils.UserEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers user endpoint", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + AuthorizationEndpointVar: AuthorizationEndpointResourceField, + TokenEndpointVar: TokenEndpointResourceField, + UserEndpointVar: UserEndpointResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index f3904769..27905d31 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -2,6 +2,7 @@ package idp_github_es_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" @@ -28,5 +29,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_github_es/schema.go b/zitadel/v2/idp_github_es/schema.go new file mode 100644 index 00000000..b7d7067f --- /dev/null +++ b/zitadel/v2/idp_github_es/schema.go @@ -0,0 +1,42 @@ +package idp_github_es + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const ( + AuthorizationEndpointVar = "authorization_endpoint" + TokenEndpointVar = "token_endpoint" + UserEndpointVar = "user_endpoint" +) + +var ( + AuthorizationEndpointResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "the providers authorization endpoint", + } + AuthorizationEndpointDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the providers authorization endpoint", + } + TokenEndpointResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "the providers token endpoint", + } + TokenEndpointDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the providers token endpoint", + } + UserEndpointResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "the providers user endpoint", + } + UserEndpointDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the providers user endpoint", + } +) diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go index 56ce45dd..8db640c3 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -9,55 +9,15 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitLab IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/v2/idp_gitlab/resource.go index 21c8bb9a..c3e2b0bc 100644 --- a/zitadel/v2/idp_gitlab/resource.go +++ b/zitadel/v2/idp_gitlab/resource.go @@ -10,50 +10,14 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index 8a71a9d0..603bb0ce 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -2,6 +2,7 @@ package idp_gitlab_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" @@ -25,5 +26,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go index f9f7b29b..fcc9ac96 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -9,70 +9,16 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitLab Self Hosted IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IssuerVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers issuer", - }, - idp_utils.TokenEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers token endpoint", - }, - idp_utils.UserEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers user endpoint", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + IssuerVar: IssuerDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_gitlab_self_hosted/funcs.go b/zitadel/v2/idp_gitlab_self_hosted/funcs.go index 48cc0b4b..30b9e1b9 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/idp_gitlab_self_hosted/funcs.go @@ -25,7 +25,6 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientId: d.Get(idp_utils.ClientIDVar).(string), Name: d.Get(idp_utils.NameVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Issuer: d.Get(idp_utils.IssuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), @@ -33,6 +32,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + Issuer: d.Get(IssuerVar).(string), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -57,13 +57,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientId: d.Get(idp_utils.ClientIDVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - Issuer: d.Get(idp_utils.IssuerVar).(string), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + Issuer: d.Get(IssuerVar).(string), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -98,11 +98,11 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.IssuerVar: specificCfg.GetIssuer(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + IssuerVar: specificCfg.GetIssuer(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/v2/idp_gitlab_self_hosted/resource.go index e1ce7efa..aa313368 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource.go @@ -10,55 +10,15 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab Self Hosted IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IssuerVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers issuer", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + IssuerVar: IssuerResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go index b999ef22..42850fdd 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" ) @@ -26,5 +28,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_gitlab_self_hosted/schema.go b/zitadel/v2/idp_gitlab_self_hosted/schema.go new file mode 100644 index 00000000..3b3d571d --- /dev/null +++ b/zitadel/v2/idp_gitlab_self_hosted/schema.go @@ -0,0 +1,18 @@ +package idp_gitlab_self_hosted + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const IssuerVar = "issuer" + +var ( + IssuerResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "the providers issuer", + } + IssuerDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the providers issuer", + } +) diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go index 68c6d6fa..8d61ae8f 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/v2/idp_google/datasource.go @@ -9,55 +9,15 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a Google IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/v2/idp_google/resource.go index a8ebeb57..048a88bf 100644 --- a/zitadel/v2/idp_google/resource.go +++ b/zitadel/v2/idp_google/resource.go @@ -10,50 +10,14 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a Google IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index e83bd625..9e1344c2 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -2,6 +2,7 @@ package idp_google_test import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" @@ -25,5 +26,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "client_secret") + }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_ldap/datasource.go b/zitadel/v2/idp_ldap/datasource.go index 4eaedf65..97fe7026 100644 --- a/zitadel/v2/idp_ldap/datasource.go +++ b/zitadel/v2/idp_ldap/datasource.go @@ -9,158 +9,38 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an LDAP IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ServersVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "Servers to try in order for establishing LDAP connections", - }, - idp_utils.StartTLSVar: { - Type: schema.TypeBool, - Computed: true, - Description: "Wether to use StartTLS for LDAP connections", - }, - idp_utils.BaseDNVar: { - Type: schema.TypeString, - Computed: true, - Description: "Base DN for LDAP connections", - }, - idp_utils.BindDNVar: { - Type: schema.TypeString, - Computed: true, - Description: "Bind DN for LDAP connections", - }, - idp_utils.BindPasswordVar: { - Type: schema.TypeString, - Computed: true, - Description: "Bind password for LDAP connections", - Sensitive: true, - }, - idp_utils.UserBaseVar: { - Type: schema.TypeString, - Computed: true, - Description: "User base for LDAP connections", - }, - idp_utils.UserObjectClassesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "User object classes for LDAP connections", - }, - idp_utils.UserFiltersVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "User filters for LDAP connections", - }, - idp_utils.TimeoutVar: { - Type: schema.TypeString, - Computed: true, - Description: "Timeout for LDAP connections", - }, - idp_utils.IdAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the id", - }, - idp_utils.FirstNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the first name", - }, - idp_utils.LastNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the last name", - }, - idp_utils.DisplayNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the display name", - }, - idp_utils.NickNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the nick name", - }, - idp_utils.PreferredUsernameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the preferred username", - }, - idp_utils.EmailAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the email", - }, - idp_utils.EmailVerifiedAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the email verified state", - }, - idp_utils.PhoneAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the phone", - }, - idp_utils.PhoneVerifiedAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the phone verified state", - }, - idp_utils.PreferredLanguageAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the preferred language", - }, - idp_utils.AvatarURLAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the avatar url", - }, - idp_utils.ProfileAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the profile", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + + ServersVar: ServersDataSourceField, + StartTLSVar: StartTLSDataSourceField, + BaseDNVar: BaseDNDataSourceField, + BindDNVar: BindDNDataSourceField, + BindPasswordVar: BindPasswordDataSourceField, + UserBaseVar: UserBaseDataSourceField, + UserObjectClassesVar: UserObjectClassesDataSourceField, + UserFiltersVar: UserFiltersDataSourceField, + TimeoutVar: TimeoutDataSourceField, + IdAttributeVar: IdAttributeDataSourceField, + + FirstNameAttributeVar: FirstNameAttributeDataSourceField, + LastNameAttributeVar: LastNameAttributeDataSourceField, + DisplayNameAttributeVar: DisplayNameAttributeDataSourceField, + NickNameAttributeVar: NickNameAttributeDataSourceField, + PreferredUsernameAttributeVar: PreferredUsernameAttributeDataSourceField, + EmailAttributeVar: EmailAttributeDataSourceField, + EmailVerifiedAttributeVar: EmailVerifiedAttributeDataSourceField, + PhoneAttributeVar: PhoneAttributeDataSourceField, + PhoneVerifiedAttributeVar: PhoneVerifiedAttributeDataSourceField, + PreferredLanguageAttributeVar: PreferredLanguageAttributeDataSourceField, + AvatarURLAttributeVar: AvatarURLAttributeDataSourceField, + ProfileAttributeVar: ProfileAttributeDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(BindPasswordVar)}, } } diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/v2/idp_ldap/funcs.go index bb7b1d7f..932590d3 100644 --- a/zitadel/v2/idp_ldap/funcs.go +++ b/zitadel/v2/idp_ldap/funcs.go @@ -24,42 +24,44 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + timeout, err := time.ParseDuration(d.Get(TimeoutVar).(string)) if err != nil { return diag.FromErr(err) } req := &admin.AddLDAPProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), - StartTls: d.Get(idp_utils.StartTLSVar).(bool), - BaseDn: d.Get(idp_utils.BaseDNVar).(string), - BindDn: d.Get(idp_utils.BindDNVar).(string), - BindPassword: d.Get(idp_utils.BindPasswordVar).(string), - UserBase: d.Get(idp_utils.UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), - Timeout: durationpb.New(timeout), - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), - }, + Name: d.Get(idp_utils.NameVar).(string), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + + Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), + StartTls: d.Get(StartTLSVar).(bool), + BaseDn: d.Get(BaseDNVar).(string), + BindDn: d.Get(BindDNVar).(string), + BindPassword: d.Get(BindPasswordVar).(string), + UserBase: d.Get(UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), + Timeout: durationpb.New(timeout), + + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(IdAttributeVar).(string), + FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(ProfileAttributeVar).(string), + }, } resp, err := client.AddLDAPProvider(ctx, req) if err != nil { @@ -78,44 +80,46 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + timeout, err := time.ParseDuration(d.Get(TimeoutVar).(string)) if err != nil { return diag.FromErr(err) } if d.HasChangesExcept(idp_utils.IdpIDVar) { _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), - StartTls: d.Get(idp_utils.StartTLSVar).(bool), - BaseDn: d.Get(idp_utils.BaseDNVar).(string), - BindDn: d.Get(idp_utils.BindDNVar).(string), - BindPassword: d.Get(idp_utils.BindPasswordVar).(string), - UserBase: d.Get(idp_utils.UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), - Timeout: durationpb.New(timeout), - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), - }, + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + + Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), + StartTls: d.Get(StartTLSVar).(bool), + BaseDn: d.Get(BaseDNVar).(string), + BindDn: d.Get(BindDNVar).(string), + BindPassword: d.Get(BindPasswordVar).(string), + UserBase: d.Get(UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), + Timeout: durationpb.New(timeout), + + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(IdAttributeVar).(string), + FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(ProfileAttributeVar).(string), + }, }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -147,33 +151,35 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn attributesCfg := specificCfg.GetAttributes() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - idp_utils.NameVar: idp.GetName(), - idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), - idp_utils.ServersVar: specificCfg.GetServers(), - idp_utils.StartTLSVar: specificCfg.GetStartTls(), - idp_utils.BaseDNVar: specificCfg.GetBaseDn(), - idp_utils.BindDNVar: specificCfg.GetBindDn(), - idp_utils.BindPasswordVar: d.Get(idp_utils.BindPasswordVar).(string), - idp_utils.UserBaseVar: specificCfg.GetUserBase(), - idp_utils.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), - idp_utils.UserFiltersVar: specificCfg.GetUserFilters(), - idp_utils.TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), - idp_utils.IdAttributeVar: attributesCfg.GetIdAttribute(), - idp_utils.FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), - idp_utils.LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), - idp_utils.DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), - idp_utils.NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), - idp_utils.PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), - idp_utils.EmailAttributeVar: attributesCfg.GetEmailAttribute(), - idp_utils.EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), - idp_utils.PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), - idp_utils.PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), - idp_utils.PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), - idp_utils.AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), - idp_utils.ProfileAttributeVar: attributesCfg.GetProfileAttribute(), + idp_utils.NameVar: idp.GetName(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + + ServersVar: specificCfg.GetServers(), + StartTLSVar: specificCfg.GetStartTls(), + BaseDNVar: specificCfg.GetBaseDn(), + BindDNVar: specificCfg.GetBindDn(), + BindPasswordVar: d.Get(BindPasswordVar).(string), + UserBaseVar: specificCfg.GetUserBase(), + UserObjectClassesVar: specificCfg.GetUserObjectClasses(), + UserFiltersVar: specificCfg.GetUserFilters(), + TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), + IdAttributeVar: attributesCfg.GetIdAttribute(), + + FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), + LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), + DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), + NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), + PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), + EmailAttributeVar: attributesCfg.GetEmailAttribute(), + EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), + PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), + PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), + PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), + AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), + ProfileAttributeVar: attributesCfg.GetProfileAttribute(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/idp_ldap/resource.go b/zitadel/v2/idp_ldap/resource.go index 3efb6470..734c351c 100644 --- a/zitadel/v2/idp_ldap/resource.go +++ b/zitadel/v2/idp_ldap/resource.go @@ -10,156 +10,40 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an LDAP IDP on the instance.", Schema: map[string]*schema.Schema{ - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ServersVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "Servers to try in order for establishing LDAP connections", - }, - idp_utils.StartTLSVar: { - Type: schema.TypeBool, - Required: true, - Description: "Wether to use StartTLS for LDAP connections", - }, - idp_utils.BaseDNVar: { - Type: schema.TypeString, - Required: true, - Description: "Base DN for LDAP connections", - }, - idp_utils.BindDNVar: { - Type: schema.TypeString, - Required: true, - Description: "Bind DN for LDAP connections", - }, - idp_utils.BindPasswordVar: { - Type: schema.TypeString, - Required: true, - Description: "Bind password for LDAP connections", - Sensitive: true, - }, - idp_utils.UserBaseVar: { - Type: schema.TypeString, - Required: true, - Description: "User base for LDAP connections", - }, - idp_utils.UserObjectClassesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "User object classes for LDAP connections", - }, - idp_utils.UserFiltersVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "User filters for LDAP connections", - }, - idp_utils.TimeoutVar: { - Type: schema.TypeString, - Required: true, - Description: "Timeout for LDAP connections", - }, - idp_utils.IdAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the id", - }, - idp_utils.FirstNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the first name", - }, - idp_utils.LastNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the last name", - }, - idp_utils.DisplayNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the display name", - }, - idp_utils.NickNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the nick name", - }, - idp_utils.PreferredUsernameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the preferred username", - }, - idp_utils.EmailAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the email", - }, - idp_utils.EmailVerifiedAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the email verified state", - }, - idp_utils.PhoneAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the phone", - }, - idp_utils.PhoneVerifiedAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the phone verified state", - }, - idp_utils.PreferredLanguageAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the preferred language", - }, - idp_utils.AvatarURLAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the avatar url", - }, - idp_utils.ProfileAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the profile", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + + ServersVar: ServersResourceField, + StartTLSVar: StartTLSResourceField, + BaseDNVar: BaseDNResourceField, + BindDNVar: BindDNResourceField, + BindPasswordVar: BindPasswordResourceField, + UserBaseVar: UserBaseResourceField, + UserObjectClassesVar: UserObjectClassesResourceField, + UserFiltersVar: UserFiltersResourceField, + TimeoutVar: TimeoutResourceField, + IdAttributeVar: IdAttributeResourceField, + + FirstNameAttributeVar: FirstNameAttributeResourceField, + LastNameAttributeVar: LastNameAttributeResourceField, + DisplayNameAttributeVar: DisplayNameAttributeResourceField, + NickNameAttributeVar: NickNameAttributeResourceField, + PreferredUsernameAttributeVar: PreferredUsernameAttributeResourceField, + EmailAttributeVar: EmailAttributeResourceField, + EmailVerifiedAttributeVar: EmailVerifiedAttributeResourceField, + PhoneAttributeVar: PhoneAttributeResourceField, + PhoneVerifiedAttributeVar: PhoneVerifiedAttributeResourceField, + PreferredLanguageAttributeVar: PreferredLanguageAttributeResourceField, + AvatarURLAttributeVar: AvatarURLAttributeResourceField, + ProfileAttributeVar: ProfileAttributeResourceField, }, ReadContext: read, UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.BindPasswordVar)}, + Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(BindPasswordVar)}, } } diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/v2/idp_ldap/resource_test.go index d5aea570..bae38944 100644 --- a/zitadel/v2/idp_ldap/resource_test.go +++ b/zitadel/v2/idp_ldap/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/test_utils" ) @@ -34,5 +36,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, name, secret) - }, "bind_password") + }, idp_ldap.BindPasswordVar) } diff --git a/zitadel/v2/idp_ldap/schema.go b/zitadel/v2/idp_ldap/schema.go new file mode 100644 index 00000000..0342fa18 --- /dev/null +++ b/zitadel/v2/idp_ldap/schema.go @@ -0,0 +1,273 @@ +package idp_ldap + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const ( + ServersVar = "servers" + StartTLSVar = "start_tls" + BaseDNVar = "base_dn" + BindDNVar = "bind_dn" + BindPasswordVar = "bind_password" + UserBaseVar = "user_base" + UserObjectClassesVar = "user_object_classes" + UserFiltersVar = "user_filters" + TimeoutVar = "timeout" + IdAttributeVar = "id_attribute" + + FirstNameAttributeVar = "first_name_attribute" + LastNameAttributeVar = "last_name_attribute" + DisplayNameAttributeVar = "display_name_attribute" + NickNameAttributeVar = "nick_name_attribute" + PreferredUsernameAttributeVar = "preferred_username_attribute" + EmailAttributeVar = "email_attribute" + EmailVerifiedAttributeVar = "email_verified_attribute" + PhoneAttributeVar = "phone_attribute" + PhoneVerifiedAttributeVar = "phone_verified_attribute" + PreferredLanguageAttributeVar = "preferred_language_attribute" + AvatarURLAttributeVar = "avatar_url_attribute" + ProfileAttributeVar = "profile_attribute" +) + +var ( + ServersResourceField = &schema.Schema{ + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "Servers to try in order for establishing LDAP connections", + } + ServersDataSourceField = &schema.Schema{ + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "Servers to try in order for establishing LDAP connections", + } + StartTLSResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "Wether to use StartTLS for LDAP connections", + } + StartTLSDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Wether to use StartTLS for LDAP connections", + } + BaseDNResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Base DN for LDAP connections", + } + BaseDNDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Base DN for LDAP connections", + } + BindDNResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Bind DN for LDAP connections", + } + BindDNDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Bind DN for LDAP connections", + } + BindPasswordResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + } + BindPasswordDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Bind password for LDAP connections", + Sensitive: true, + } + UserBaseResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "User base for LDAP connections", + } + UserBaseDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User base for LDAP connections", + } + UserObjectClassesResourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User object classes for LDAP connections", + } + UserObjectClassesDataSourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User object classes for LDAP connections", + } + UserFiltersResourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "User filters for LDAP connections", + } + UserFiltersDataSourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "User filters for LDAP connections", + } + TimeoutResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Timeout for LDAP connections", + } + TimeoutDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Timeout for LDAP connections", + } + IdAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the id", + } + IdAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the id", + } + + FirstNameAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the first name", + } + FirstNameAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the first name", + } + LastNameAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the last name", + } + LastNameAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the last name", + } + DisplayNameAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the display name", + } + DisplayNameAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the display name", + } + NickNameAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the nick name", + } + NickNameAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the nick name", + } + PreferredUsernameAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred username", + } + PreferredUsernameAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred username", + } + EmailAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email", + } + EmailAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email", + } + EmailVerifiedAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the email verified state", + } + EmailVerifiedAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the email verified state", + } + PhoneAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone", + } + PhoneAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone", + } + PhoneVerifiedAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the phone verified state", + } + PhoneVerifiedAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the phone verified state", + } + PreferredLanguageAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the preferred language", + } + PreferredLanguageAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the preferred language", + } + AvatarURLAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the avatar url", + } + AvatarURLAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the avatar url", + } + ProfileAttributeResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "User attribute for the profile", + } + ProfileAttributeDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "User attribute for the profile", + } +) diff --git a/zitadel/v2/idp_utils/const.go b/zitadel/v2/idp_utils/const.go deleted file mode 100644 index ed3ecbbc..00000000 --- a/zitadel/v2/idp_utils/const.go +++ /dev/null @@ -1,44 +0,0 @@ -package idp_utils - -const ( - IdpIDVar = "id" - NameVar = "name" - ClientIDVar = "client_id" - ClientSecretVar = "client_secret" - ScopesVar = "scopes" - IsLinkingAllowedVar = "is_linking_allowed" - IsCreationAllowedVar = "is_creation_allowed" - IsAutoCreationVar = "is_auto_creation" - IsAutoUpdateVar = "is_auto_update" - AuthorizationEndpointVar = "authorization_endpoint" - TokenEndpointVar = "token_endpoint" - UserEndpointVar = "user_endpoint" - IssuerVar = "issuer" - TenantTypeVar = "tenant_type" - TenantIDVar = "tenant_id" - EmailVerifiedVar = "email_verified" - // ServersVar is the first LDAP specific provider config property - ServersVar = "servers" - StartTLSVar = "start_tls" - BaseDNVar = "base_dn" - BindDNVar = "bind_dn" - BindPasswordVar = "bind_password" - UserBaseVar = "user_base" - UserObjectClassesVar = "user_object_classes" - UserFiltersVar = "user_filters" - TimeoutVar = "timeout" - IdAttributeVar = "id_attribute" - // FirstNameAttributeVar is the first LDAP specific user config property - FirstNameAttributeVar = "first_name_attribute" - LastNameAttributeVar = "last_name_attribute" - DisplayNameAttributeVar = "display_name_attribute" - NickNameAttributeVar = "nick_name_attribute" - PreferredUsernameAttributeVar = "preferred_username_attribute" - EmailAttributeVar = "email_attribute" - EmailVerifiedAttributeVar = "email_verified_attribute" - PhoneAttributeVar = "phone_attribute" - PhoneVerifiedAttributeVar = "phone_verified_attribute" - PreferredLanguageAttributeVar = "preferred_language_attribute" - AvatarURLAttributeVar = "avatar_url_attribute" - ProfileAttributeVar = "profile_attribute" -) diff --git a/zitadel/v2/idp_utils/schema.go b/zitadel/v2/idp_utils/schema.go new file mode 100644 index 00000000..4a4eed89 --- /dev/null +++ b/zitadel/v2/idp_utils/schema.go @@ -0,0 +1,111 @@ +package idp_utils + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const ( + IdpIDVar = "id" + NameVar = "name" + ClientIDVar = "client_id" + ClientSecretVar = "client_secret" + ScopesVar = "scopes" + IsLinkingAllowedVar = "is_linking_allowed" + IsCreationAllowedVar = "is_creation_allowed" + IsAutoCreationVar = "is_auto_creation" + IsAutoUpdateVar = "is_auto_update" +) + +var ( + IdPIDDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The ID of this resource.", + } + NameResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Name of the IDP", + } + NameDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Name of the IDP", + } + ClientIDResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "client id generated by the identity provider", + } + ClientIDDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "client id generated by the identity provider", + } + ClientSecretResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + } + ClientSecretDataSourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "client secret generated by the identity provider", + Sensitive: true, + } + ScopesResourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Required: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + } + ScopesDataSourceField = &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Computed: true, + Description: "the scopes requested by ZITADEL during the request on the identity provider", + } + IsLinkingAllowedResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to link an existing ZITADEL user with an external account", + } + IsLinkingAllowedDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "enabled if users are able to link an existing ZITADEL user with an external account", + } + IsCreationAllowedResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "enable if users should be able to create a new account in ZITADEL when using an external account", + } + IsCreationAllowedDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "enabled if users are able to create a new account in ZITADEL when using an external account", + } + IsAutoCreationResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "enable if a new account in ZITADEL should be created automatically on login with an external account", + } + IsAutoCreationDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "enabled if a new account in ZITADEL are created automatically on login with an external account", + } + IsAutoUpdateResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "enable if a the ZITADEL account fields should be updated automatically on each login", + } + IsAutoUpdateDataSourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "enabled if a the ZITADEL account fields are updated automatically on each login", + } +) diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index eb4fbb99..b40ad180 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -2,6 +2,7 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,75 +11,19 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an Azure AD IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.TenantTypeVar: { - Type: schema.TypeString, - Computed: true, - Description: "the azure ad tenant type", - }, - idp_utils.TenantIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "the azure ad tenant id", - }, - idp_utils.EmailVerifiedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "automatically mark emails as verified", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + idp_azure_ad.TenantTypeVar: idp_azure_ad.TenantTypeDataSourceField, + idp_azure_ad.TenantIDVar: idp_azure_ad.TenantIDDataSourceField, + idp_azure_ad.EmailVerifiedVar: idp_azure_ad.EmailVerifiedDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go index fa0eff68..62d4c6ea 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -27,18 +27,18 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddAzureADProvider(ctx, &management.AddAzureADProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - Tenant: idp_azure_ad.ConstructTenant(d), - EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -58,19 +58,19 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - Tenant: idp_azure_ad.ConstructTenant(d), - EmailVerified: d.Get(idp_utils.EmailVerifiedVar).(bool), + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -106,13 +106,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.EmailVerifiedVar: specificCfg.GetEmailVerified(), - idp_utils.TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], - idp_utils.TenantIDVar: specificCfg.GetTenant().GetTenantId(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_azure_ad.EmailVerifiedVar: specificCfg.GetEmailVerified(), + idp_azure_ad.TenantTypeVar: idp.AzureADTenantType_name[int32(specificCfg.GetTenant().GetTenantType())], + idp_azure_ad.TenantIDVar: specificCfg.GetTenant().GetTenantId(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index 8c524834..5defe974 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -1,7 +1,7 @@ package org_idp_azure_ad import ( - "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,72 +12,18 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an Azure AD IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.TenantTypeVar: { - Type: schema.TypeString, - Optional: true, - Default: "AZURE_AD_TENANT_TYPE_COMMON", - Description: "the azure ad tenant type", - }, - idp_utils.TenantIDVar: { - Type: schema.TypeString, - Optional: true, - Description: fmt.Sprintf("if %s is not set, the %s is used", idp_utils.TenantIDVar, idp_utils.TenantTypeVar), - }, - idp_utils.EmailVerifiedVar: { - Type: schema.TypeBool, - Required: true, - Description: "automatically mark emails as verified", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + idp_azure_ad.TenantTypeVar: idp_azure_ad.TenantTypeResourceField, + idp_azure_ad.TenantIDVar: idp_azure_ad.TenantIDResourceField, + idp_azure_ad.EmailVerifiedVar: idp_azure_ad.EmailVerifiedResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index dfa87e49..5a7de757 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -10,60 +10,16 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 77050290..4d31a42d 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -10,56 +10,15 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index 2d13f694..d7efac32 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -2,6 +2,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,75 +11,19 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitHub Enterprise IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.AuthorizationEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers authorization endpoint", - }, - idp_utils.TokenEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers token endpoint", - }, - idp_utils.UserEndpointVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers user endpoint", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + idp_github_es.AuthorizationEndpointVar: idp_github_es.AuthorizationEndpointDataSourceField, + idp_github_es.TokenEndpointVar: idp_github_es.TokenEndpointDataSourceField, + idp_github_es.UserEndpointVar: idp_github_es.UserEndpointDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/v2/org_idp_github_es/funcs.go index 3a2629c7..303b2636 100644 --- a/zitadel/v2/org_idp_github_es/funcs.go +++ b/zitadel/v2/org_idp_github_es/funcs.go @@ -3,6 +3,8 @@ package org_idp_github_es import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -25,19 +27,19 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &management.AddGitHubEnterpriseServerProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -57,20 +59,20 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &management.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - AuthorizationEndpoint: d.Get(idp_utils.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_utils.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_utils.UserEndpointVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -101,18 +103,18 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithubEs() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), - idp_utils.NameVar: idp.GetName(), - idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), - idp_utils.AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), - idp_utils.TokenEndpointVar: specificCfg.GetTokenEndpoint(), - idp_utils.UserEndpointVar: specificCfg.GetUserEndpoint(), - idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_github_es.AuthorizationEndpointVar: specificCfg.GetAuthorizationEndpoint(), + idp_github_es.TokenEndpointVar: specificCfg.GetTokenEndpoint(), + idp_github_es.UserEndpointVar: specificCfg.GetUserEndpoint(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index f2ac63c3..97ca3cf8 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -2,6 +2,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,71 +11,18 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub Enterprise IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.AuthorizationEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers authorization endpoint", - }, - idp_utils.TokenEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers token endpoint", - }, - idp_utils.UserEndpointVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers user endpoint", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + idp_github_es.AuthorizationEndpointVar: idp_github_es.AuthorizationEndpointResourceField, + idp_github_es.TokenEndpointVar: idp_github_es.TokenEndpointResourceField, + idp_github_es.UserEndpointVar: idp_github_es.UserEndpointResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index 495a3264..0b74f7fa 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -10,60 +10,16 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitLab IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index 5d54ac0e..ca81b877 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -10,56 +10,15 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index 8762ba09..22f8bcaf 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -2,6 +2,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,65 +11,17 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a GitLab Self Hosted IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IssuerVar: { - Type: schema.TypeString, - Computed: true, - Description: "the providers issuer", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + idp_gitlab_self_hosted.IssuerVar: idp_gitlab_self_hosted.IssuerDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go index 628666be..635f7322 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go @@ -3,6 +3,8 @@ package org_idp_gitlab_self_hosted import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -28,7 +30,6 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Name: d.Get(idp_utils.NameVar).(string), ClientId: d.Get(idp_utils.ClientIDVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Issuer: d.Get(idp_utils.IssuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), @@ -36,6 +37,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -59,7 +61,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Name: d.Get(idp_utils.NameVar).(string), ClientId: d.Get(idp_utils.ClientIDVar).(string), ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Issuer: d.Get(idp_utils.IssuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), @@ -67,6 +68,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -97,16 +99,16 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGitlabSelfHosted() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), - idp_utils.NameVar: idp.GetName(), - idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), - idp_utils.IssuerVar: specificCfg.GetIssuer(), - idp_utils.ScopesVar: specificCfg.GetScopes(), - idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + idp_gitlab_self_hosted.IssuerVar: specificCfg.GetIssuer(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index 8f0588f9..e5935907 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -2,6 +2,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,61 +11,16 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab Self Hosted IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IssuerVar: { - Type: schema.TypeString, - Required: true, - Description: "the providers issuer", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + idp_gitlab_self_hosted.IssuerVar: idp_gitlab_self_hosted.IssuerResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index 7277b608..6bdfdc80 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -10,60 +10,16 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a Google IdP of the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 379c87c3..989cc632 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -10,56 +10,15 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a Google IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ClientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - }, - idp_utils.ClientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - idp_utils.ScopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, }, ReadContext: read, UpdateContext: update, diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go index ac745c6a..02c2cd15 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -2,6 +2,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,161 +11,37 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an LDAP IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - idp_utils.IdpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - idp_utils.ServersVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "Servers to try in order for establishing LDAP connections", - }, - idp_utils.StartTLSVar: { - Type: schema.TypeBool, - Computed: true, - Description: "Wether to use StartTLS for LDAP connections", - }, - idp_utils.BaseDNVar: { - Type: schema.TypeString, - Computed: true, - Description: "Base DN for LDAP connections", - }, - idp_utils.BindDNVar: { - Type: schema.TypeString, - Computed: true, - Description: "Bind DN for LDAP connections", - }, - idp_utils.BindPasswordVar: { - Type: schema.TypeString, - Computed: true, - Description: "Bind password for LDAP connections", - Sensitive: true, - }, - idp_utils.UserBaseVar: { - Type: schema.TypeString, - Computed: true, - Description: "User base for LDAP connections", - }, - idp_utils.UserObjectClassesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "User object classes for LDAP connections", - }, - idp_utils.UserFiltersVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "User filters for LDAP connections", - }, - idp_utils.TimeoutVar: { - Type: schema.TypeString, - Computed: true, - Description: "Timeout for LDAP connections", - }, - idp_utils.IdAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the id", - }, - idp_utils.FirstNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the first name", - }, - idp_utils.LastNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the last name", - }, - idp_utils.DisplayNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the display name", - }, - idp_utils.NickNameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the nick name", - }, - idp_utils.PreferredUsernameAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the preferred username", - }, - idp_utils.EmailAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the email", - }, - idp_utils.EmailVerifiedAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the email verified state", - }, - idp_utils.PhoneAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the phone", - }, - idp_utils.PhoneVerifiedAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the phone verified state", - }, - idp_utils.PreferredLanguageAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the preferred language", - }, - idp_utils.AvatarURLAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the avatar url", - }, - idp_utils.ProfileAttributeVar: { - Type: schema.TypeString, - Computed: true, - Description: "User attribute for the profile", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Computed: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + + idp_ldap.ServersVar: idp_ldap.ServersDataSourceField, + idp_ldap.StartTLSVar: idp_ldap.StartTLSDataSourceField, + idp_ldap.BaseDNVar: idp_ldap.BaseDNDataSourceField, + idp_ldap.BindDNVar: idp_ldap.BindDNDataSourceField, + idp_ldap.BindPasswordVar: idp_ldap.BindPasswordDataSourceField, + idp_ldap.UserBaseVar: idp_ldap.UserBaseDataSourceField, + idp_ldap.UserObjectClassesVar: idp_ldap.UserObjectClassesDataSourceField, + idp_ldap.UserFiltersVar: idp_ldap.UserFiltersDataSourceField, + idp_ldap.TimeoutVar: idp_ldap.TimeoutDataSourceField, + idp_ldap.IdAttributeVar: idp_ldap.IdAttributeDataSourceField, + + idp_ldap.FirstNameAttributeVar: idp_ldap.FirstNameAttributeDataSourceField, + idp_ldap.LastNameAttributeVar: idp_ldap.LastNameAttributeDataSourceField, + idp_ldap.DisplayNameAttributeVar: idp_ldap.DisplayNameAttributeDataSourceField, + idp_ldap.NickNameAttributeVar: idp_ldap.NickNameAttributeDataSourceField, + idp_ldap.PreferredUsernameAttributeVar: idp_ldap.PreferredUsernameAttributeDataSourceField, + idp_ldap.EmailAttributeVar: idp_ldap.EmailAttributeDataSourceField, + idp_ldap.EmailVerifiedAttributeVar: idp_ldap.EmailVerifiedAttributeDataSourceField, + idp_ldap.PhoneAttributeVar: idp_ldap.PhoneAttributeDataSourceField, + idp_ldap.PhoneVerifiedAttributeVar: idp_ldap.PhoneVerifiedAttributeDataSourceField, + idp_ldap.PreferredLanguageAttributeVar: idp_ldap.PreferredLanguageAttributeDataSourceField, + idp_ldap.AvatarURLAttributeVar: idp_ldap.AvatarURLAttributeDataSourceField, + idp_ldap.ProfileAttributeVar: idp_ldap.ProfileAttributeDataSourceField, }, ReadContext: read, Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/v2/org_idp_ldap/funcs.go index d21134d2..d8213b70 100644 --- a/zitadel/v2/org_idp_ldap/funcs.go +++ b/zitadel/v2/org_idp_ldap/funcs.go @@ -4,6 +4,8 @@ import ( "context" "time" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" + "google.golang.org/protobuf/types/known/durationpb" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -27,42 +29,44 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + timeout, err := time.ParseDuration(d.Get(idp_ldap.TimeoutVar).(string)) if err != nil { return diag.FromErr(err) } resp, err := client.AddLDAPProvider(ctx, &management.AddLDAPProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), - StartTls: d.Get(idp_utils.StartTLSVar).(bool), - BaseDn: d.Get(idp_utils.BaseDNVar).(string), - BindDn: d.Get(idp_utils.BindDNVar).(string), - BindPassword: d.Get(idp_utils.BindPasswordVar).(string), - UserBase: d.Get(idp_utils.UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), - Timeout: durationpb.New(timeout), - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), - }, + Name: d.Get(idp_utils.NameVar).(string), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), }, + + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), + StartTls: d.Get(idp_ldap.StartTLSVar).(bool), + BaseDn: d.Get(idp_ldap.BaseDNVar).(string), + BindDn: d.Get(idp_ldap.BindDNVar).(string), + BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), + UserBase: d.Get(idp_ldap.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), + Timeout: durationpb.New(timeout), + + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), + }, }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -80,44 +84,46 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(idp_utils.TimeoutVar).(string)) + timeout, err := time.ParseDuration(d.Get(idp_ldap.TimeoutVar).(string)) if err != nil { return diag.FromErr(err) } if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { _, err = client.UpdateLDAPProvider(ctx, &management.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_utils.ServersVar)), - StartTls: d.Get(idp_utils.StartTLSVar).(bool), - BaseDn: d.Get(idp_utils.BaseDNVar).(string), - BindDn: d.Get(idp_utils.BindDNVar).(string), - BindPassword: d.Get(idp_utils.BindPasswordVar).(string), - UserBase: d.Get(idp_utils.UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_utils.UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, idp_utils.UserFiltersVar), - Timeout: durationpb.New(timeout), - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_utils.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_utils.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_utils.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_utils.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_utils.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_utils.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_utils.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_utils.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_utils.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_utils.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_utils.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_utils.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_utils.ProfileAttributeVar).(string), - }, + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), ProviderOptions: &idp.Options{ IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), }, + + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), + StartTls: d.Get(idp_ldap.StartTLSVar).(bool), + BaseDn: d.Get(idp_ldap.BaseDNVar).(string), + BindDn: d.Get(idp_ldap.BindDNVar).(string), + BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), + UserBase: d.Get(idp_ldap.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), + Timeout: durationpb.New(timeout), + + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), + }, }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -149,34 +155,36 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn attributesCfg := specificCfg.GetAttributes() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), - idp_utils.NameVar: idp.GetName(), - idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), - idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), - idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), - idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), - idp_utils.ServersVar: specificCfg.GetServers(), - idp_utils.StartTLSVar: specificCfg.GetStartTls(), - idp_utils.BaseDNVar: specificCfg.GetBaseDn(), - idp_utils.BindDNVar: specificCfg.GetBindDn(), - idp_utils.BindPasswordVar: d.Get(idp_utils.BindPasswordVar).(string), - idp_utils.UserBaseVar: specificCfg.GetUserBase(), - idp_utils.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), - idp_utils.UserFiltersVar: specificCfg.GetUserFilters(), - idp_utils.TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), - idp_utils.IdAttributeVar: attributesCfg.GetIdAttribute(), - idp_utils.FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), - idp_utils.LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), - idp_utils.DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), - idp_utils.NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), - idp_utils.PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), - idp_utils.EmailAttributeVar: attributesCfg.GetEmailAttribute(), - idp_utils.EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), - idp_utils.PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), - idp_utils.PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), - idp_utils.PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), - idp_utils.AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), - idp_utils.ProfileAttributeVar: attributesCfg.GetProfileAttribute(), + org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + + idp_ldap.ServersVar: specificCfg.GetServers(), + idp_ldap.StartTLSVar: specificCfg.GetStartTls(), + idp_ldap.BaseDNVar: specificCfg.GetBaseDn(), + idp_ldap.BindDNVar: specificCfg.GetBindDn(), + idp_ldap.BindPasswordVar: d.Get(idp_ldap.BindPasswordVar).(string), + idp_ldap.UserBaseVar: specificCfg.GetUserBase(), + idp_ldap.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), + idp_ldap.UserFiltersVar: specificCfg.GetUserFilters(), + idp_ldap.TimeoutVar: specificCfg.GetTimeout().AsDuration().String(), + idp_ldap.IdAttributeVar: attributesCfg.GetIdAttribute(), + + idp_ldap.FirstNameAttributeVar: attributesCfg.GetFirstNameAttribute(), + idp_ldap.LastNameAttributeVar: attributesCfg.GetLastNameAttribute(), + idp_ldap.DisplayNameAttributeVar: attributesCfg.GetDisplayNameAttribute(), + idp_ldap.NickNameAttributeVar: attributesCfg.GetNickNameAttribute(), + idp_ldap.PreferredUsernameAttributeVar: attributesCfg.GetPreferredUsernameAttribute(), + idp_ldap.EmailAttributeVar: attributesCfg.GetEmailAttribute(), + idp_ldap.EmailVerifiedAttributeVar: attributesCfg.GetEmailVerifiedAttribute(), + idp_ldap.PhoneAttributeVar: attributesCfg.GetPhoneAttribute(), + idp_ldap.PhoneVerifiedAttributeVar: attributesCfg.GetPhoneVerifiedAttribute(), + idp_ldap.PreferredLanguageAttributeVar: attributesCfg.GetPreferredLanguageAttribute(), + idp_ldap.AvatarURLAttributeVar: attributesCfg.GetAvatarUrlAttribute(), + idp_ldap.ProfileAttributeVar: attributesCfg.GetProfileAttribute(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/v2/org_idp_ldap/resource.go index ed560be3..22ee99f6 100644 --- a/zitadel/v2/org_idp_ldap/resource.go +++ b/zitadel/v2/org_idp_ldap/resource.go @@ -2,6 +2,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -10,162 +11,41 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an LDAP IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - idp_utils.NameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - idp_utils.ServersVar: { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "Servers to try in order for establishing LDAP connections", - }, - idp_utils.StartTLSVar: { - Type: schema.TypeBool, - Required: true, - Description: "Wether to use StartTLS for LDAP connections", - }, - idp_utils.BaseDNVar: { - Type: schema.TypeString, - Required: true, - Description: "Base DN for LDAP connections", - }, - idp_utils.BindDNVar: { - Type: schema.TypeString, - Required: true, - Description: "Bind DN for LDAP connections", - }, - idp_utils.BindPasswordVar: { - Type: schema.TypeString, - Required: true, - Description: "Bind password for LDAP connections", - Sensitive: true, - }, - idp_utils.UserBaseVar: { - Type: schema.TypeString, - Required: true, - Description: "User base for LDAP connections", - }, - idp_utils.UserObjectClassesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "User object classes for LDAP connections", - }, - idp_utils.UserFiltersVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "User filters for LDAP connections", - }, - idp_utils.TimeoutVar: { - Type: schema.TypeString, - Required: true, - Description: "Timeout for LDAP connections", - }, - idp_utils.IdAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the id", - }, - idp_utils.FirstNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the first name", - }, - idp_utils.LastNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the last name", - }, - idp_utils.DisplayNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the display name", - }, - idp_utils.NickNameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the nick name", - }, - idp_utils.PreferredUsernameAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the preferred username", - }, - idp_utils.EmailAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the email", - }, - idp_utils.EmailVerifiedAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the email verified state", - }, - idp_utils.PhoneAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the phone", - }, - idp_utils.PhoneVerifiedAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the phone verified state", - }, - idp_utils.PreferredLanguageAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the preferred language", - }, - idp_utils.AvatarURLAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the avatar url", - }, - idp_utils.ProfileAttributeVar: { - Type: schema.TypeString, - Optional: true, - Description: "User attribute for the profile", - }, - idp_utils.IsLinkingAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to link an existing ZITADEL user with an external account", - }, - idp_utils.IsCreationAllowedVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if users should be able to create a new account in ZITADEL when using an external account", - }, - idp_utils.IsAutoCreationVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a new account in ZITADEL should be created automatically when login with an external account", - }, - idp_utils.IsAutoUpdateVar: { - Type: schema.TypeBool, - Required: true, - Description: "enable if a the ZITADEL account fields should be updated automatically on each login", - }, + org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + + idp_ldap.ServersVar: idp_ldap.ServersResourceField, + idp_ldap.StartTLSVar: idp_ldap.StartTLSResourceField, + idp_ldap.BaseDNVar: idp_ldap.BaseDNResourceField, + idp_ldap.BindDNVar: idp_ldap.BindDNResourceField, + idp_ldap.BindPasswordVar: idp_ldap.BindPasswordResourceField, + idp_ldap.UserBaseVar: idp_ldap.UserBaseResourceField, + idp_ldap.UserObjectClassesVar: idp_ldap.UserObjectClassesResourceField, + idp_ldap.UserFiltersVar: idp_ldap.UserFiltersResourceField, + idp_ldap.TimeoutVar: idp_ldap.TimeoutResourceField, + idp_ldap.IdAttributeVar: idp_ldap.IdAttributeResourceField, + + idp_ldap.FirstNameAttributeVar: idp_ldap.FirstNameAttributeResourceField, + idp_ldap.LastNameAttributeVar: idp_ldap.LastNameAttributeResourceField, + idp_ldap.DisplayNameAttributeVar: idp_ldap.DisplayNameAttributeResourceField, + idp_ldap.NickNameAttributeVar: idp_ldap.NickNameAttributeResourceField, + idp_ldap.PreferredUsernameAttributeVar: idp_ldap.PreferredUsernameAttributeResourceField, + idp_ldap.EmailAttributeVar: idp_ldap.EmailAttributeResourceField, + idp_ldap.EmailVerifiedAttributeVar: idp_ldap.EmailVerifiedAttributeResourceField, + idp_ldap.PhoneAttributeVar: idp_ldap.PhoneAttributeResourceField, + idp_ldap.PhoneVerifiedAttributeVar: idp_ldap.PhoneVerifiedAttributeResourceField, + idp_ldap.PreferredLanguageAttributeVar: idp_ldap.PreferredLanguageAttributeResourceField, + idp_ldap.AvatarURLAttributeVar: idp_ldap.AvatarURLAttributeResourceField, + idp_ldap.ProfileAttributeVar: idp_ldap.ProfileAttributeResourceField, }, ReadContext: read, UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.BindPasswordVar)}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_ldap.BindPasswordVar)}, } } diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index e82ab490..5e2f8a5d 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" test_utils_org "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/test_utils" ) @@ -37,5 +37,5 @@ resource "%s" "%s" { is_auto_creation = false is_auto_update = true }`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.BindPasswordVar) + }, idp_ldap.BindPasswordVar) } diff --git a/zitadel/v2/org_idp_utils/const.go b/zitadel/v2/org_idp_utils/const.go deleted file mode 100644 index c3a14d49..00000000 --- a/zitadel/v2/org_idp_utils/const.go +++ /dev/null @@ -1,5 +0,0 @@ -package org_idp_utils - -const ( - OrgIDVar = "org_id" -) diff --git a/zitadel/v2/org_idp_utils/resource.go b/zitadel/v2/org_idp_utils/resource.go new file mode 100644 index 00000000..aee87d06 --- /dev/null +++ b/zitadel/v2/org_idp_utils/resource.go @@ -0,0 +1 @@ +package org_idp_utils diff --git a/zitadel/v2/org_idp_utils/schema.go b/zitadel/v2/org_idp_utils/schema.go new file mode 100644 index 00000000..8623fd7f --- /dev/null +++ b/zitadel/v2/org_idp_utils/schema.go @@ -0,0 +1,21 @@ +package org_idp_utils + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const ( + OrgIDVar = "org_id" +) + +var ( + OrgIDResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + ForceNew: true, + } + OrgIDDatasourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "ID of the organization", + } +) From 5c51773dccf0a93230a4d1ba2b8eb78b9b2820ff Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 07:05:36 +0200 Subject: [PATCH 120/260] remove useless has changes checks --- zitadel/v2/idp_azure_ad/funcs.go | 36 ++++----- zitadel/v2/idp_github/funcs.go | 32 ++++---- zitadel/v2/idp_github_es/funcs.go | 38 +++++---- zitadel/v2/idp_gitlab/funcs.go | 32 ++++---- zitadel/v2/idp_gitlab_self_hosted/funcs.go | 34 ++++---- zitadel/v2/idp_google/funcs.go | 32 ++++---- zitadel/v2/idp_ldap/funcs.go | 74 +++++++++--------- zitadel/v2/org_idp_azure_ad/funcs.go | 36 ++++----- zitadel/v2/org_idp_github/funcs.go | 32 ++++---- zitadel/v2/org_idp_github_es/funcs.go | 38 +++++---- zitadel/v2/org_idp_gitlab/funcs.go | 32 ++++---- .../v2/org_idp_gitlab_self_hosted/funcs.go | 34 ++++---- zitadel/v2/org_idp_google/funcs.go | 32 ++++---- zitadel/v2/org_idp_ldap/funcs.go | 78 +++++++++---------- 14 files changed, 266 insertions(+), 294 deletions(-) diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go index e8ecb3c2..f47c1a11 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -51,25 +51,23 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Tenant: ConstructTenant(d), - EmailVerified: d.Get(EmailVerifiedVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + Tenant: ConstructTenant(d), + EmailVerified: d.Get(EmailVerifiedVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_github/funcs.go b/zitadel/v2/idp_github/funcs.go index 958e93b9..06c15285 100644 --- a/zitadel/v2/idp_github/funcs.go +++ b/zitadel/v2/idp_github/funcs.go @@ -49,23 +49,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateGitHubProvider(ctx, &admin.UpdateGitHubProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitHubProvider(ctx, &admin.UpdateGitHubProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_github_es/funcs.go b/zitadel/v2/idp_github_es/funcs.go index ce2de08d..caa18c04 100644 --- a/zitadel/v2/idp_github_es/funcs.go +++ b/zitadel/v2/idp_github_es/funcs.go @@ -52,26 +52,24 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &admin.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(TokenEndpointVar).(string), - UserEndpoint: d.Get(UserEndpointVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &admin.UpdateGitHubEnterpriseServerProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(TokenEndpointVar).(string), + UserEndpoint: d.Get(UserEndpointVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_gitlab/funcs.go b/zitadel/v2/idp_gitlab/funcs.go index ee3ce76e..f402de04 100644 --- a/zitadel/v2/idp_gitlab/funcs.go +++ b/zitadel/v2/idp_gitlab/funcs.go @@ -49,23 +49,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateGitLabProvider(ctx, &admin.UpdateGitLabProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitLabProvider(ctx, &admin.UpdateGitLabProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_gitlab_self_hosted/funcs.go b/zitadel/v2/idp_gitlab_self_hosted/funcs.go index 30b9e1b9..00391dfd 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/idp_gitlab_self_hosted/funcs.go @@ -50,24 +50,22 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateGitLabSelfHostedProvider(ctx, &admin.UpdateGitLabSelfHostedProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Issuer: d.Get(IssuerVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitLabSelfHostedProvider(ctx, &admin.UpdateGitLabSelfHostedProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + Issuer: d.Get(IssuerVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_google/funcs.go b/zitadel/v2/idp_google/funcs.go index 7f680f8a..0366d4cf 100644 --- a/zitadel/v2/idp_google/funcs.go +++ b/zitadel/v2/idp_google/funcs.go @@ -49,23 +49,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateGoogleProvider(ctx, &admin.UpdateGoogleProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGoogleProvider(ctx, &admin.UpdateGoogleProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/v2/idp_ldap/funcs.go index 932590d3..d5eb628b 100644 --- a/zitadel/v2/idp_ldap/funcs.go +++ b/zitadel/v2/idp_ldap/funcs.go @@ -84,46 +84,44 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar) { - _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, - Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), - StartTls: d.Get(StartTLSVar).(bool), - BaseDn: d.Get(BaseDNVar).(string), - BindDn: d.Get(BindDNVar).(string), - BindPassword: d.Get(BindPasswordVar).(string), - UserBase: d.Get(UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), - Timeout: durationpb.New(timeout), + Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), + StartTls: d.Get(StartTLSVar).(bool), + BaseDn: d.Get(BaseDNVar).(string), + BindDn: d.Get(BindDNVar).(string), + BindPassword: d.Get(BindPasswordVar).(string), + UserBase: d.Get(UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), + Timeout: durationpb.New(timeout), - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(IdAttributeVar).(string), - FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(ProfileAttributeVar).(string), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(IdAttributeVar).(string), + FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(ProfileAttributeVar).(string), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go index 62d4c6ea..a969c0db 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -56,25 +56,23 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Tenant: idp_azure_ad.ConstructTenant(d), - EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index e98ec6aa..e75b3db3 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -52,23 +52,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/v2/org_idp_github_es/funcs.go index 303b2636..005e7f38 100644 --- a/zitadel/v2/org_idp_github_es/funcs.go +++ b/zitadel/v2/org_idp_github_es/funcs.go @@ -57,26 +57,24 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &management.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &management.UpdateGitHubEnterpriseServerProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), + TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), + UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_gitlab/funcs.go b/zitadel/v2/org_idp_gitlab/funcs.go index ce54737a..94cd7c66 100644 --- a/zitadel/v2/org_idp_gitlab/funcs.go +++ b/zitadel/v2/org_idp_gitlab/funcs.go @@ -52,23 +52,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateGitLabProvider(ctx, &management.UpdateGitLabProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitLabProvider(ctx, &management.UpdateGitLabProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go index 635f7322..d6c246c6 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go @@ -55,24 +55,22 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateGitLabSelfHostedProvider(ctx, &management.UpdateGitLabSelfHostedProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGitLabSelfHostedProvider(ctx, &management.UpdateGitLabSelfHostedProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_google/funcs.go b/zitadel/v2/org_idp_google/funcs.go index 8fe8d86f..c2207812 100644 --- a/zitadel/v2/org_idp_google/funcs.go +++ b/zitadel/v2/org_idp_google/funcs.go @@ -52,23 +52,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateGoogleProvider(ctx, &management.UpdateGoogleProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateGoogleProvider(ctx, &management.UpdateGoogleProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ClientId: d.Get(idp_utils.ClientIDVar).(string), + ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), + Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/v2/org_idp_ldap/funcs.go index d8213b70..268ec278 100644 --- a/zitadel/v2/org_idp_ldap/funcs.go +++ b/zitadel/v2/org_idp_ldap/funcs.go @@ -88,46 +88,44 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChangesExcept(idp_utils.IdpIDVar, org_idp_utils.OrgIDVar) { - _, err = client.UpdateLDAPProvider(ctx, &management.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - - Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), - StartTls: d.Get(idp_ldap.StartTLSVar).(bool), - BaseDn: d.Get(idp_ldap.BaseDNVar).(string), - BindDn: d.Get(idp_ldap.BindDNVar).(string), - BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), - UserBase: d.Get(idp_ldap.UserBaseVar).(string), - UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), - UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), - Timeout: durationpb.New(timeout), - - Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), - }, - }) - if err != nil { - return diag.Errorf("failed to update idp: %v", err) - } + _, err = client.UpdateLDAPProvider(ctx, &management.UpdateLDAPProviderRequest{ + Id: d.Id(), + Name: d.Get(idp_utils.NameVar).(string), + ProviderOptions: &idp.Options{ + IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), + IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), + IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), + IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), + }, + + Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), + StartTls: d.Get(idp_ldap.StartTLSVar).(bool), + BaseDn: d.Get(idp_ldap.BaseDNVar).(string), + BindDn: d.Get(idp_ldap.BindDNVar).(string), + BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), + UserBase: d.Get(idp_ldap.UserBaseVar).(string), + UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), + UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), + Timeout: durationpb.New(timeout), + + Attributes: &idp.LDAPAttributes{ + IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), + FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), + LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), + DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), + NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), + PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), + EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), + EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), + PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), + PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), + PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), + AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), + ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), + }, + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } From 394e7ca98e33569f53d3ad88660e124d8525b15f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 07:15:40 +0200 Subject: [PATCH 121/260] make name and scopes optional --- zitadel/v2/idp_utils/schema.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/idp_utils/schema.go b/zitadel/v2/idp_utils/schema.go index 4a4eed89..9be0294b 100644 --- a/zitadel/v2/idp_utils/schema.go +++ b/zitadel/v2/idp_utils/schema.go @@ -22,7 +22,7 @@ var ( } NameResourceField = &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, Description: "Name of the IDP", } NameDataSourceField = &schema.Schema{ @@ -57,7 +57,7 @@ var ( Elem: &schema.Schema{ Type: schema.TypeString, }, - Required: true, + Optional: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", } ScopesDataSourceField = &schema.Schema{ From 2a9d677a9a95bc393870587fc9c811c8e299ba47 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 07:56:52 +0200 Subject: [PATCH 122/260] reduce state parsing mental overhead --- zitadel/v2/idp_azure_ad/funcs.go | 46 +++---- zitadel/v2/idp_github/funcs.go | 35 ++---- zitadel/v2/idp_github_es/funcs.go | 47 +++----- zitadel/v2/idp_gitlab/funcs.go | 35 ++---- zitadel/v2/idp_gitlab_self_hosted/funcs.go | 39 +++--- zitadel/v2/idp_google/funcs.go | 35 ++---- zitadel/v2/idp_ldap/funcs.go | 101 +++++++--------- zitadel/v2/idp_utils/funcs.go | 25 +++- zitadel/v2/org_idp_azure_ad/funcs.go | 57 ++++----- zitadel/v2/org_idp_github/funcs.go | 47 +++----- zitadel/v2/org_idp_github_es/funcs.go | 62 ++++------ zitadel/v2/org_idp_gitlab/funcs.go | 47 +++----- .../v2/org_idp_gitlab_self_hosted/funcs.go | 54 ++++----- zitadel/v2/org_idp_google/funcs.go | 47 +++----- zitadel/v2/org_idp_ldap/funcs.go | 112 ++++++++---------- 15 files changed, 321 insertions(+), 468 deletions(-) diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go index f47c1a11..5e94073a 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -22,18 +22,13 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddAzureADProvider(ctx, &admin.AddAzureADProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - Tenant: ConstructTenant(d), - EmailVerified: d.Get(EmailVerifiedVar).(bool), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Tenant: ConstructTenant(d), + EmailVerified: idp_utils.BoolValue(d, EmailVerifiedVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -52,19 +47,14 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Tenant: ConstructTenant(d), - EmailVerified: d.Get(EmailVerifiedVar).(bool), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Tenant: ConstructTenant(d), + EmailVerified: idp_utils.BoolValue(d, EmailVerifiedVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -96,7 +86,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: respIdp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), @@ -117,14 +107,14 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn func ConstructTenant(d *schema.ResourceData) *idp.AzureADTenant { tenant := &idp.AzureADTenant{} - tenantId := d.Get(TenantIDVar).(string) + tenantId := idp_utils.StringValue(d, TenantIDVar) if tenantId != "" { tenant.Type = &idp.AzureADTenant_TenantId{ TenantId: tenantId, } } else { tenant.Type = &idp.AzureADTenant_TenantType{ - TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[d.Get(TenantTypeVar).(string)]), + TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[idp_utils.StringValue(d, TenantTypeVar)]), } } return tenant diff --git a/zitadel/v2/idp_github/funcs.go b/zitadel/v2/idp_github/funcs.go index 06c15285..96330b6e 100644 --- a/zitadel/v2/idp_github/funcs.go +++ b/zitadel/v2/idp_github/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -22,16 +21,11 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitHubProvider(ctx, &admin.AddGitHubProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -50,17 +44,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateGitHubProvider(ctx, &admin.UpdateGitHubProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -92,7 +81,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/idp_github_es/funcs.go b/zitadel/v2/idp_github_es/funcs.go index caa18c04..101d17a3 100644 --- a/zitadel/v2/idp_github_es/funcs.go +++ b/zitadel/v2/idp_github_es/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -22,19 +21,14 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &admin.AddGitHubEnterpriseServerProviderRequest{ - ClientId: d.Get(idp_utils.ClientIDVar).(string), - Name: d.Get(idp_utils.NameVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(TokenEndpointVar).(string), - UserEndpoint: d.Get(UserEndpointVar).(string), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + AuthorizationEndpoint: idp_utils.StringValue(d, AuthorizationEndpointVar), + TokenEndpoint: idp_utils.StringValue(d, TokenEndpointVar), + UserEndpoint: idp_utils.StringValue(d, UserEndpointVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -53,20 +47,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &admin.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - AuthorizationEndpoint: d.Get(AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(TokenEndpointVar).(string), - UserEndpoint: d.Get(UserEndpointVar).(string), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + AuthorizationEndpoint: idp_utils.StringValue(d, AuthorizationEndpointVar), + TokenEndpoint: idp_utils.StringValue(d, TokenEndpointVar), + UserEndpoint: idp_utils.StringValue(d, UserEndpointVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -98,7 +87,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/idp_gitlab/funcs.go b/zitadel/v2/idp_gitlab/funcs.go index f402de04..4a9ad427 100644 --- a/zitadel/v2/idp_gitlab/funcs.go +++ b/zitadel/v2/idp_gitlab/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -22,16 +21,11 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitLabProvider(ctx, &admin.AddGitLabProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -50,17 +44,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateGitLabProvider(ctx, &admin.UpdateGitLabProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -92,7 +81,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/idp_gitlab_self_hosted/funcs.go b/zitadel/v2/idp_gitlab_self_hosted/funcs.go index 00391dfd..5163c1e0 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/idp_gitlab_self_hosted/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -22,17 +21,12 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGitLabSelfHostedProvider(ctx, &admin.AddGitLabSelfHostedProviderRequest{ - ClientId: d.Get(idp_utils.ClientIDVar).(string), - Name: d.Get(idp_utils.NameVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - Issuer: d.Get(IssuerVar).(string), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Issuer: idp_utils.StringValue(d, IssuerVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -51,18 +45,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateGitLabSelfHostedProvider(ctx, &admin.UpdateGitLabSelfHostedProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Issuer: d.Get(IssuerVar).(string), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Issuer: idp_utils.StringValue(d, IssuerVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -94,7 +83,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/idp_google/funcs.go b/zitadel/v2/idp_google/funcs.go index 0366d4cf..81081575 100644 --- a/zitadel/v2/idp_google/funcs.go +++ b/zitadel/v2/idp_google/funcs.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -22,16 +21,11 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddGoogleProvider(ctx, &admin.AddGoogleProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -50,17 +44,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateGoogleProvider(ctx, &admin.UpdateGoogleProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -92,7 +81,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/v2/idp_ldap/funcs.go index d5eb628b..7fdcac79 100644 --- a/zitadel/v2/idp_ldap/funcs.go +++ b/zitadel/v2/idp_ldap/funcs.go @@ -4,12 +4,11 @@ import ( "context" "time" - "google.golang.org/protobuf/types/known/durationpb" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "google.golang.org/protobuf/types/known/durationpb" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -24,43 +23,38 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(TimeoutVar).(string)) + timeout, err := time.ParseDuration(idp_utils.StringValue(d, TimeoutVar)) if err != nil { return diag.FromErr(err) } req := &admin.AddLDAPProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ProviderOptions: idp_utils.ProviderOptionsValue(d), Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), - StartTls: d.Get(StartTLSVar).(bool), - BaseDn: d.Get(BaseDNVar).(string), - BindDn: d.Get(BindDNVar).(string), - BindPassword: d.Get(BindPasswordVar).(string), - UserBase: d.Get(UserBaseVar).(string), + StartTls: idp_utils.BoolValue(d, StartTLSVar), + BaseDn: idp_utils.StringValue(d, BaseDNVar), + BindDn: idp_utils.StringValue(d, BindDNVar), + BindPassword: idp_utils.StringValue(d, BindPasswordVar), + UserBase: idp_utils.StringValue(d, UserBaseVar), UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), Timeout: durationpb.New(timeout), Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(IdAttributeVar).(string), - FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(ProfileAttributeVar).(string), + IdAttribute: idp_utils.StringValue(d, IdAttributeVar), + FirstNameAttribute: idp_utils.StringValue(d, FirstNameAttributeVar), + LastNameAttribute: idp_utils.StringValue(d, LastNameAttributeVar), + DisplayNameAttribute: idp_utils.StringValue(d, DisplayNameAttributeVar), + NickNameAttribute: idp_utils.StringValue(d, NickNameAttributeVar), + PreferredUsernameAttribute: idp_utils.StringValue(d, PreferredUsernameAttributeVar), + EmailAttribute: idp_utils.StringValue(d, EmailAttributeVar), + EmailVerifiedAttribute: idp_utils.StringValue(d, EmailVerifiedAttributeVar), + PhoneAttribute: idp_utils.StringValue(d, PhoneAttributeVar), + PhoneVerifiedAttribute: idp_utils.StringValue(d, PhoneVerifiedAttributeVar), + PreferredLanguageAttribute: idp_utils.StringValue(d, PreferredLanguageAttributeVar), + AvatarUrlAttribute: idp_utils.StringValue(d, AvatarURLAttributeVar), + ProfileAttribute: idp_utils.StringValue(d, ProfileAttributeVar), }, } resp, err := client.AddLDAPProvider(ctx, req) @@ -80,44 +74,39 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - timeout, err := time.ParseDuration(d.Get(TimeoutVar).(string)) + timeout, err := time.ParseDuration(idp_utils.StringValue(d, TimeoutVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateLDAPProvider(ctx, &admin.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ProviderOptions: idp_utils.ProviderOptionsValue(d), Servers: idp_utils.InterfaceToStringSlice(d.Get(ServersVar)), - StartTls: d.Get(StartTLSVar).(bool), - BaseDn: d.Get(BaseDNVar).(string), - BindDn: d.Get(BindDNVar).(string), - BindPassword: d.Get(BindPasswordVar).(string), - UserBase: d.Get(UserBaseVar).(string), + StartTls: idp_utils.BoolValue(d, StartTLSVar), + BaseDn: idp_utils.StringValue(d, BaseDNVar), + BindDn: idp_utils.StringValue(d, BindDNVar), + BindPassword: idp_utils.StringValue(d, BindPasswordVar), + UserBase: idp_utils.StringValue(d, UserBaseVar), UserObjectClasses: helper.GetOkSetToStringSlice(d, UserObjectClassesVar), UserFilters: helper.GetOkSetToStringSlice(d, UserFiltersVar), Timeout: durationpb.New(timeout), Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(IdAttributeVar).(string), - FirstNameAttribute: d.Get(FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(ProfileAttributeVar).(string), + IdAttribute: idp_utils.StringValue(d, IdAttributeVar), + FirstNameAttribute: idp_utils.StringValue(d, FirstNameAttributeVar), + LastNameAttribute: idp_utils.StringValue(d, LastNameAttributeVar), + DisplayNameAttribute: idp_utils.StringValue(d, DisplayNameAttributeVar), + NickNameAttribute: idp_utils.StringValue(d, NickNameAttributeVar), + PreferredUsernameAttribute: idp_utils.StringValue(d, PreferredUsernameAttributeVar), + EmailAttribute: idp_utils.StringValue(d, EmailAttributeVar), + EmailVerifiedAttribute: idp_utils.StringValue(d, EmailVerifiedAttributeVar), + PhoneAttribute: idp_utils.StringValue(d, PhoneAttributeVar), + PhoneVerifiedAttribute: idp_utils.StringValue(d, PhoneVerifiedAttributeVar), + PreferredLanguageAttribute: idp_utils.StringValue(d, PreferredLanguageAttributeVar), + AvatarUrlAttribute: idp_utils.StringValue(d, AvatarURLAttributeVar), + ProfileAttribute: idp_utils.StringValue(d, ProfileAttributeVar), }, }) if err != nil { @@ -159,7 +148,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn StartTLSVar: specificCfg.GetStartTls(), BaseDNVar: specificCfg.GetBaseDn(), BindDNVar: specificCfg.GetBindDn(), - BindPasswordVar: d.Get(BindPasswordVar).(string), + BindPasswordVar: idp_utils.StringValue(d, BindPasswordVar), UserBaseVar: specificCfg.GetUserBase(), UserObjectClassesVar: specificCfg.GetUserObjectClasses(), UserFiltersVar: specificCfg.GetUserFilters(), diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/v2/idp_utils/funcs.go index d46aa992..901637c7 100644 --- a/zitadel/v2/idp_utils/funcs.go +++ b/zitadel/v2/idp_utils/funcs.go @@ -7,8 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -45,6 +47,27 @@ func ImportIDPWithSecret(secretVar string) schema.StateContextFunc { } } +func StringValue(d *schema.ResourceData, attributeVar string) string { + return d.Get(attributeVar).(string) +} + +func BoolValue(d *schema.ResourceData, attributeVar string) bool { + return d.Get(attributeVar).(bool) +} + +func ScopesValue(d *schema.ResourceData) []string { + return helper.GetOkSetToStringSlice(d, ScopesVar) +} + +func ProviderOptionsValue(d *schema.ResourceData) *idp.Options { + return &idp.Options{ + IsLinkingAllowed: BoolValue(d, IsLinkingAllowedVar), + IsCreationAllowed: BoolValue(d, IsCreationAllowedVar), + IsAutoUpdate: BoolValue(d, IsAutoUpdateVar), + IsAutoCreation: BoolValue(d, IsAutoCreationVar), + } +} + func InterfaceToStringSlice(in interface{}) []string { slice := in.([]interface{}) ret := make([]string, 0) diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go index a969c0db..44adf409 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -3,18 +3,15 @@ package org_idp_azure_ad import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -22,23 +19,18 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddAzureADProvider(ctx, &management.AddAzureADProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - Tenant: idp_azure_ad.ConstructTenant(d), - EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: idp_utils.BoolValue(d, idp_azure_ad.EmailVerifiedVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -52,24 +44,19 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Tenant: idp_azure_ad.ConstructTenant(d), - EmailVerified: d.Get(idp_azure_ad.EmailVerifiedVar).(bool), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Tenant: idp_azure_ad.ConstructTenant(d), + EmailVerified: idp_utils.BoolValue(d, idp_azure_ad.EmailVerifiedVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -82,7 +69,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -102,7 +89,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: respIdp.GetDetails().GetResourceOwner(), idp_utils.NameVar: respIdp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index e75b3db3..5b1fee50 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -3,16 +3,13 @@ package org_idp_github import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -20,21 +17,16 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGitHubProvider(ctx, &management.AddGitHubProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -48,22 +40,17 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateGitHubProvider(ctx, &management.UpdateGitHubProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -76,7 +63,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -96,7 +83,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/v2/org_idp_github_es/funcs.go index 005e7f38..841ec115 100644 --- a/zitadel/v2/org_idp_github_es/funcs.go +++ b/zitadel/v2/org_idp_github_es/funcs.go @@ -3,18 +3,14 @@ package org_idp_github_es import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -22,24 +18,19 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGitHubEnterpriseServerProvider(ctx, &management.AddGitHubEnterpriseServerProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + AuthorizationEndpoint: idp_utils.StringValue(d, idp_github_es.AuthorizationEndpointVar), + TokenEndpoint: idp_utils.StringValue(d, idp_github_es.TokenEndpointVar), + UserEndpoint: idp_utils.StringValue(d, idp_github_es.UserEndpointVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -53,25 +44,20 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateGitHubEnterpriseServerProvider(ctx, &management.UpdateGitHubEnterpriseServerProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - AuthorizationEndpoint: d.Get(idp_github_es.AuthorizationEndpointVar).(string), - TokenEndpoint: d.Get(idp_github_es.TokenEndpointVar).(string), - UserEndpoint: d.Get(idp_github_es.UserEndpointVar).(string), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + AuthorizationEndpoint: idp_utils.StringValue(d, idp_github_es.AuthorizationEndpointVar), + TokenEndpoint: idp_utils.StringValue(d, idp_github_es.TokenEndpointVar), + UserEndpoint: idp_utils.StringValue(d, idp_github_es.UserEndpointVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -84,7 +70,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -104,7 +90,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_gitlab/funcs.go b/zitadel/v2/org_idp_gitlab/funcs.go index 94cd7c66..db512a6e 100644 --- a/zitadel/v2/org_idp_gitlab/funcs.go +++ b/zitadel/v2/org_idp_gitlab/funcs.go @@ -3,16 +3,13 @@ package org_idp_gitlab import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -20,21 +17,16 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGitLabProvider(ctx, &management.AddGitLabProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -48,22 +40,17 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateGitLabProvider(ctx, &management.UpdateGitLabProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -76,7 +63,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -96,7 +83,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go index d6c246c6..24a18a84 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go @@ -3,18 +3,14 @@ package org_idp_gitlab_self_hosted import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -22,22 +18,17 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGitLabSelfHostedProvider(ctx, &management.AddGitLabSelfHostedProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, - Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Issuer: idp_utils.StringValue(d, idp_gitlab_self_hosted.IssuerVar), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -51,23 +42,18 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateGitLabSelfHostedProvider(ctx, &management.UpdateGitLabSelfHostedProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, - Issuer: d.Get(idp_gitlab_self_hosted.IssuerVar).(string), + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Issuer: idp_utils.StringValue(d, idp_gitlab_self_hosted.IssuerVar), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -80,7 +66,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -100,7 +86,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_google/funcs.go b/zitadel/v2/org_idp_google/funcs.go index c2207812..882bbd85 100644 --- a/zitadel/v2/org_idp_google/funcs.go +++ b/zitadel/v2/org_idp_google/funcs.go @@ -3,16 +3,13 @@ package org_idp_google import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -20,21 +17,16 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } resp, err := client.AddGoogleProvider(ctx, &management.AddGoogleProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to create idp: %v", err) @@ -48,22 +40,17 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } _, err = client.UpdateGoogleProvider(ctx, &management.UpdateGoogleProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ClientId: d.Get(idp_utils.ClientIDVar).(string), - ClientSecret: d.Get(idp_utils.ClientSecretVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, idp_utils.ScopesVar), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), }) if err != nil { return diag.Errorf("failed to update idp: %v", err) @@ -76,7 +63,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -96,7 +83,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), - idp_utils.ClientSecretVar: d.Get(idp_utils.ClientSecretVar).(string), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), idp_utils.ScopesVar: specificCfg.GetScopes(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/v2/org_idp_ldap/funcs.go index 268ec278..d1d60607 100644 --- a/zitadel/v2/org_idp_ldap/funcs.go +++ b/zitadel/v2/org_idp_ldap/funcs.go @@ -4,20 +4,16 @@ import ( "context" "time" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - - "google.golang.org/protobuf/types/known/durationpb" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/durationpb" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -25,7 +21,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -34,38 +30,33 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddLDAPProvider(ctx, &management.AddLDAPProviderRequest{ - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - }, + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ProviderOptions: idp_utils.ProviderOptionsValue(d), Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), - StartTls: d.Get(idp_ldap.StartTLSVar).(bool), - BaseDn: d.Get(idp_ldap.BaseDNVar).(string), - BindDn: d.Get(idp_ldap.BindDNVar).(string), - BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), - UserBase: d.Get(idp_ldap.UserBaseVar).(string), + StartTls: idp_utils.BoolValue(d, idp_ldap.StartTLSVar), + BaseDn: idp_utils.StringValue(d, idp_ldap.BaseDNVar), + BindDn: idp_utils.StringValue(d, idp_ldap.BindDNVar), + BindPassword: idp_utils.StringValue(d, idp_ldap.BindPasswordVar), + UserBase: idp_utils.StringValue(d, idp_ldap.UserBaseVar), UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), Timeout: durationpb.New(timeout), Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), + IdAttribute: idp_utils.StringValue(d, idp_ldap.IdAttributeVar), + FirstNameAttribute: idp_utils.StringValue(d, idp_ldap.FirstNameAttributeVar), + LastNameAttribute: idp_utils.StringValue(d, idp_ldap.LastNameAttributeVar), + DisplayNameAttribute: idp_utils.StringValue(d, idp_ldap.DisplayNameAttributeVar), + NickNameAttribute: idp_utils.StringValue(d, idp_ldap.NickNameAttributeVar), + PreferredUsernameAttribute: idp_utils.StringValue(d, idp_ldap.PreferredUsernameAttributeVar), + EmailAttribute: idp_utils.StringValue(d, idp_ldap.EmailAttributeVar), + EmailVerifiedAttribute: idp_utils.StringValue(d, idp_ldap.EmailVerifiedAttributeVar), + PhoneAttribute: idp_utils.StringValue(d, idp_ldap.PhoneAttributeVar), + PhoneVerifiedAttribute: idp_utils.StringValue(d, idp_ldap.PhoneVerifiedAttributeVar), + PreferredLanguageAttribute: idp_utils.StringValue(d, idp_ldap.PreferredLanguageAttributeVar), + AvatarUrlAttribute: idp_utils.StringValue(d, idp_ldap.AvatarURLAttributeVar), + ProfileAttribute: idp_utils.StringValue(d, idp_ldap.ProfileAttributeVar), }, }) if err != nil { @@ -80,7 +71,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -89,39 +80,34 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } _, err = client.UpdateLDAPProvider(ctx, &management.UpdateLDAPProviderRequest{ - Id: d.Id(), - Name: d.Get(idp_utils.NameVar).(string), - ProviderOptions: &idp.Options{ - IsLinkingAllowed: d.Get(idp_utils.IsLinkingAllowedVar).(bool), - IsCreationAllowed: d.Get(idp_utils.IsCreationAllowedVar).(bool), - IsAutoCreation: d.Get(idp_utils.IsAutoCreationVar).(bool), - IsAutoUpdate: d.Get(idp_utils.IsAutoUpdateVar).(bool), - }, + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ProviderOptions: idp_utils.ProviderOptionsValue(d), Servers: idp_utils.InterfaceToStringSlice(d.Get(idp_ldap.ServersVar)), - StartTls: d.Get(idp_ldap.StartTLSVar).(bool), - BaseDn: d.Get(idp_ldap.BaseDNVar).(string), - BindDn: d.Get(idp_ldap.BindDNVar).(string), - BindPassword: d.Get(idp_ldap.BindPasswordVar).(string), - UserBase: d.Get(idp_ldap.UserBaseVar).(string), + StartTls: idp_utils.BoolValue(d, idp_ldap.StartTLSVar), + BaseDn: idp_utils.StringValue(d, idp_ldap.BaseDNVar), + BindDn: idp_utils.StringValue(d, idp_ldap.BindDNVar), + BindPassword: idp_utils.StringValue(d, idp_ldap.BindPasswordVar), + UserBase: idp_utils.StringValue(d, idp_ldap.UserBaseVar), UserObjectClasses: helper.GetOkSetToStringSlice(d, idp_ldap.UserObjectClassesVar), UserFilters: helper.GetOkSetToStringSlice(d, idp_ldap.UserFiltersVar), Timeout: durationpb.New(timeout), Attributes: &idp.LDAPAttributes{ - IdAttribute: d.Get(idp_ldap.IdAttributeVar).(string), - FirstNameAttribute: d.Get(idp_ldap.FirstNameAttributeVar).(string), - LastNameAttribute: d.Get(idp_ldap.LastNameAttributeVar).(string), - DisplayNameAttribute: d.Get(idp_ldap.DisplayNameAttributeVar).(string), - NickNameAttribute: d.Get(idp_ldap.NickNameAttributeVar).(string), - PreferredUsernameAttribute: d.Get(idp_ldap.PreferredUsernameAttributeVar).(string), - EmailAttribute: d.Get(idp_ldap.EmailAttributeVar).(string), - EmailVerifiedAttribute: d.Get(idp_ldap.EmailVerifiedAttributeVar).(string), - PhoneAttribute: d.Get(idp_ldap.PhoneAttributeVar).(string), - PhoneVerifiedAttribute: d.Get(idp_ldap.PhoneVerifiedAttributeVar).(string), - PreferredLanguageAttribute: d.Get(idp_ldap.PreferredLanguageAttributeVar).(string), - AvatarUrlAttribute: d.Get(idp_ldap.AvatarURLAttributeVar).(string), - ProfileAttribute: d.Get(idp_ldap.ProfileAttributeVar).(string), + IdAttribute: idp_utils.StringValue(d, idp_ldap.IdAttributeVar), + FirstNameAttribute: idp_utils.StringValue(d, idp_ldap.FirstNameAttributeVar), + LastNameAttribute: idp_utils.StringValue(d, idp_ldap.LastNameAttributeVar), + DisplayNameAttribute: idp_utils.StringValue(d, idp_ldap.DisplayNameAttributeVar), + NickNameAttribute: idp_utils.StringValue(d, idp_ldap.NickNameAttributeVar), + PreferredUsernameAttribute: idp_utils.StringValue(d, idp_ldap.PreferredUsernameAttributeVar), + EmailAttribute: idp_utils.StringValue(d, idp_ldap.EmailAttributeVar), + EmailVerifiedAttribute: idp_utils.StringValue(d, idp_ldap.EmailVerifiedAttributeVar), + PhoneAttribute: idp_utils.StringValue(d, idp_ldap.PhoneAttributeVar), + PhoneVerifiedAttribute: idp_utils.StringValue(d, idp_ldap.PhoneVerifiedAttributeVar), + PreferredLanguageAttribute: idp_utils.StringValue(d, idp_ldap.PreferredLanguageAttributeVar), + AvatarUrlAttribute: idp_utils.StringValue(d, idp_ldap.AvatarURLAttributeVar), + ProfileAttribute: idp_utils.StringValue(d, idp_ldap.ProfileAttributeVar), }, }) if err != nil { @@ -135,7 +121,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(org_idp_utils.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -164,7 +150,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp_ldap.StartTLSVar: specificCfg.GetStartTls(), idp_ldap.BaseDNVar: specificCfg.GetBaseDn(), idp_ldap.BindDNVar: specificCfg.GetBindDn(), - idp_ldap.BindPasswordVar: d.Get(idp_ldap.BindPasswordVar).(string), + idp_ldap.BindPasswordVar: idp_utils.StringValue(d, idp_ldap.BindPasswordVar), idp_ldap.UserBaseVar: specificCfg.GetUserBase(), idp_ldap.UserObjectClassesVar: specificCfg.GetUserObjectClasses(), idp_ldap.UserFiltersVar: specificCfg.GetUserFilters(), From dad73518d716ae3c62d3af251af5a748bdeb7a43 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 08:33:27 +0200 Subject: [PATCH 123/260] describe maintaining docs --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0b6deef..903e346d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,3 +26,9 @@ TF_ACC=1 TF_ACC_ZITADEL_TOKEN=/my-token.json go test ./... The tests are flaky when resources should be cleaned up. This results in dangling resources. + +# Generate Docs + +1. Manually maintain files in /templates and /examples +1. Install the tool tfplugindocs with `go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs` +1. Generate the docs with `tfplugindocs generate` From 22f0a561ba0c4cddf6f1f47ceb4a3d549eae32fa Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 08:33:44 +0200 Subject: [PATCH 124/260] increment provider example --- examples/provider/provider.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 7a204d98..f04e9ae3 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,12 +2,12 @@ terraform { required_providers { zitadel = { source = "zitadel/zitadel" - version = "1.0.0-alpha.14" + version = "1.0.0-alpha.16" } } } -provider zitadel { +provider "zitadel" { domain = "localhost" insecure = "true" port = "8080" From 6fdb3c948f57f93df11199b0e1f6992f40ddbe15 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 08:34:06 +0200 Subject: [PATCH 125/260] regenerate docs --- docs/data-sources/idp_azure_ad.md | 8 ++++---- docs/data-sources/idp_github.md | 8 ++++---- docs/data-sources/idp_github_es.md | 8 ++++---- docs/data-sources/idp_gitlab.md | 8 ++++---- docs/data-sources/idp_gitlab_self_hosted.md | 10 ++++------ docs/data-sources/idp_google.md | 8 ++++---- docs/data-sources/idp_ldap.md | 8 ++++---- docs/data-sources/org_idp_azure_ad.md | 8 ++++---- docs/data-sources/org_idp_github.md | 8 ++++---- docs/data-sources/org_idp_github_es.md | 8 ++++---- docs/data-sources/org_idp_gitlab.md | 8 ++++---- docs/data-sources/org_idp_gitlab_self_hosted.md | 8 ++++---- docs/data-sources/org_idp_google.md | 8 ++++---- docs/data-sources/org_idp_ldap.md | 8 ++++---- docs/index.md | 4 ++-- docs/resources/idp_azure_ad.md | 6 +++--- docs/resources/idp_github.md | 5 ++++- docs/resources/idp_github_es.md | 9 ++++++--- docs/resources/idp_gitlab.md | 5 ++++- docs/resources/idp_gitlab_self_hosted.md | 5 ++++- docs/resources/idp_google.md | 5 ++++- docs/resources/idp_ldap.md | 4 ++-- docs/resources/org_idp_azure_ad.md | 6 +++--- docs/resources/org_idp_github.md | 7 +++++-- docs/resources/org_idp_github_es.md | 9 ++++++--- docs/resources/org_idp_gitlab.md | 7 +++++-- docs/resources/org_idp_gitlab_self_hosted.md | 7 +++++-- docs/resources/org_idp_google.md | 7 +++++-- docs/resources/org_idp_ldap.md | 4 ++-- 29 files changed, 116 insertions(+), 88 deletions(-) diff --git a/docs/data-sources/idp_azure_ad.md b/docs/data-sources/idp_azure_ad.md index 8c5bb97a..3bc8aab0 100644 --- a/docs/data-sources/idp_azure_ad.md +++ b/docs/data-sources/idp_azure_ad.md @@ -29,10 +29,10 @@ data "zitadel_idp_azure_ad" "azure_ad" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider - `email_verified` (Boolean) automatically mark emails as verified -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id diff --git a/docs/data-sources/idp_github.md b/docs/data-sources/idp_github.md index f99e9a42..f41459d0 100644 --- a/docs/data-sources/idp_github.md +++ b/docs/data-sources/idp_github.md @@ -28,10 +28,10 @@ data "zitadel_idp_github" "github" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_github_es.md b/docs/data-sources/idp_github_es.md index adfe659a..9eeea1ce 100644 --- a/docs/data-sources/idp_github_es.md +++ b/docs/data-sources/idp_github_es.md @@ -29,10 +29,10 @@ data "zitadel_idp_github_es" "github_es" { - `authorization_endpoint` (String) the providers authorization endpoint - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint diff --git a/docs/data-sources/idp_gitlab.md b/docs/data-sources/idp_gitlab.md index 3555eaa9..eab89775 100644 --- a/docs/data-sources/idp_gitlab.md +++ b/docs/data-sources/idp_gitlab.md @@ -28,10 +28,10 @@ data "zitadel_idp_gitlab" "gitlab" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_gitlab_self_hosted.md b/docs/data-sources/idp_gitlab_self_hosted.md index f5097acb..7c981b6d 100644 --- a/docs/data-sources/idp_gitlab_self_hosted.md +++ b/docs/data-sources/idp_gitlab_self_hosted.md @@ -28,15 +28,13 @@ data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `issuer` (String) the providers issuer - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `token_endpoint` (String) the providers token endpoint -- `user_endpoint` (String) the providers user endpoint ## Import diff --git a/docs/data-sources/idp_google.md b/docs/data-sources/idp_google.md index 60330e6c..ddc9e0f5 100644 --- a/docs/data-sources/idp_google.md +++ b/docs/data-sources/idp_google.md @@ -28,10 +28,10 @@ data "zitadel_idp_google" "google" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/idp_ldap.md b/docs/data-sources/idp_ldap.md index 22f747d7..b69a2ea1 100644 --- a/docs/data-sources/idp_ldap.md +++ b/docs/data-sources/idp_ldap.md @@ -35,10 +35,10 @@ data "zitadel_idp_ldap" "ldap" { - `email_verified_attribute` (String) User attribute for the email verified state - `first_name_attribute` (String) User attribute for the first name - `id_attribute` (String) User attribute for the id -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `last_name_attribute` (String) User attribute for the last name - `name` (String) Name of the IDP - `nick_name_attribute` (String) User attribute for the nick name diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md index 7b4617fa..2497903f 100644 --- a/docs/data-sources/org_idp_azure_ad.md +++ b/docs/data-sources/org_idp_azure_ad.md @@ -30,10 +30,10 @@ data "zitadel_org_idp_azure_ad" "azure_ad" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider - `email_verified` (Boolean) automatically mark emails as verified -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md index 34852344..ca13ea79 100644 --- a/docs/data-sources/org_idp_github.md +++ b/docs/data-sources/org_idp_github.md @@ -29,10 +29,10 @@ data "zitadel_org_idp_github" "github" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md index 80bdf92e..64fb14fd 100644 --- a/docs/data-sources/org_idp_github_es.md +++ b/docs/data-sources/org_idp_github_es.md @@ -30,10 +30,10 @@ data "zitadel_org_idp_github_es" "github_es" { - `authorization_endpoint` (String) the providers authorization endpoint - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md index c20ac113..65e6dfa1 100644 --- a/docs/data-sources/org_idp_gitlab.md +++ b/docs/data-sources/org_idp_gitlab.md @@ -29,10 +29,10 @@ data "zitadel_org_idp_gitlab" "gitlab" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md index dd2149da..4b391b4d 100644 --- a/docs/data-sources/org_idp_gitlab_self_hosted.md +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -29,10 +29,10 @@ data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `issuer` (String) the providers issuer - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md index 073ae6bf..553f3f5f 100644 --- a/docs/data-sources/org_idp_google.md +++ b/docs/data-sources/org_idp_google.md @@ -29,10 +29,10 @@ data "zitadel_org_idp_google" "google" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md index 7dea2cfb..7e3f28b9 100644 --- a/docs/data-sources/org_idp_ldap.md +++ b/docs/data-sources/org_idp_ldap.md @@ -36,10 +36,10 @@ data "zitadel_org_idp_ldap" "ldap" { - `email_verified_attribute` (String) User attribute for the email verified state - `first_name_attribute` (String) User attribute for the first name - `id_attribute` (String) User attribute for the id -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account -- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login -- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account -- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `last_name_attribute` (String) User attribute for the last name - `name` (String) Name of the IDP - `nick_name_attribute` (String) User attribute for the nick name diff --git a/docs/index.md b/docs/index.md index 8dad0999..2b8321bc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,7 @@ terraform { } } -provider zitadel { +provider "zitadel" { domain = "localhost" insecure = "true" port = "8080" @@ -62,4 +62,4 @@ provider zitadel { ## Limitations -The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. +The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file diff --git a/docs/resources/idp_azure_ad.md b/docs/resources/idp_azure_ad.md index a06a9229..ca0ad907 100644 --- a/docs/resources/idp_azure_ad.md +++ b/docs/resources/idp_azure_ad.md @@ -34,15 +34,15 @@ resource "zitadel_idp_azure_ad" "azure_ad" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider - `email_verified` (Boolean) automatically mark emails as verified -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Optional +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) if tenant_id is not set, the tenant_type is used - `tenant_type` (String) the azure ad tenant type diff --git a/docs/resources/idp_github.md b/docs/resources/idp_github.md index 3b003f43..74f5b625 100644 --- a/docs/resources/idp_github.md +++ b/docs/resources/idp_github.md @@ -31,10 +31,13 @@ resource "zitadel_idp_github" "github" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account + +### Optional + - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/resources/idp_github_es.md b/docs/resources/idp_github_es.md index 7d423df5..250a1867 100644 --- a/docs/resources/idp_github_es.md +++ b/docs/resources/idp_github_es.md @@ -35,15 +35,18 @@ resource "zitadel_idp_github_es" "github_es" { - `authorization_endpoint` (String) the providers authorization endpoint - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint +### Optional + +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + ### Read-Only - `id` (String) The ID of this resource. diff --git a/docs/resources/idp_gitlab.md b/docs/resources/idp_gitlab.md index ea8dda83..1a429094 100644 --- a/docs/resources/idp_gitlab.md +++ b/docs/resources/idp_gitlab.md @@ -31,10 +31,13 @@ resource "zitadel_idp_gitlab" "gitlab" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account + +### Optional + - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/resources/idp_gitlab_self_hosted.md b/docs/resources/idp_gitlab_self_hosted.md index 44598165..4ce8fefa 100644 --- a/docs/resources/idp_gitlab_self_hosted.md +++ b/docs/resources/idp_gitlab_self_hosted.md @@ -32,11 +32,14 @@ resource "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `issuer` (String) the providers issuer + +### Optional + - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/resources/idp_google.md b/docs/resources/idp_google.md index 04a52e0c..83905365 100644 --- a/docs/resources/idp_google.md +++ b/docs/resources/idp_google.md @@ -31,10 +31,13 @@ resource "zitadel_idp_google" "google" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account + +### Optional + - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider diff --git a/docs/resources/idp_ldap.md b/docs/resources/idp_ldap.md index d1038025..3fb0e2dd 100644 --- a/docs/resources/idp_ldap.md +++ b/docs/resources/idp_ldap.md @@ -41,11 +41,10 @@ resource "zitadel_idp_ldap" "ldap" { - `base_dn` (String) Base DN for LDAP connections - `bind_dn` (String) Bind DN for LDAP connections - `bind_password` (String, Sensitive) Bind password for LDAP connections -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `servers` (List of String) Servers to try in order for establishing LDAP connections - `start_tls` (Boolean) Wether to use StartTLS for LDAP connections - `timeout` (String) Timeout for LDAP connections @@ -62,6 +61,7 @@ resource "zitadel_idp_ldap" "ldap" { - `first_name_attribute` (String) User attribute for the first name - `id_attribute` (String) User attribute for the id - `last_name_attribute` (String) User attribute for the last name +- `name` (String) Name of the IDP - `nick_name_attribute` (String) User attribute for the nick name - `phone_attribute` (String) User attribute for the phone - `phone_verified_attribute` (String) User attribute for the phone verified state diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md index 2c51a3fd..d382b38b 100644 --- a/docs/resources/org_idp_azure_ad.md +++ b/docs/resources/org_idp_azure_ad.md @@ -35,16 +35,16 @@ resource "zitadel_org_idp_azure_ad" "azure_ad" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider - `email_verified` (Boolean) automatically mark emails as verified -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Optional +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) if tenant_id is not set, the tenant_type is used - `tenant_type` (String) the azure ad tenant type diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md index 5c2d4c58..303cbd56 100644 --- a/docs/resources/org_idp_github.md +++ b/docs/resources/org_idp_github.md @@ -32,12 +32,15 @@ resource "zitadel_org_idp_github" "github" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization + +### Optional + +- `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md index be604544..c89c32fc 100644 --- a/docs/resources/org_idp_github_es.md +++ b/docs/resources/org_idp_github_es.md @@ -36,16 +36,19 @@ resource "zitadel_org_idp_github_es" "github_es" { - `authorization_endpoint` (String) the providers authorization endpoint - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint +### Optional + +- `name` (String) Name of the IDP +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider + ### Read-Only - `id` (String) The ID of this resource. diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md index 46fc5cc5..6de386f2 100644 --- a/docs/resources/org_idp_gitlab.md +++ b/docs/resources/org_idp_gitlab.md @@ -32,12 +32,15 @@ resource "zitadel_org_idp_gitlab" "gitlab" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization + +### Optional + +- `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md index 23c5b145..82b4f640 100644 --- a/docs/resources/org_idp_gitlab_self_hosted.md +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -33,13 +33,16 @@ resource "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `issuer` (String) the providers issuer -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization + +### Optional + +- `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md index b7412788..d4a7be21 100644 --- a/docs/resources/org_idp_google.md +++ b/docs/resources/org_idp_google.md @@ -32,12 +32,15 @@ resource "zitadel_org_idp_google" "google" { - `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization + +### Optional + +- `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md index 80e99893..b5f17c7f 100644 --- a/docs/resources/org_idp_ldap.md +++ b/docs/resources/org_idp_ldap.md @@ -42,11 +42,10 @@ resource "zitadel_org_idp_ldap" "ldap" { - `base_dn` (String) Base DN for LDAP connections - `bind_dn` (String) Bind DN for LDAP connections - `bind_password` (String, Sensitive) Bind password for LDAP connections -- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically when login with an external account +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `name` (String) Name of the IDP - `org_id` (String) ID of the organization - `servers` (List of String) Servers to try in order for establishing LDAP connections - `start_tls` (Boolean) Wether to use StartTLS for LDAP connections @@ -64,6 +63,7 @@ resource "zitadel_org_idp_ldap" "ldap" { - `first_name_attribute` (String) User attribute for the first name - `id_attribute` (String) User attribute for the id - `last_name_attribute` (String) User attribute for the last name +- `name` (String) Name of the IDP - `nick_name_attribute` (String) User attribute for the nick name - `phone_attribute` (String) User attribute for the phone - `phone_verified_attribute` (String) User attribute for the phone verified state From eb807f380cf337aad56a38334287a72bd309a6d6 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 25 Apr 2023 18:26:43 +0200 Subject: [PATCH 126/260] fix tenant type schema --- zitadel/v2/idp_azure_ad/schema.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zitadel/v2/idp_azure_ad/schema.go b/zitadel/v2/idp_azure_ad/schema.go index 2106106f..4484e261 100644 --- a/zitadel/v2/idp_azure_ad/schema.go +++ b/zitadel/v2/idp_azure_ad/schema.go @@ -3,7 +3,12 @@ package idp_azure_ad import ( "fmt" + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( @@ -16,8 +21,11 @@ var ( TenantTypeResourceField = &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "AZURE_AD_TENANT_TYPE_COMMON", + Default: idp.AzureADTenantType_name[0], Description: "the azure ad tenant type", + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(TenantTypeVar, value, idp.AzureADTenantType_value) + }, } TenantTypeDataSourceField = &schema.Schema{ Type: schema.TypeString, From 3ff5eacf8ae15c6650122550fc52adb493847003 Mon Sep 17 00:00:00 2001 From: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> Date: Mon, 1 May 2023 15:37:33 -0500 Subject: [PATCH 127/260] feat: update privacy_policy and default_privacy_policy resources to add support for support email Signed-off-by: Yoriyasu Yano <430092+yorinasub17@users.noreply.github.com> --- docs/resources/default_privacy_policy.md | 1 + docs/resources/privacy_policy.md | 1 + .../resources/default_privacy_policy.tf | 9 ++++---- examples/provider/resources/privacy_policy.tf | 11 +++++---- zitadel/v2/default_privacy_policy/const.go | 7 +++--- zitadel/v2/default_privacy_policy/funcs.go | 16 +++++++------ zitadel/v2/default_privacy_policy/resource.go | 5 ++++ zitadel/v2/privacy_policy/const.go | 9 ++++---- zitadel/v2/privacy_policy/funcs.go | 23 +++++++++++-------- zitadel/v2/privacy_policy/resource.go | 5 ++++ 10 files changed, 54 insertions(+), 33 deletions(-) diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index dc7e920a..9684a246 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -26,6 +26,7 @@ resource zitadel_default_privacy_policy privacy_policy { - `help_link` (String) - `privacy_link` (String) +- `support_email` (String) - `tos_link` (String) ### Read-Only diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index ffb4a63f..374a573b 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -28,6 +28,7 @@ resource zitadel_privacy_policy privacy_policy { - `help_link` (String) - `org_id` (String) Id for the organization - `privacy_link` (String) +- `support_email` (String) - `tos_link` (String) ### Read-Only diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf index 5bae97d6..b0b20d09 100644 --- a/examples/provider/resources/default_privacy_policy.tf +++ b/examples/provider/resources/default_privacy_policy.tf @@ -1,5 +1,6 @@ resource zitadel_default_privacy_policy privacy_policy { - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" -} \ No newline at end of file + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" +} diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index 486bb012..5dc3491a 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,6 +1,7 @@ resource zitadel_privacy_policy privacy_policy { - org_id = zitadel_org.org.id - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" -} \ No newline at end of file + org_id = zitadel_org.org.id + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" +} diff --git a/zitadel/v2/default_privacy_policy/const.go b/zitadel/v2/default_privacy_policy/const.go index ec5939b4..c3c5224e 100644 --- a/zitadel/v2/default_privacy_policy/const.go +++ b/zitadel/v2/default_privacy_policy/const.go @@ -1,7 +1,8 @@ package default_privacy_policy const ( - tosLinkVar = "tos_link" - privacyLinkVar = "privacy_link" - helpLinkVar = "help_link" + tosLinkVar = "tos_link" + privacyLinkVar = "privacy_link" + helpLinkVar = "help_link" + supportEmailVar = "support_email" ) diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index b11bde98..1804bb84 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -30,11 +30,12 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } id := "" - if d.HasChanges(tosLinkVar, privacyLinkVar, helpLinkVar) { + if d.HasChanges(tosLinkVar, privacyLinkVar, helpLinkVar, supportEmailVar) { resp, err := client.UpdatePrivacyPolicy(ctx, &admin.UpdatePrivacyPolicyRequest{ - TosLink: d.Get(tosLinkVar).(string), - PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + SupportEmail: d.Get(supportEmailVar).(string), }) if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default privacy policy: %v", err) @@ -78,9 +79,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn policy := resp.Policy set := map[string]interface{}{ - tosLinkVar: policy.GetTosLink(), - privacyLinkVar: policy.GetPrivacyLink(), - helpLinkVar: policy.GetHelpLink(), + tosLinkVar: policy.GetTosLink(), + privacyLinkVar: policy.GetPrivacyLink(), + helpLinkVar: policy.GetHelpLink(), + supportEmailVar: policy.GetSupportEmail(), } for k, v := range set { diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/v2/default_privacy_policy/resource.go index e03dbf92..2503a115 100644 --- a/zitadel/v2/default_privacy_policy/resource.go +++ b/zitadel/v2/default_privacy_policy/resource.go @@ -23,6 +23,11 @@ func GetResource() *schema.Resource { Required: true, Description: "", }, + supportEmailVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, }, CreateContext: update, DeleteContext: delete, diff --git a/zitadel/v2/privacy_policy/const.go b/zitadel/v2/privacy_policy/const.go index 712d5110..17acc93f 100644 --- a/zitadel/v2/privacy_policy/const.go +++ b/zitadel/v2/privacy_policy/const.go @@ -1,8 +1,9 @@ package privacy_policy const ( - orgIDVar = "org_id" - tosLinkVar = "tos_link" - privacyLinkVar = "privacy_link" - helpLinkVar = "help_link" + orgIDVar = "org_id" + tosLinkVar = "tos_link" + privacyLinkVar = "privacy_link" + helpLinkVar = "help_link" + supportEmailVar = "support_email" ) diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index ee270b41..e057daa7 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -47,9 +47,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateCustomPrivacyPolicy(ctx, &management.UpdateCustomPrivacyPolicyRequest{ - TosLink: d.Get(tosLinkVar).(string), - PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + SupportEmail: d.Get(supportEmailVar).(string), }) if err != nil { return diag.Errorf("failed to update privacy policy: %v", err) @@ -72,9 +73,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.AddCustomPrivacyPolicy(ctx, &management.AddCustomPrivacyPolicyRequest{ - TosLink: d.Get(tosLinkVar).(string), - PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + TosLink: d.Get(tosLinkVar).(string), + PrivacyLink: d.Get(privacyLinkVar).(string), + HelpLink: d.Get(helpLinkVar).(string), + SupportEmail: d.Get(supportEmailVar).(string), }) if err != nil { return diag.Errorf("failed to create privacy policy: %v", err) @@ -112,10 +114,11 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), - tosLinkVar: policy.GetTosLink(), - privacyLinkVar: policy.GetPrivacyLink(), - helpLinkVar: policy.GetHelpLink(), + orgIDVar: policy.GetDetails().GetResourceOwner(), + tosLinkVar: policy.GetTosLink(), + privacyLinkVar: policy.GetPrivacyLink(), + helpLinkVar: policy.GetHelpLink(), + supportEmailVar: policy.GetSupportEmail(), } for k, v := range set { diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go index bdf75e34..da54651d 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/v2/privacy_policy/resource.go @@ -29,6 +29,11 @@ func GetResource() *schema.Resource { Required: true, Description: "", }, + supportEmailVar: { + Type: schema.TypeString, + Required: true, + Description: "", + }, }, CreateContext: create, DeleteContext: delete, From 4d73aece762d0a97d401d595542502921ec21eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kotori=E3=81=AE=E3=81=AD=E3=81=93?= Date: Sat, 6 May 2023 16:28:10 -0500 Subject: [PATCH 128/260] feat: implement org removal when an org resource is deleted --- zitadel/v2/org/funcs.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/zitadel/v2/org/funcs.go b/zitadel/v2/org/funcs.go index 63dce0bb..ba95c169 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/v2/org/funcs.go @@ -14,7 +14,25 @@ import ( ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "org delete not yet implemented") + tflog.Info(ctx, "started delete") + + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.RemoveOrg(ctx, &admin.RemoveOrgRequest{ + OrgId: d.Id(), + }) + if err != nil { + return diag.FromErr(err) + } + d.SetId("") return nil } From b886243153041fe57e37b96687e3efe967afcd7f Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 12 May 2023 10:06:12 +0200 Subject: [PATCH 129/260] fix: correct handling of primary domain to set default primary first --- docs/resources/default_login_texts.md | 8 +++----- .../default_password_change_message_text.md | 7 +++---- .../resources/password_change_message_text.md | 7 +++---- .../resources/default_login_texts.md.tmpl | 16 ++++++++++++++++ ...fault_password_change_message_text.md.tmpl | 16 ++++++++++++++++ .../password_change_message_text.md.tmpl | 16 ++++++++++++++++ zitadel/v2/domain/funcs.go | 19 ++++++++++++++++++- zitadel/v2/domain/resource.go | 1 + 8 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 templates/resources/default_login_texts.md.tmpl create mode 100644 templates/resources/default_password_change_message_text.md.tmpl create mode 100644 templates/resources/password_change_message_text.md.tmpl diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md index db08f05d..94e679fc 100644 --- a/docs/resources/default_login_texts.md +++ b/docs/resources/default_login_texts.md @@ -1,14 +1,14 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_default_login_texts Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_default_login_texts (Resource) + ## Example Usage ```terraform @@ -304,8 +304,6 @@ resource zitadel_default_login_texts login_texts_en { } ``` - - ## Schema @@ -808,4 +806,4 @@ Optional: - `error_retry` (String) - `not_supported` (String) - `title` (String) -- `validate_token_text` (String) +- `validate_token_text` (String) \ No newline at end of file diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md index 2ec195dc..a7fe0d63 100644 --- a/docs/resources/default_password_change_message_text.md +++ b/docs/resources/default_password_change_message_text.md @@ -1,14 +1,14 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_default_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_default_password_change_message_text (Resource) + ## Example Usage ```terraform @@ -25,7 +25,6 @@ resource zitadel_default_password_change_message_text password_change_en { } ``` - ## Schema @@ -45,4 +44,4 @@ resource zitadel_default_password_change_message_text password_change_en { ### Read-Only -- `id` (String) The ID of this resource. +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index be8a789e..3754d000 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -1,14 +1,14 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_password_change_message_text (Resource) + ## Example Usage ```terraform @@ -26,7 +26,6 @@ resource zitadel_password_change_message_text password_change_en { } ``` - ## Schema @@ -47,4 +46,4 @@ resource zitadel_password_change_message_text password_change_en { ### Read-Only -- `id` (String) The ID of this resource. +- `id` (String) The ID of this resource. \ No newline at end of file diff --git a/templates/resources/default_login_texts.md.tmpl b/templates/resources/default_login_texts.md.tmpl new file mode 100644 index 00000000..f44b5a1a --- /dev/null +++ b/templates/resources/default_login_texts.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_login_texts.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/default_password_change_message_text.md.tmpl b/templates/resources/default_password_change_message_text.md.tmpl new file mode 100644 index 00000000..12190450 --- /dev/null +++ b/templates/resources/default_password_change_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_password_change_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/templates/resources/password_change_message_text.md.tmpl b/templates/resources/password_change_message_text.md.tmpl new file mode 100644 index 00000000..49601b72 --- /dev/null +++ b/templates/resources/password_change_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/password_change_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} \ No newline at end of file diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index e41e7f63..60ede410 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -2,6 +2,7 @@ package domain import ( "context" + "strings" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -25,9 +26,25 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + domainName := d.Id() + if d.Get(isPrimaryVar).(bool) { + resp, err := client.ListOrgDomains(ctx, &management.ListOrgDomainsRequest{}) + if err != nil { + return diag.FromErr(err) + } + for _, domain := range resp.Result { + parts := strings.Split(clientinfo.Domain, ":") + if domain.IsVerified && domain.DomainName != domainName && strings.HasSuffix(domain.GetDomainName(), parts[0]) { + if _, err := client.SetPrimaryOrgDomain(ctx, &management.SetPrimaryOrgDomainRequest{Domain: domain.DomainName}); err != nil { + return diag.FromErr(err) + } + break + } + } + } _, err = client.RemoveOrgDomain(ctx, &management.RemoveOrgDomainRequest{ - Domain: d.Id(), + Domain: domainName, }) if err != nil { return diag.Errorf("failed to delete domain: %v", err) diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index 2b0f8800..a708641d 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -29,6 +29,7 @@ func GetResource() *schema.Resource { Type: schema.TypeBool, Optional: true, Description: "Is domain primary", + Default: false, }, validationTypeVar: { Type: schema.TypeInt, From 649b2fd573cea6ef40510943956ffe01b08a1385 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 15 May 2023 16:01:03 +0200 Subject: [PATCH 130/260] chore: run tests on PR --- .github/workflows/pull_request.yaml | 22 +++++++++++ CONTRIBUTING.md | 11 ++++-- acceptance/docker-compose.yaml | 37 +++++++++++++++++++ acceptance/machinekey/.gitignore | 1 + acceptance/zitadel.yaml | 13 +++++++ zitadel/v2/idp_utils/idp_test_utils/checks.go | 25 +++++++++++-- .../org_idp_test_utils/checks.go | 14 ++++--- 7 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/pull_request.yaml create mode 100644 acceptance/docker-compose.yaml create mode 100644 acceptance/machinekey/.gitignore create mode 100644 acceptance/zitadel.yaml diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 00000000..9f4c5ce9 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,22 @@ +name: Test Provider + +on: pull_request + +jobs: + test: + + runs-on: ubuntu-20.04 + + permissions: + contents: read + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up ZITADEL + run: docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel + + - name: Run Acceptance Tests + run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 903e346d..c7f9a42e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,11 +17,16 @@ # Run Acceptance Tests -Ensure ZITADEL listens at http://localhost:8080 and you have a service account key in your local filesystem. -The easiest way to achieve that is [to follow this guide](https://zitadel.com/docs/self-hosting/deploy/compose#docker-compose-with-service-account). +Run a local ZITADEL instance using docker compose. ```bash -TF_ACC=1 TF_ACC_ZITADEL_TOKEN=/my-token.json go test ./... +docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel +``` + +Run the accepance tests using the machine key generated by ZITADEL. + +```bash +TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... ``` The tests are flaky when resources should be cleaned up. diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml new file mode 100644 index 00000000..cef42f75 --- /dev/null +++ b/acceptance/docker-compose.yaml @@ -0,0 +1,37 @@ +version: '3.8' + +services: + zitadel: + user: '$UID' + restart: 'on-failure' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}' + command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' + ports: + - "8080:8080" + volumes: + - ./machinekey:/machinekey + - ./zitadel.yaml:/zitadel.yaml + depends_on: + db: + condition: 'service_healthy' + + db: + image: 'cockroachdb/cockroach:v22.2.2' + command: 'start-single-node --insecure --http-addr :9090' + healthcheck: + test: ['CMD', 'curl', '-f', 'http://localhost:9090/health?ready=1'] + interval: '10s' + timeout: '30s' + retries: 5 + start_period: '20s' + ports: + - "26257:26257" + - "9090:9090" + restart: 'on-failure' + + wait_for_zitadel: + image: curlimages/curl:8.00.1 + command: [ "/bin/sh", "-c", "i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0" ] + depends_on: + - zitadel + diff --git a/acceptance/machinekey/.gitignore b/acceptance/machinekey/.gitignore new file mode 100644 index 00000000..7c9f54d0 --- /dev/null +++ b/acceptance/machinekey/.gitignore @@ -0,0 +1 @@ +zitadel-admin-sa.json diff --git a/acceptance/zitadel.yaml b/acceptance/zitadel.yaml new file mode 100644 index 00000000..daf4e5d8 --- /dev/null +++ b/acceptance/zitadel.yaml @@ -0,0 +1,13 @@ +FirstInstance: + MachineKeyPath: /machinekey/zitadel-admin-sa.json + Org: + Machine: + Machine: + Username: zitadel-admin-sa + Name: Admin + MachineKey: + Type: 1 + +Database: + Cockroach: + Host: db diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index f9a92f80..51acfd7c 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -2,6 +2,7 @@ package idp_test_utils import ( "fmt" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -30,10 +31,26 @@ func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource func CheckDestroy(frame test_utils.InstanceTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - err := CheckProviderName(frame)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) + return RetryAMinute(func() error { + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + }) + } +} + +func RetryAMinute(try func() error) error { + start := time.Now() + for { + err := try() + if err == nil { + return nil + } + if time.Since(start) > time.Minute { + return fmt.Errorf("function failed after retrying for a minute: %w", err) } - return nil + time.Sleep(time.Second) } } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 55a5dcaa..08e7a899 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -3,6 +3,8 @@ package org_idp_test_utils import ( "fmt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -31,10 +33,12 @@ func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.Test func CheckDestroy(frame test_utils.OrgTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - err := CheckProviderName(frame)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil + return idp_test_utils.RetryAMinute(func() error { + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + }) } } From 82a06d25e22f3d1770ec65b458fafd5a1645e5fb Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 15 May 2023 16:20:29 +0200 Subject: [PATCH 131/260] chore: align to zitadel pipeline --- .github/workflows/pull_request.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 9f4c5ce9..94609773 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -11,12 +11,21 @@ jobs: contents: read steps: + - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up ZITADEL run: docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: Run Acceptance Tests run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... From dd90e113500420914a9233f6276bd46be1b69439 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 15 May 2023 16:45:54 +0200 Subject: [PATCH 132/260] chore: save zitadel logs --- .github/workflows/pull_request.yaml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 94609773..093ce8a3 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -16,11 +16,9 @@ jobs: with: fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up ZITADEL - run: docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel + working-directory: acceptance + run: docker compose run wait_for_zitadel - name: Set up Go uses: actions/setup-go@v3 @@ -29,3 +27,16 @@ jobs: - name: Run Acceptance Tests run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... + + - name: Save ZITADEL Logs + if: always() + run: docker compose logs zitadel > .zitadel.log + + - name: Archive ZITADEL Logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: pull-request-tests + path: | + .zitadel.log + retention-days: 30 From f917c194fe1010fef0fc4ac0c689b841de4c3aa5 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 15 May 2023 16:46:29 +0200 Subject: [PATCH 133/260] chore: save zitadel logs --- .github/workflows/pull_request.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 093ce8a3..bdd6c62d 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -29,6 +29,7 @@ jobs: run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... - name: Save ZITADEL Logs + working-directory: acceptance if: always() run: docker compose logs zitadel > .zitadel.log From c0bac510de1e572f2c35169ac5b380354f64e5fa Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 16 May 2023 10:26:13 +0200 Subject: [PATCH 134/260] fix: correct import of idps --- zitadel/v2/org_idp_jwt/resource.go | 3 ++- zitadel/v2/org_idp_oidc/resource.go | 3 ++- zitadel/v2/org_idp_utils/funcs.go | 21 ++++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index 64ef192a..8b6e4c68 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -7,6 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetResource() *schema.Resource { @@ -62,6 +63,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrg()}, } } diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index 9df43783..a3ca27e7 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -7,6 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetResource() *schema.Resource { @@ -77,6 +78,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(clientSecretVar)}, } } diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index d2b58f50..2e9809d5 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -7,9 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -29,6 +30,24 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } +func ImportIDPWithOrg() schema.StateContextFunc { + return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { + id := data.Id() + if id == "" { + return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) + } + parts := strings.SplitN(id, ":", 2) + if len(parts) != 2 || parts[0] == "" || parts[1] == "" { + return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, OrgIDVar, idp_utils.IdpIDVar) + } + if err := data.Set(OrgIDVar, parts[0]); err != nil { + return nil, err + } + data.SetId(parts[1]) + return []*schema.ResourceData{data}, nil + } +} + func ImportIDPWithOrgAndSecret(secretVar string) schema.StateContextFunc { return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { id := data.Id() From b67f3c40eb21c1b6e3eabf7480c4efb1d05336af Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 17:22:30 +0200 Subject: [PATCH 135/260] use docker network --- acceptance/docker-compose.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index cef42f75..2583256e 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -14,6 +14,8 @@ services: depends_on: db: condition: 'service_healthy' + networks: + - zitadel_net db: image: 'cockroachdb/cockroach:v22.2.2' @@ -28,10 +30,17 @@ services: - "26257:26257" - "9090:9090" restart: 'on-failure' + networks: + - zitadel_net wait_for_zitadel: image: curlimages/curl:8.00.1 command: [ "/bin/sh", "-c", "i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0" ] depends_on: - zitadel + networks: + - zitadel_net +networks: + zitadel_net: + driver: bridge From 106a906c97fa1c04deccaca7b52f2a10b33efeea Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 18:56:28 +0200 Subject: [PATCH 136/260] save zitadel logs --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index bdd6c62d..acd91476 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -39,5 +39,5 @@ jobs: with: name: pull-request-tests path: | - .zitadel.log + acceptance/.zitadel.log retention-days: 30 From 38601210c5dea768cfeb86afe9825ba1bc377a96 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 19:43:21 +0200 Subject: [PATCH 137/260] keep machinekey directory --- acceptance/machinekey/.kitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 acceptance/machinekey/.kitkeep diff --git a/acceptance/machinekey/.kitkeep b/acceptance/machinekey/.kitkeep new file mode 100644 index 00000000..e69de29b From 08b097c04c867dcbd9b52f2b1e09197e440118e2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 19:48:28 +0200 Subject: [PATCH 138/260] debug --- .github/workflows/pull_request.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index acd91476..58a4c3bf 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -16,6 +16,14 @@ jobs: with: fetch-depth: 0 + - name: Debug + working-directory: acceptance + run: "ls -la" + + - name: Debug MK + working-directory: acceptance + run: "ls -la machinekey" + - name: Set up ZITADEL working-directory: acceptance run: docker compose run wait_for_zitadel From 96dfda5c3c7de8ce8d17570bf27ba7ead56f62ce Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 19:55:06 +0200 Subject: [PATCH 139/260] run compose as runner --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 58a4c3bf..9738c139 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -26,7 +26,7 @@ jobs: - name: Set up ZITADEL working-directory: acceptance - run: docker compose run wait_for_zitadel + run: docker compose run --user runner wait_for_zitadel - name: Set up Go uses: actions/setup-go@v3 From ae5541dcd4eacdaeff6cd41136ac30fded118792 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 19:57:13 +0200 Subject: [PATCH 140/260] run compose as runner --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 9738c139..339d5f21 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -26,7 +26,7 @@ jobs: - name: Set up ZITADEL working-directory: acceptance - run: docker compose run --user runner wait_for_zitadel + run: docker compose run --user 1001 wait_for_zitadel - name: Set up Go uses: actions/setup-go@v3 From afde316e23f1ef4c750a65c6430c9ee26d1d52fa Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 20:12:58 +0200 Subject: [PATCH 141/260] make machinekey writable --- .github/workflows/pull_request.yaml | 4 ++-- acceptance/docker-compose.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 339d5f21..5d065880 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -18,7 +18,7 @@ jobs: - name: Debug working-directory: acceptance - run: "ls -la" + run: "chmod 777 machinekey" - name: Debug MK working-directory: acceptance @@ -26,7 +26,7 @@ jobs: - name: Set up ZITADEL working-directory: acceptance - run: docker compose run --user 1001 wait_for_zitadel + run: docker compose run wait_for_zitadel - name: Set up Go uses: actions/setup-go@v3 diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 2583256e..f3fc10cf 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -3,7 +3,6 @@ version: '3.8' services: zitadel: user: '$UID' - restart: 'on-failure' image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: @@ -14,6 +13,7 @@ services: depends_on: db: condition: 'service_healthy' + restart: 'never' networks: - zitadel_net @@ -29,7 +29,7 @@ services: ports: - "26257:26257" - "9090:9090" - restart: 'on-failure' + restart: 'never' networks: - zitadel_net From d57791f8e78faef514171d5427d86020b154ce62 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 20:15:28 +0200 Subject: [PATCH 142/260] make machinekey writable --- .github/workflows/pull_request.yaml | 4 ++-- acceptance/docker-compose.yaml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 5d065880..5a1b368a 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -16,9 +16,9 @@ jobs: with: fetch-depth: 0 - - name: Debug + - name: Make Machinekey Directory Writable working-directory: acceptance - run: "chmod 777 machinekey" + run: "chmod -R 777 machinekey" - name: Debug MK working-directory: acceptance diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index f3fc10cf..8f971841 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -13,7 +13,6 @@ services: depends_on: db: condition: 'service_healthy' - restart: 'never' networks: - zitadel_net @@ -29,7 +28,6 @@ services: ports: - "26257:26257" - "9090:9090" - restart: 'never' networks: - zitadel_net From 2e5f38e79ed3b1a43a1ba8d1fc2b9a0329f62421 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 20:31:17 +0200 Subject: [PATCH 143/260] await eventual consistency --- zitadel/v2/helper/test_utils/checks.go | 18 +++++++++++++ zitadel/v2/helper/test_utils/lifecyletest.go | 6 ++--- zitadel/v2/idp_utils/idp_test_utils/checks.go | 25 +++---------------- .../org_idp_test_utils/checks.go | 14 ++++------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index ddce8f5b..563de889 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -1,7 +1,9 @@ package test_utils import ( + "fmt" "regexp" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -14,3 +16,19 @@ func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) } } + +func RetryAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { + return func(state *terraform.State) error { + start := time.Now() + for { + err := check(state) + if err == nil { + return nil + } + if time.Since(start) > time.Minute { + return fmt.Errorf("function failed after retrying for a minute: %w", err) + } + time.Sleep(time.Second) + } + } +} diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 4c350770..2a67c8af 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -33,7 +33,7 @@ func RunLifecyleTest( }, { // Check resource is created Config: initialConfig, Check: resource.ComposeAggregateTestCheckFunc( - checkRemoteProperty(initialProperty), + RetryAMinute(checkRemoteProperty(initialProperty)), CheckStateHasIDSet(frame), ), }, { // Check updating name has a diff @@ -43,7 +43,7 @@ func RunLifecyleTest( PlanOnly: true, }, { // Check remote state can be updated Config: updatedNameConfig, - Check: checkRemoteProperty(updatedProperty), + Check: RetryAMinute(checkRemoteProperty(updatedProperty)), }, } if secretAttribute != "" { @@ -77,7 +77,7 @@ func RunLifecyleTest( } resource.Test(t, resource.TestCase{ ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), - CheckDestroy: checkDestroy, + CheckDestroy: RetryAMinute(checkDestroy), Steps: steps, }) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index 51acfd7c..f9a92f80 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -2,7 +2,6 @@ package idp_test_utils import ( "fmt" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -31,26 +30,10 @@ func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource func CheckDestroy(frame test_utils.InstanceTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - return RetryAMinute(func() error { - err := CheckProviderName(frame)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - }) - } -} - -func RetryAMinute(try func() error) error { - start := time.Now() - for { - err := try() - if err == nil { - return nil - } - if time.Since(start) > time.Minute { - return fmt.Errorf("function failed after retrying for a minute: %w", err) + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) } - time.Sleep(time.Second) + return nil } } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 08e7a899..55a5dcaa 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -3,8 +3,6 @@ package org_idp_test_utils import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -33,12 +31,10 @@ func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.Test func CheckDestroy(frame test_utils.OrgTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - return idp_test_utils.RetryAMinute(func() error { - err := CheckProviderName(frame)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - }) + err := CheckProviderName(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil } } From 5bf8d4dded7bf9f6470766f146328d324797a6eb Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 20:43:41 +0200 Subject: [PATCH 144/260] optimize --- .github/workflows/pull_request.yaml | 16 ++++++++++------ acceptance/docker-compose.yaml | 10 ---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 5a1b368a..a75cb44d 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -12,7 +12,8 @@ jobs: steps: - - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -20,19 +21,22 @@ jobs: working-directory: acceptance run: "chmod -R 777 machinekey" - - name: Debug MK - working-directory: acceptance - run: "ls -la machinekey" - - name: Set up ZITADEL working-directory: acceptance - run: docker compose run wait_for_zitadel + run: docker compose up -d zitadel - name: Set up Go uses: actions/setup-go@v3 with: go-version: 1.19 + - name: Download Go Modules + run: go mod download + + - name: Await ZITADEL + working-directory: acceptance + run: docker compose run wait_for_zitadel + - name: Run Acceptance Tests run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 8f971841..042561d3 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -13,8 +13,6 @@ services: depends_on: db: condition: 'service_healthy' - networks: - - zitadel_net db: image: 'cockroachdb/cockroach:v22.2.2' @@ -28,17 +26,9 @@ services: ports: - "26257:26257" - "9090:9090" - networks: - - zitadel_net wait_for_zitadel: image: curlimages/curl:8.00.1 command: [ "/bin/sh", "-c", "i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0" ] depends_on: - zitadel - networks: - - zitadel_net - -networks: - zitadel_net: - driver: bridge From bd7268ad728344e38d0250e70dc17e4bedf2d566 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 20:49:27 +0200 Subject: [PATCH 145/260] enable access logs --- acceptance/zitadel.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/acceptance/zitadel.yaml b/acceptance/zitadel.yaml index daf4e5d8..231d1311 100644 --- a/acceptance/zitadel.yaml +++ b/acceptance/zitadel.yaml @@ -11,3 +11,8 @@ FirstInstance: Database: Cockroach: Host: db + +Logstore: + Access: + Stdout: + Enabled: true From b60826f35345a18f086f231c6314634254aad644 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 21:04:00 +0200 Subject: [PATCH 146/260] remove flakiness disclaimer --- CONTRIBUTING.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7f9a42e..8d381402 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,10 +6,10 @@ ```bash # export the printed environment variable from the go run ./... -debug command above. E.g. export TF_REATTACH_PROVIDERS='{"registry.terraform.io/zitadel/zitadel":{"Protocol":"grpc","ProtocolVersion":6,"Pid":8123,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin275634719"}}}' - + # go to a directory containing .tf files. cd /my-zitadel-terraform-files - + # apply them terraform apply ``` @@ -29,9 +29,6 @@ Run the accepance tests using the machine key generated by ZITADEL. TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... ``` -The tests are flaky when resources should be cleaned up. -This results in dangling resources. - # Generate Docs 1. Manually maintain files in /templates and /examples From 74623147b044c658d5eba22782a39e97c720d242 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 16 May 2023 21:04:13 +0200 Subject: [PATCH 147/260] add PR template --- .github/pull_request_template.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..ccefeb21 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +### Definition of Ready + +- [ ] Short description of the feature/issue is added in the pr description +- [ ] PR is linked to the corresponding user story +- [ ] Acceptance criteria are met +- [ ] All open todos and follow ups are defined in a new ticket and justified +- [ ] Deviations from the acceptance criteria and design are agreed with the PO and documented. +- [ ] No debug or dead code +- [ ] All non-functional requirements are met +- [ ] The generic lifecycle acceptance test passes for affected resources. +- [ ] Examples are up-to-date and meaningful. The provider version is incremented. +- [ ] Docs are generated. +- [ ] Code is generated where possible. From 4f36d3b8e6438dcb7dd586d50b927e3a401dabcf Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 22 May 2023 09:38:43 +0200 Subject: [PATCH 148/260] Update pull_request_template.md --- .github/pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ccefeb21..f05340dd 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,6 +6,7 @@ - [ ] All open todos and follow ups are defined in a new ticket and justified - [ ] Deviations from the acceptance criteria and design are agreed with the PO and documented. - [ ] No debug or dead code +- [ ] My code has no repetitions - [ ] All non-functional requirements are met - [ ] The generic lifecycle acceptance test passes for affected resources. - [ ] Examples are up-to-date and meaningful. The provider version is incremented. From 8e458fc902a4635782bc62660c14e7ffc3fc79e2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 15:21:35 +0200 Subject: [PATCH 149/260] chore: fix filename typo --- acceptance/machinekey/{.kitkeep => .gitkeep} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename acceptance/machinekey/{.kitkeep => .gitkeep} (100%) diff --git a/acceptance/machinekey/.kitkeep b/acceptance/machinekey/.gitkeep similarity index 100% rename from acceptance/machinekey/.kitkeep rename to acceptance/machinekey/.gitkeep From 78de7825f98f05d12c9a6f4f1a79abfbfb56b729 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 15:41:33 +0200 Subject: [PATCH 150/260] chore: use platform independent 1000 --- CONTRIBUTING.md | 4 ++++ acceptance/docker-compose.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d381402..0a499253 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,10 @@ Run a local ZITADEL instance using docker compose. ```bash +# To have the machine key written with the correct ownership, set your current users ID. +export TF_ZITADEL_UID="$(id -u)" + +# Setup ZITADEL docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel ``` diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 042561d3..3138859b 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: zitadel: - user: '$UID' + user: '$TF_ZITADEL_UID' image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: From 2e8e13f854051538ad734d348d1c0d79f762f876 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 16:25:26 +0200 Subject: [PATCH 151/260] test: await eventual consistency --- zitadel/v2/helper/test_utils/checks.go | 28 ++++++++++++-------- zitadel/v2/helper/test_utils/lifecyletest.go | 6 ++--- zitadel/v2/helper/test_utils/org_frame.go | 25 +++++++++++------ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index 563de889..50e7e800 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -17,18 +17,24 @@ func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { } } -func RetryAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { +func CheckAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { return func(state *terraform.State) error { - start := time.Now() - for { - err := check(state) - if err == nil { - return nil - } - if time.Since(start) > time.Minute { - return fmt.Errorf("function failed after retrying for a minute: %w", err) - } - time.Sleep(time.Second) + return retryAMinute(func() error { + return check(state) + }) + } +} + +func retryAMinute(try func() error) error { + start := time.Now() + for { + err := try() + if err == nil { + return nil + } + if time.Since(start) > time.Minute { + return fmt.Errorf("function failed after retrying for a minute: %w", err) } + time.Sleep(time.Second) } } diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 2a67c8af..c456aa0b 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -33,7 +33,7 @@ func RunLifecyleTest( }, { // Check resource is created Config: initialConfig, Check: resource.ComposeAggregateTestCheckFunc( - RetryAMinute(checkRemoteProperty(initialProperty)), + CheckAMinute(checkRemoteProperty(initialProperty)), CheckStateHasIDSet(frame), ), }, { // Check updating name has a diff @@ -43,7 +43,7 @@ func RunLifecyleTest( PlanOnly: true, }, { // Check remote state can be updated Config: updatedNameConfig, - Check: RetryAMinute(checkRemoteProperty(updatedProperty)), + Check: CheckAMinute(checkRemoteProperty(updatedProperty)), }, } if secretAttribute != "" { @@ -77,7 +77,7 @@ func RunLifecyleTest( } resource.Test(t, resource.TestCase{ ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), - CheckDestroy: RetryAMinute(checkDestroy), + CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, }) } diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index 27b9d61f..84c404e9 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -29,16 +29,25 @@ func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { if err != nil { return nil, err } - org, err := mgmtClient.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: fmt.Sprintf("%s.%s", orgName, domain)}) - orgID := org.GetOrg().GetId() - if status.Code(err) == codes.NotFound { - var newOrg *management.AddOrgResponse - newOrg, err = mgmtClient.AddOrg(baseFrame, &management.AddOrgRequest{Name: orgName}) - orgID = newOrg.GetId() - } - if err != nil { + org, err := mgmtClient.AddOrg(baseFrame, &management.AddOrgRequest{Name: orgName}) + alreadyExists := status.Code(err) == codes.AlreadyExists + if err != nil && !alreadyExists { return nil, err } + orgID := org.GetId() + if alreadyExists { + err := retryAMinute(func() error { + getOrgResp, getOrgErr := mgmtClient.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: fmt.Sprintf("%s.%s", orgName, domain)}) + if getOrgErr != nil { + return getOrgErr + } + orgID = getOrgResp.GetOrg().GetId() + return nil + }) + if err != nil { + return nil, err + } + } mgmtClient, err = helper.GetManagementClient(baseFrame.ClientInfo, orgID) return &OrgTestFrame{ BaseTestFrame: *baseFrame, From 93d6c900b1adb48097f6a1dac532f52780f65dfd Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 16:26:05 +0200 Subject: [PATCH 152/260] chore: pull latest zitadel image --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a499253..a63c642b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,9 @@ Run a local ZITADEL instance using docker compose. # To have the machine key written with the correct ownership, set your current users ID. export TF_ZITADEL_UID="$(id -u)" +# Pull Images +docker compose --file ./acceptance/docker-compose.yaml pull + # Setup ZITADEL docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel ``` From 76e4248527d05519010fcd1c9c221f5a24167dc2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 18:32:07 +0200 Subject: [PATCH 153/260] ZITADEL_DEV_UID --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a63c642b..219ec4dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ Run a local ZITADEL instance using docker compose. ```bash # To have the machine key written with the correct ownership, set your current users ID. -export TF_ZITADEL_UID="$(id -u)" +export ZITADEL_DEV_UID="$(id -u)" # Pull Images docker compose --file ./acceptance/docker-compose.yaml pull From a5ceee120ab5373c1721b08811266a3066e96945 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 23 May 2023 18:32:29 +0200 Subject: [PATCH 154/260] ZITADEL_DEV_UID --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 3138859b..30be8c2d 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: zitadel: - user: '$TF_ZITADEL_UID' + user: '${ZITADEL_DEV_UID}' image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: From 7b09506d0d55d9086ab12052e444e04d4ed4875a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 09:30:33 +0200 Subject: [PATCH 155/260] fix: update zitadel-go --- go.mod | 16 ++++++++-------- go.sum | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 899c4060..da35549e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/zitadel/terraform-provider-zitadel go 1.19 require ( - github.com/envoyproxy/protoc-gen-validate v0.9.1 + github.com/envoyproxy/protoc-gen-validate v1.0.1 github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 @@ -14,9 +14,9 @@ require ( github.com/hashicorp/terraform-plugin-log v0.8.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 - github.com/zitadel/oidc v1.13.2 - github.com/zitadel/zitadel-go/v2 v2.0.13 - golang.org/x/oauth2 v0.7.0 + github.com/zitadel/oidc v1.13.4 + github.com/zitadel/zitadel-go/v2 v2.0.14 + golang.org/x/oauth2 v0.8.0 google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.30.0 ) @@ -31,7 +31,7 @@ require ( github.com/bgentry/speakeasy v0.1.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/go-test/deep v1.0.7 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/schema v1.2.0 // indirect @@ -72,9 +72,9 @@ require ( github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.13.1 // indirect golang.org/x/crypto v0.7.0 // indirect - golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.9.0 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect diff --git a/go.sum b/go.sum index bf0d8abe..074fdb76 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= +github.com/envoyproxy/protoc-gen-validate v1.0.1 h1:kt9FtLiooDc0vbwTLhdg3dyNX1K9Qwa1EK9LcD4jVUQ= +github.com/envoyproxy/protoc-gen-validate v1.0.1/go.mod h1:0vj8bNkYbSTNS2PIyH87KZaeN4x9zpL9Qt8fQC7d+vs= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -131,6 +133,7 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -341,8 +344,11 @@ github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4 github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= github.com/zitadel/oidc v1.13.2 h1:DiwAgHtw1kKcngNzLjgv1/oRL1OjdYf3emEsFzQzraI= github.com/zitadel/oidc v1.13.2/go.mod h1:GUywRhXAiTvvjdRdXblmGknDOeMwrsdMxTRCypi6974= +github.com/zitadel/oidc v1.13.4/go.mod h1:3h2DhUcP02YV6q/CA/BG4yla0o6rXjK+DkJGK/dwJfw= github.com/zitadel/zitadel-go/v2 v2.0.13 h1:TZ44dgEJHtJKsiAW2CbBIYiEjyHSrH8qZ5Wi1qUAP50= github.com/zitadel/zitadel-go/v2 v2.0.13/go.mod h1:T4tAZyYIsq+7dRzfnlJse1b60gjVczHJCMGE5Nqg0ak= +github.com/zitadel/zitadel-go/v2 v2.0.14 h1:+Gp+cb1Qrp752oQnnoetPeTciK0gnEuoygK+S7sRuUM= +github.com/zitadel/zitadel-go/v2 v2.0.14/go.mod h1:apPFRGKTMDAtB2qdC9ELXco/HwyvfS87vD29lfhMRF0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -397,6 +403,7 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -435,6 +442,7 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -443,6 +451,7 @@ golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -502,10 +511,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.4.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/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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= +golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= 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= From 1ab60238b8cfa63c8ca555ce1e9ff9a6d7cac587 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 11:35:27 +0200 Subject: [PATCH 156/260] go mod tidy --- go.sum | 354 +-------------------------------------------------------- 1 file changed, 6 insertions(+), 348 deletions(-) diff --git a/go.sum b/go.sum index 074fdb76..ace72bfb 100644 --- a/go.sum +++ b/go.sum @@ -1,38 +1,4 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= @@ -60,24 +26,12 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= -github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/envoyproxy/protoc-gen-validate v1.0.1 h1:kt9FtLiooDc0vbwTLhdg3dyNX1K9Qwa1EK9LcD4jVUQ= github.com/envoyproxy/protoc-gen-validate v1.0.1/go.mod h1:0vj8bNkYbSTNS2PIyH87KZaeN4x9zpL9Qt8fQC7d+vs= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -96,76 +50,27 @@ github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/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.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -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/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= @@ -196,8 +101,6 @@ github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 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/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= @@ -229,18 +132,14 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKe github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/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/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/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -292,10 +191,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -304,25 +200,18 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -332,32 +221,18 @@ github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37w github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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.3.5/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.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/zitadel/logging v0.3.4/go.mod h1:aPpLQhE+v6ocNK0TWrBrd363hZ95KcI17Q1ixAQwZF0= -github.com/zitadel/oidc v1.13.2 h1:DiwAgHtw1kKcngNzLjgv1/oRL1OjdYf3emEsFzQzraI= -github.com/zitadel/oidc v1.13.2/go.mod h1:GUywRhXAiTvvjdRdXblmGknDOeMwrsdMxTRCypi6974= +github.com/zitadel/oidc v1.13.4 h1:+k2GKqP9Ld9S2MSFlj+KaNsoZ3J9oy+Ezw51EzSFuC8= github.com/zitadel/oidc v1.13.4/go.mod h1:3h2DhUcP02YV6q/CA/BG4yla0o6rXjK+DkJGK/dwJfw= -github.com/zitadel/zitadel-go/v2 v2.0.13 h1:TZ44dgEJHtJKsiAW2CbBIYiEjyHSrH8qZ5Wi1qUAP50= -github.com/zitadel/zitadel-go/v2 v2.0.13/go.mod h1:T4tAZyYIsq+7dRzfnlJse1b60gjVczHJCMGE5Nqg0ak= github.com/zitadel/zitadel-go/v2 v2.0.14 h1:+Gp+cb1Qrp752oQnnoetPeTciK0gnEuoygK+S7sRuUM= github.com/zitadel/zitadel-go/v2 v2.0.14/go.mod h1:apPFRGKTMDAtB2qdC9ELXco/HwyvfS87vD29lfhMRF0= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -368,295 +243,91 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -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/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -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-20220722155255-886fb9371eb4/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= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 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-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= @@ -665,30 +336,17 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-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= -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= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From cab46ed22c8b20310eaeb62e93a8c12fd999122c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 15:02:43 +0200 Subject: [PATCH 157/260] chore: easily create a human admin --- CONTRIBUTING.md | 2 +- acceptance/Dockerfile | 6 ++ acceptance/docker-compose.yaml | 13 ++++ acceptance/setup.sh | 111 +++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 acceptance/Dockerfile create mode 100644 acceptance/setup.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 219ec4dd..fe18984e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ export ZITADEL_DEV_UID="$(id -u)" docker compose --file ./acceptance/docker-compose.yaml pull # Setup ZITADEL -docker compose --file ./acceptance/docker-compose.yaml run wait_for_zitadel +docker compose --file ./acceptance/docker-compose.yaml run setup ``` Run the accepance tests using the machine key generated by ZITADEL. diff --git a/acceptance/Dockerfile b/acceptance/Dockerfile new file mode 100644 index 00000000..a2283d09 --- /dev/null +++ b/acceptance/Dockerfile @@ -0,0 +1,6 @@ +FROM golang:1.19-alpine +RUN apk add curl jq +RUN go install github.com/zitadel/zitadel-tools@v0.4.0 +COPY setup.sh /setup.sh +RUN chmod +x /setup.sh +ENTRYPOINT [ "/setup.sh" ] diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 30be8c2d..29393ddc 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -32,3 +32,16 @@ services: command: [ "/bin/sh", "-c", "i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0" ] depends_on: - zitadel + + setup: + user: '${ZITADEL_DEV_UID}' + container_name: setup + build: . + environment: + KEY: /key/zitadel-admin-sa.json + SERVICE: http://zitadel:8080 + volumes: + - "./machinekey:/key" + depends_on: + wait_for_zitadel: + condition: 'service_completed_successfully' diff --git a/acceptance/setup.sh b/acceptance/setup.sh new file mode 100644 index 00000000..303d9dd4 --- /dev/null +++ b/acceptance/setup.sh @@ -0,0 +1,111 @@ +#!/bin/sh + +set -e + +KEY=${KEY:-./machinekey/zitadel-admin-sa.json} +echo "Using key path ${KEY} to the instance admin service account." + +AUDIENCE=${AUDIENCE:-http://localhost:8080} +echo "Using audience ${AUDIENCE} for which the key is used." + +SERVICE=${SERVICE:-$AUDIENCE} +echo "Using the service ${SERVICE} to connect to ZITADEL. For example in docker compose this can differ from the audience." + +AUDIENCE_HOST="$(echo $AUDIENCE | cut -d/ -f3)" +echo "Deferred the Host header ${AUDIENCE_HOST} which will be sent in requests that ZITADEL then maps to a virtual instance" + +JWT=$(zitadel-tools key2jwt --key ${KEY} --audience ${AUDIENCE}) +echo "Created JWT from Admin service account key ${JWT}" + +TOKEN_RESPONSE=$(curl -s --request POST \ + --url ${SERVICE}/oauth/v2/token \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --header "Host: ${AUDIENCE_HOST}" \ + --data grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \ + --data scope='openid profile email urn:zitadel:iam:org:project:id:zitadel:aud' \ + --data assertion="${JWT}") +echo "Got response from token endpoint:" +echo "${TOKEN_RESPONSE}" | jq + +TOKEN=$(echo -n ${TOKEN_RESPONSE} | jq --raw-output '.access_token') +echo "Extracted access token ${TOKEN}" + +ORG_RESPONSE=$(curl -s --request GET \ + --url ${SERVICE}/admin/v1/orgs/default \ + --header 'Accept: application/json' \ + --header "Authorization: Bearer ${TOKEN}" \ + --header "Host: ${AUDIENCE_HOST}") +echo "Got default org response:" +echo "${ORG_RESPONSE}" | jq + +ORG_ID=$(echo -n ${ORG_RESPONSE} | jq --raw-output '.org.id') +echo "Extracted default org id ${ORG_ID}" + +HUMAN_USER_USERNAME="zitadel-admin@zitadel.localhost" +HUMAN_USER_PASSWORD="Password1!" + +HUMAN_USER_PAYLOAD=$(cat << EOM +{ + "userName": "${HUMAN_USER_USERNAME}", + "profile": { + "firstName": "ZITADEL", + "lastName": "Admin", + "displayName": "ZITADEL Admin", + "preferredLanguage": "en" + }, + "email": { + "email": "zitadel-admin@zitadel.localhost", + "isEmailVerified": true + }, + "password": "${HUMAN_USER_PASSWORD}", + "passwordChangeRequired": false +} +EOM +) +echo "Creating human user" +echo "${HUMAN_USER_PAYLOAD}" | jq + +HUMAN_USER_RESPONSE=$(curl -s --request POST \ + --url ${SERVICE}/management/v1/users/human/_import \ + --header 'Content-Type: application/json' \ + --header 'Accept: application/json' \ + --header "Authorization: Bearer ${TOKEN}" \ + --header "Host: ${AUDIENCE_HOST}" \ + --data-raw "${HUMAN_USER_PAYLOAD}") +echo "Create human user response" +echo "${HUMAN_USER_RESPONSE}" | jq + +if [ "$(echo -n "${HUMAN_USER_RESPONSE}" | jq --raw-output '.code')" == "6" ]; then + echo "admin user already exists" + exit 0 +fi + +HUMAN_USER_ID=$(echo -n ${HUMAN_USER_RESPONSE} | jq --raw-output '.userId') +echo "Extracted human user id ${HUMAN_USER_ID}" + +HUMAN_ADMIN_PAYLOAD=$(cat << EOM +{ + "userId": "${HUMAN_USER_ID}", + "roles": [ + "IAM_OWNER" + ] +} +EOM +) +echo "Granting iam owner to human user" +echo "${HUMAN_ADMIN_PAYLOAD}" | jq + +HUMAN_ADMIN_RESPONSE=$(curl -s --request POST \ + --url ${SERVICE}/admin/v1/members \ + --header 'Content-Type: application/json' \ + --header 'Accept: application/json' \ + --header "Authorization: Bearer ${TOKEN}" \ + --header "Host: ${AUDIENCE_HOST}" \ + --data-raw "${HUMAN_ADMIN_PAYLOAD}") + +echo "Grant iam owner to human user response" +echo "${HUMAN_ADMIN_RESPONSE}" | jq + +echo "You can now log in at ${AUDIENCE}/ui/login" +echo "username: ${HUMAN_USER_USERNAME}" +echo "password: ${HUMAN_USER_PASSWORD}" From 9c2daf553a686d1148245f7822c7f2d5f3526145 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 15:04:16 +0200 Subject: [PATCH 158/260] refactor: improve visibility --- zitadel/v2/helper/test_utils/lifecyletest.go | 2 +- zitadel/v2/login_policy/funcs.go | 1 - zitadel/v2/trigger_actions/resource_test.go | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index c456aa0b..806c01ff 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -11,7 +11,7 @@ import ( func RunLifecyleTest( t *testing.T, frame BaseTestFrame, - resourceFunc func(string, string) string, + resourceFunc func(initialProperty, initialSecret string) string, initialProperty, updatedProperty, initialSecret, updatedSecret string, checkRemoteProperty func(expect string) resource.TestCheckFunc, diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 05e5a101..2799545a 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -50,7 +50,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - if d.HasChanges( allowUsernamePasswordVar, allowRegisterVar, diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 32f04d69..5d8773f9 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -50,15 +50,15 @@ flow_type = "%s" }, initialTriggerType, updatedTriggerType, "", "", - CheckTriggerType(*frame, flowType), - CheckDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), + checkTriggerType(*frame, flowType), + checkDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), nil, nil, "", "", ) } var errTriggerTypeNotFound = errors.New("trigger type not found") -func CheckTriggerType(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { +func checkTriggerType(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { return func(expectTriggerType string) resource.TestCheckFunc { return func(state *terraform.State) error { flowTypeValues := helper.EnumValueMap(trigger_actions.FlowTypes()) @@ -84,10 +84,10 @@ func CheckTriggerType(frame test_utils.OrgTestFrame, flowType string) func(strin } } -func CheckDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []string) resource.TestCheckFunc { +func checkDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []string) resource.TestCheckFunc { return func(state *terraform.State) error { for _, testTriggerType := range testTypes { - if err := CheckTriggerType(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { + if err := checkTriggerType(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { return fmt.Errorf("expected error %v, but got %w", errTriggerTypeNotFound, err) } } From b8d116d342a79c596c2c90249ffc38a1489ca651 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 15:05:13 +0200 Subject: [PATCH 159/260] feat: add zitadel_default_oidc_settings resource --- zitadel/provider.go | 2 + zitadel/v2/default_oidc_settings/const.go | 8 ++ zitadel/v2/default_oidc_settings/funcs.go | 103 ++++++++++++++++++ zitadel/v2/default_oidc_settings/resource.go | 37 +++++++ .../v2/default_oidc_settings/resource_test.go | 56 ++++++++++ 5 files changed, 206 insertions(+) create mode 100644 zitadel/v2/default_oidc_settings/const.go create mode 100644 zitadel/v2/default_oidc_settings/funcs.go create mode 100644 zitadel/v2/default_oidc_settings/resource.go create mode 100644 zitadel/v2/default_oidc_settings/resource_test.go diff --git a/zitadel/provider.go b/zitadel/provider.go index 981e1341..b629d153 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -2,6 +2,7 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" "github.com/hashicorp/terraform-plugin-framework/datasource" fdiag "github.com/hashicorp/terraform-plugin-framework/diag" @@ -305,6 +306,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_google": org_idp_google.GetResource(), "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetResource(), "zitadel_org_idp_ldap": org_idp_ldap.GetResource(), + "zitadel_default_oidc_settings": default_oidc_settings.GetResource(), }, ConfigureContextFunc: providerConfigure, } diff --git a/zitadel/v2/default_oidc_settings/const.go b/zitadel/v2/default_oidc_settings/const.go new file mode 100644 index 00000000..00285d4e --- /dev/null +++ b/zitadel/v2/default_oidc_settings/const.go @@ -0,0 +1,8 @@ +package default_oidc_settings + +const ( + accessTokenLifetimeVar = "access_token_lifetime" + idTokenLifetimeVar = "id_token_lifetime" + refreshTokenIdleExpirationVar = "refresh_token_idle_expiration" + refreshTokenExpirationVar = "refresh_token_expiration" +) diff --git a/zitadel/v2/default_oidc_settings/funcs.go b/zitadel/v2/default_oidc_settings/funcs.go new file mode 100644 index 00000000..5345ab92 --- /dev/null +++ b/zitadel/v2/default_oidc_settings/funcs.go @@ -0,0 +1,103 @@ +package default_oidc_settings + +import ( + "context" + "time" + + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) + +func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Warn(ctx, "default oidc settings cannot be deleted") + return nil +} + +func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + accessTokenLT, err := time.ParseDuration(d.Get(accessTokenLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + idTokenLT, err := time.ParseDuration(d.Get(idTokenLifetimeVar).(string)) + if err != nil { + return diag.FromErr(err) + } + refreshTokenExp, err := time.ParseDuration(d.Get(refreshTokenExpirationVar).(string)) + if err != nil { + return diag.FromErr(err) + } + refreshTokenIdleExp, err := time.ParseDuration(d.Get(refreshTokenIdleExpirationVar).(string)) + if err != nil { + return diag.FromErr(err) + } + resp, err := client.UpdateOIDCSettings(ctx, &admin.UpdateOIDCSettingsRequest{ + AccessTokenLifetime: durationpb.New(accessTokenLT), + IdTokenLifetime: durationpb.New(idTokenLT), + RefreshTokenIdleExpiration: durationpb.New(refreshTokenIdleExp), + RefreshTokenExpiration: durationpb.New(refreshTokenExp), + }) + id := resp.GetDetails().GetResourceOwner() + if err != nil { + if helper.IgnorePreconditionError(err) != nil { + return diag.Errorf("failed to update default oidc settings: %v", err) + } + } + if id == "" { + getResp, getErr := client.GetOIDCSettings(ctx, &admin.GetOIDCSettingsRequest{}) + if getErr != nil { + return diag.Errorf("failed to get new default oidc settings id: %v", getErr) + } + id = getResp.GetSettings().GetDetails().GetResourceOwner() + } + d.SetId(id) + return nil +} + +func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + + resp, err := client.GetOIDCSettings(ctx, &admin.GetOIDCSettingsRequest{}) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } + if err != nil { + return diag.Errorf("failed to get default oidc settings") + } + + set := map[string]interface{}{ + accessTokenLifetimeVar: resp.GetSettings().GetAccessTokenLifetime().AsDuration().String(), + idTokenLifetimeVar: resp.GetSettings().GetIdTokenLifetime().AsDuration().String(), + refreshTokenIdleExpirationVar: resp.GetSettings().GetRefreshTokenIdleExpiration().AsDuration().String(), + refreshTokenExpirationVar: resp.GetSettings().GetRefreshTokenExpiration().AsDuration().String(), + } + + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of default oidc settings: %v", k, err) + } + } + d.SetId(resp.GetSettings().GetDetails().GetResourceOwner()) + return nil +} diff --git a/zitadel/v2/default_oidc_settings/resource.go b/zitadel/v2/default_oidc_settings/resource.go new file mode 100644 index 00000000..b55c0eba --- /dev/null +++ b/zitadel/v2/default_oidc_settings/resource.go @@ -0,0 +1,37 @@ +package default_oidc_settings + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetResource() *schema.Resource { + return &schema.Resource{ + Description: "Resource representing the default login policy.", + Schema: map[string]*schema.Schema{ + accessTokenLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "lifetime duration of access tokens", + }, + idTokenLifetimeVar: { + Type: schema.TypeString, + Required: true, + Description: "lifetime duration of id tokens", + }, + refreshTokenExpirationVar: { + Type: schema.TypeString, + Required: true, + Description: "expiration duration of refresh tokens", + }, + refreshTokenIdleExpirationVar: { + Type: schema.TypeString, + Required: true, + Description: "expiration duration of idle refresh tokens", + }, + }, + CreateContext: update, + UpdateContext: update, + DeleteContext: delete, + ReadContext: read, + } +} diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go new file mode 100644 index 00000000..31859ddc --- /dev/null +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -0,0 +1,56 @@ +package default_oidc_settings_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccDefaultOIDCSettings(t *testing.T) { + resourceName := "zitadel_default_oidc_settings" + initialAccessTokenLifetime := "123h0m0s" + updatedAccessTokenLifetime := "456h0m0s" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(accessTokenLifetime, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + access_token_lifetime = "%s" + id_token_lifetime = "777h0m0s" + refresh_token_idle_expiration = "888h0m0s" + refresh_token_expiration = "999h0m0s" +}`, resourceName, frame.UniqueResourcesID, accessTokenLifetime) + }, + initialAccessTokenLifetime, updatedAccessTokenLifetime, + "", "", + checkAccessTokenLifetime(*frame), + func(state *terraform.State) error { return nil }, + nil, nil, "", "", + ) +} + +func checkAccessTokenLifetime(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expectAccessTokenLifetime string) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetOIDCSettings(frame, &admin.GetOIDCSettingsRequest{}) + if err != nil { + return fmt.Errorf("getting oidc settings failed: %w", err) + } + actual := resp.GetSettings().GetAccessTokenLifetime().AsDuration().String() + if actual != expectAccessTokenLifetime { + return fmt.Errorf("expected access token lifetime %s, but got %s", expectAccessTokenLifetime, actual) + } + return nil + } + } +} From f8c06febfaccd88abf89552d1f36570916c2f7a6 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 15:10:42 +0200 Subject: [PATCH 160/260] feat: add zitadel_default_oidc_settings datasource --- zitadel/provider.go | 2 ++ .../v2/default_oidc_settings/datasource.go | 34 +++++++++++++++++++ zitadel/v2/default_oidc_settings/resource.go | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 zitadel/v2/default_oidc_settings/datasource.go diff --git a/zitadel/provider.go b/zitadel/provider.go index b629d153..9a0de956 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -2,6 +2,7 @@ package zitadel import ( "context" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -221,6 +222,7 @@ func Provider() *schema.Provider { "zitadel_org_idp_google": org_idp_google.GetDatasource(), "zitadel_org_idp_azure_ad": org_idp_azure_ad.GetDatasource(), "zitadel_org_idp_ldap": org_idp_ldap.GetDatasource(), + "zitadel_default_oidc_settings": default_oidc_settings.GetDatasource(), }, Schema: map[string]*schema.Schema{ helper.DomainVar: { diff --git a/zitadel/v2/default_oidc_settings/datasource.go b/zitadel/v2/default_oidc_settings/datasource.go new file mode 100644 index 00000000..56f90814 --- /dev/null +++ b/zitadel/v2/default_oidc_settings/datasource.go @@ -0,0 +1,34 @@ +package default_oidc_settings + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func GetDatasource() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing the default oidc settings.", + Schema: map[string]*schema.Schema{ + accessTokenLifetimeVar: { + Type: schema.TypeString, + Computed: true, + Description: "lifetime duration of access tokens", + }, + idTokenLifetimeVar: { + Type: schema.TypeString, + Computed: true, + Description: "lifetime duration of id tokens", + }, + refreshTokenExpirationVar: { + Type: schema.TypeString, + Computed: true, + Description: "expiration duration of refresh tokens", + }, + refreshTokenIdleExpirationVar: { + Type: schema.TypeString, + Computed: true, + Description: "expiration duration of idle refresh tokens", + }, + }, + ReadContext: read, + } +} diff --git a/zitadel/v2/default_oidc_settings/resource.go b/zitadel/v2/default_oidc_settings/resource.go index b55c0eba..08d7f6a9 100644 --- a/zitadel/v2/default_oidc_settings/resource.go +++ b/zitadel/v2/default_oidc_settings/resource.go @@ -6,7 +6,7 @@ import ( func GetResource() *schema.Resource { return &schema.Resource{ - Description: "Resource representing the default login policy.", + Description: "Resource representing the default oidc settings.", Schema: map[string]*schema.Schema{ accessTokenLifetimeVar: { Type: schema.TypeString, From 9176aae36d766c5ed265011f457e1fd3182269f2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 15:30:36 +0200 Subject: [PATCH 161/260] docs: add templates and examples --- .../data-sources/default_oidc_settings.tf | 5 +++++ .../provider/resources/default_oidc_settings.tf | 6 ++++++ .../data-sources/default_oidc_settings.tmpl | 16 ++++++++++++++++ templates/resources/default_oidc_settings.tmpl | 16 ++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 examples/provider/data-sources/default_oidc_settings.tf create mode 100644 examples/provider/resources/default_oidc_settings.tf create mode 100644 templates/data-sources/default_oidc_settings.tmpl create mode 100644 templates/resources/default_oidc_settings.tmpl diff --git a/examples/provider/data-sources/default_oidc_settings.tf b/examples/provider/data-sources/default_oidc_settings.tf new file mode 100644 index 00000000..6ff3b5ba --- /dev/null +++ b/examples/provider/data-sources/default_oidc_settings.tf @@ -0,0 +1,5 @@ +data zitadel_default_oidc_settings oidc_settings {} + +output oidc_settings { + value = data.zitadel_default_oidc_settings.oidc_settings +} diff --git a/examples/provider/resources/default_oidc_settings.tf b/examples/provider/resources/default_oidc_settings.tf new file mode 100644 index 00000000..d81ecb04 --- /dev/null +++ b/examples/provider/resources/default_oidc_settings.tf @@ -0,0 +1,6 @@ +resource zitadel_default_oidc_settings oidc_settings { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" + refresh_token_idle_expiration = "2160h0m0s" +} diff --git a/templates/data-sources/default_oidc_settings.tmpl b/templates/data-sources/default_oidc_settings.tmpl new file mode 100644 index 00000000..be8aa77e --- /dev/null +++ b/templates/data-sources/default_oidc_settings.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/data-sources/default_oidc_settings.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/default_oidc_settings.tmpl b/templates/resources/default_oidc_settings.tmpl new file mode 100644 index 00000000..3d377910 --- /dev/null +++ b/templates/resources/default_oidc_settings.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_oidc_settings.tf" }} + +{{ .SchemaMarkdown | trimspace }} From c4a943da195622f9db8943ef084a4adc3f02ee5e Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 2 Jun 2023 17:46:30 +0200 Subject: [PATCH 162/260] docs: generate docs --- docs/resources/application_oidc.md | 2 +- docs/resources/default_login_texts.md | 298 +----------------- docs/resources/default_oidc_settings.md | 35 ++ .../default_password_change_message_text.md | 18 +- .../resources/password_change_message_text.md | 19 +- ...ngs.tmpl => default_oidc_settings.md.tmpl} | 0 6 files changed, 45 insertions(+), 327 deletions(-) create mode 100644 docs/resources/default_oidc_settings.md rename templates/resources/{default_oidc_settings.tmpl => default_oidc_settings.md.tmpl} (100%) diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 3569be6b..8a0202fa 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -39,7 +39,7 @@ resource zitadel_application_oidc application_oidc { ### Required -- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN +- `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_DEVICE_CODE - `name` (String) Name of the application - `org_id` (String) orgID of the application - `project_id` (String) ID of the project diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md index db08f05d..33be1cf4 100644 --- a/docs/resources/default_login_texts.md +++ b/docs/resources/default_login_texts.md @@ -3,306 +3,12 @@ page_title: "zitadel_default_login_texts Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_default_login_texts (Resource) -## Example Usage - -```terraform -resource zitadel_default_login_texts login_texts_en { - language = "en" - - email_verification_done_text = { - cancel_button_text = "example" - description = "example" - login_button_text = "example" - next_button_text = "example" - title = "example" - } - email_verification_text = { - code_label = "example" - description = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - external_registration_user_overview_text = { - back_button_text = "example" - description = "example" - email_label = "example" - firstname_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - nickname_label = "example" - phone_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - external_user_not_found_text = { - auto_register_button_text = "example" - description = "example" - link_button_text = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - } - footer_text = { - help = "example" - privacy_policy = "example" - tos = "example" - } - init_mfa_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_mfa_otp_text = { - cancel_button_text = "example" - code_label = "example" - description = "example" - description_otp = "example" - next_button_text = "example" - secret_label = "example" - title = "example" - } - init_mfa_prompt_text = { - description = "example" - next_button_text = "example" - otp_option = "example" - skip_button_text = "example" - title = "example" - u2f_option = "example" - } - init_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - init_password_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_password_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - initialize_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - initialize_user_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - linking_user_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - login_text = { - description = "example" - description_linking_process = "example" - external_user_description = "example" - login_name_label = "example" - login_name_placeholder = "example" - next_button_text = "example" - register_button_text = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - user_name_placeholder = "example" - } - logout_text = { - description = "example" - login_button_text = "example" - title = "example" - } - mfa_providers_text = { - choose_other = "example" - otp = "example" - u2f = "example" - } - password_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_change_text = { - cancel_button_text = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - old_password_label = "example" - title = "example" - } - password_reset_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_text = { - back_button_text = "example" - confirmation = "example" - description = "example" - has_lowercase = "example" - has_number = "example" - has_symbol = "example" - has_uppercase = "example" - min_length = "example" - next_button_text = "example" - password_label = "example" - reset_link_text = "example" - title = "example" - } - passwordless_prompt_text = { - description = "example" - description_init = "example" - next_button_text = "example" - passwordless_button_text = "example" - skip_button_text = "example" - title = "example" - } - passwordless_registration_done_text = { - cancel_button_text = "example" - description = "example" - description_close = "example" - next_button_text = "example" - title = "example" - } - passwordless_registration_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - passwordless_text = { - description = "example" - error_retry = "example" - login_with_pw_button_text = "example" - not_supported = "example" - title = "example" - validate_token_button_text = "example" - } - registration_option_text = { - description = "example" - external_login_description = "example" - title = "example" - user_name_button_text = "example" - } - registration_org_text = { - description = "example" - email_label = "example" - firstname_label = "example" - lastname_label = "example" - orgname_label = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - save_button_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - registration_user_text = { - back_button_text = "example" - description = "example" - description_org_register = "example" - email_label = "example" - firstname_label = "example" - gender_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - select_account_text = { - description = "example" - description_linking_process = "example" - other_user = "example" - session_state_active = "example" - session_state_inactive = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - } - success_login_text = { - auto_redirect_description = "example" - next_button_text = "example" - redirected_description = "example" - title = "example" - } - username_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - username_change_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - username_label = "example" - } - verify_mfa_otp_text = { - code_label = "example" - description = "example" - next_button_text = "example" - title = "example" - } - verify_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - title = "example" - validate_token_text = "example" - } -} -``` @@ -809,3 +515,5 @@ Optional: - `not_supported` (String) - `title` (String) - `validate_token_text` (String) + + diff --git a/docs/resources/default_oidc_settings.md b/docs/resources/default_oidc_settings.md new file mode 100644 index 00000000..0251eb3a --- /dev/null +++ b/docs/resources/default_oidc_settings.md @@ -0,0 +1,35 @@ +--- +page_title: "zitadel_default_oidc_settings Resource - terraform-provider-zitadel" +subcategory: "" +description: |- + Resource representing the default oidc settings. +--- + +# zitadel_default_oidc_settings (Resource) + +Resource representing the default oidc settings. + +## Example Usage + +```terraform +resource zitadel_default_oidc_settings oidc_settings { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" + refresh_token_idle_expiration = "2160h0m0s" +} +``` + + +## Schema + +### Required + +- `access_token_lifetime` (String) lifetime duration of access tokens +- `id_token_lifetime` (String) lifetime duration of id tokens +- `refresh_token_expiration` (String) expiration duration of refresh tokens +- `refresh_token_idle_expiration` (String) expiration duration of idle refresh tokens + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md index 2ec195dc..c06e4c43 100644 --- a/docs/resources/default_password_change_message_text.md +++ b/docs/resources/default_password_change_message_text.md @@ -3,27 +3,13 @@ page_title: "zitadel_default_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_default_password_change_message_text (Resource) -## Example Usage - -```terraform -resource zitadel_default_password_change_message_text password_change_en { - language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -} -``` @@ -46,3 +32,5 @@ resource zitadel_default_password_change_message_text password_change_en { ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index be8a789e..3e45b8f0 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -3,28 +3,13 @@ page_title: "zitadel_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- - + --- # zitadel_password_change_message_text (Resource) -## Example Usage - -```terraform -resource zitadel_password_change_message_text password_change_en { - org_id = zitadel_org.org.id - language = "en" - title = "title example" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -} -``` @@ -48,3 +33,5 @@ resource zitadel_password_change_message_text password_change_en { ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/templates/resources/default_oidc_settings.tmpl b/templates/resources/default_oidc_settings.md.tmpl similarity index 100% rename from templates/resources/default_oidc_settings.tmpl rename to templates/resources/default_oidc_settings.md.tmpl From 2199fe49f788ce7b2f1ce9d488535b58e27f0eaa Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 17:58:07 +0200 Subject: [PATCH 163/260] docs: fix datasource file ending --- docs/data-sources/default_oidc_settings.md | 31 +++++++++++++++++++ ...ngs.tmpl => default_oidc_settings.md.tmpl} | 0 2 files changed, 31 insertions(+) create mode 100644 docs/data-sources/default_oidc_settings.md rename templates/data-sources/{default_oidc_settings.tmpl => default_oidc_settings.md.tmpl} (100%) diff --git a/docs/data-sources/default_oidc_settings.md b/docs/data-sources/default_oidc_settings.md new file mode 100644 index 00000000..85366afa --- /dev/null +++ b/docs/data-sources/default_oidc_settings.md @@ -0,0 +1,31 @@ +--- +page_title: "zitadel_default_oidc_settings Data Source - terraform-provider-zitadel" +subcategory: "" +description: |- + Datasource representing the default oidc settings. +--- + +# zitadel_default_oidc_settings (Data Source) + +Datasource representing the default oidc settings. + +## Example Usage + +```terraform +data zitadel_default_oidc_settings oidc_settings {} + +output oidc_settings { + value = data.zitadel_default_oidc_settings.oidc_settings +} +``` + + +## Schema + +### Read-Only + +- `access_token_lifetime` (String) lifetime duration of access tokens +- `id` (String) The ID of this resource. +- `id_token_lifetime` (String) lifetime duration of id tokens +- `refresh_token_expiration` (String) expiration duration of refresh tokens +- `refresh_token_idle_expiration` (String) expiration duration of idle refresh tokens diff --git a/templates/data-sources/default_oidc_settings.tmpl b/templates/data-sources/default_oidc_settings.md.tmpl similarity index 100% rename from templates/data-sources/default_oidc_settings.tmpl rename to templates/data-sources/default_oidc_settings.md.tmpl From 1106b7c545aca17db1ce7ea4e0d216de442bc041 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 18:05:34 +0200 Subject: [PATCH 164/260] docs: add default login texts template --- docs/resources/default_login_texts.md | 298 +++++++++++++++++- .../resources/default_login_texts.md.tmpl | 16 + 2 files changed, 310 insertions(+), 4 deletions(-) create mode 100644 templates/resources/default_login_texts.md.tmpl diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md index 33be1cf4..8fc0784f 100644 --- a/docs/resources/default_login_texts.md +++ b/docs/resources/default_login_texts.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_default_login_texts Resource - terraform-provider-zitadel" subcategory: "" description: |- @@ -10,7 +9,300 @@ description: |- - +## Example Usage + +```terraform +resource zitadel_default_login_texts login_texts_en { + language = "en" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "example" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +} +``` ## Schema @@ -515,5 +807,3 @@ Optional: - `not_supported` (String) - `title` (String) - `validate_token_text` (String) - - diff --git a/templates/resources/default_login_texts.md.tmpl b/templates/resources/default_login_texts.md.tmpl new file mode 100644 index 00000000..094156bf --- /dev/null +++ b/templates/resources/default_login_texts.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_login_texts.tf" }} + +{{ .SchemaMarkdown | trimspace }} From c56b4432a2dea6eda6f51882fc7a275d6f20c81d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 2 Jun 2023 18:10:44 +0200 Subject: [PATCH 165/260] docs: add password change message templates --- .../default_password_change_message_text.md | 17 ++++++++++++++--- docs/resources/password_change_message_text.md | 18 +++++++++++++++--- ...efault_password_change_message_text.md.tmpl | 16 ++++++++++++++++ .../password_change_message_text.md.tmpl | 16 ++++++++++++++++ 4 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 templates/resources/default_password_change_message_text.md.tmpl create mode 100644 templates/resources/password_change_message_text.md.tmpl diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md index c06e4c43..50309af5 100644 --- a/docs/resources/default_password_change_message_text.md +++ b/docs/resources/default_password_change_message_text.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_default_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- @@ -10,7 +9,21 @@ description: |- +## Example Usage +```terraform +resource zitadel_default_password_change_message_text password_change_en { + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` ## Schema @@ -32,5 +45,3 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index 3e45b8f0..40dbcf1f 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "zitadel_password_change_message_text Resource - terraform-provider-zitadel" subcategory: "" description: |- @@ -10,7 +9,22 @@ description: |- +## Example Usage +```terraform +resource zitadel_password_change_message_text password_change_en { + org_id = zitadel_org.org.id + language = "en" + + title = "title example" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +} +``` ## Schema @@ -33,5 +47,3 @@ description: |- ### Read-Only - `id` (String) The ID of this resource. - - diff --git a/templates/resources/default_password_change_message_text.md.tmpl b/templates/resources/default_password_change_message_text.md.tmpl new file mode 100644 index 00000000..4fa4e210 --- /dev/null +++ b/templates/resources/default_password_change_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/default_password_change_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/password_change_message_text.md.tmpl b/templates/resources/password_change_message_text.md.tmpl new file mode 100644 index 00000000..5a150cfb --- /dev/null +++ b/templates/resources/password_change_message_text.md.tmpl @@ -0,0 +1,16 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +## Example Usage + +{{ tffile "examples/provider/resources/password_change_message_text.tf" }} + +{{ .SchemaMarkdown | trimspace }} From 704d9b421a8e3a4affeba97697e71bf581958a0e Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Wed, 21 Jun 2023 14:39:51 +0200 Subject: [PATCH 166/260] fix: correct update on application when attributes changed --- zitadel/v2/application_oidc/funcs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index 15eb9c34..19c6ddf1 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -63,10 +63,14 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChanges(redirectURIsVar, + if d.HasChanges( + redirectURIsVar, + responseTypesVar, + grantTypesVar, appTypeVar, authMethodTypeVar, postLogoutRedirectURIsVar, + versionVar, devModeVar, accessTokenTypeVar, accessTokenRoleAssertionVar, From 813425abb6fc48955a0296727c609c42fbdf6fd1 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 10 Jul 2023 14:59:08 +0200 Subject: [PATCH 167/260] test 2 resources --- zitadel/v2/action/resource_test.go | 71 ++++++++++++++++++++++++ zitadel/v2/app_key/resource_test.go | 84 +++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 zitadel/v2/action/resource_test.go create mode 100644 zitadel/v2/app_key/resource_test.go diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go new file mode 100644 index 00000000..7b78b9bf --- /dev/null +++ b/zitadel/v2/action/resource_test.go @@ -0,0 +1,71 @@ +package action_test + +import ( + "fmt" + "testing" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELAction(t *testing.T) { + resourceName := "zitadel_action" + initialProperty := "initialproperty" + updatedProperty := "updatedproperty" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "testaction" + script = "%s" + timeout = "10s" + allowed_to_fail = true +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + checkDestroy(frame), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + actual := remoteResource.GetAction().GetScript() + if actual != expect { + return fmt.Errorf("expected %s, actual: %s", expect, actual) + } + return nil + } + } +} + +func checkDestroy(frame *test_utils.OrgTestFrame) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := checkRemoteProperty(frame)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go new file mode 100644 index 00000000..892820bf --- /dev/null +++ b/zitadel/v2/app_key/resource_test.go @@ -0,0 +1,84 @@ +package app_key_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELAppKey(t *testing.T) { + resourceName := "zitadel_application_key" + initialProperty := "2500-01-01T08:45:00Z" + updatedProperty := "2501-01-01T08:45:00Z" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + app, err := frame.AddOIDCApp(frame, &management.AddOIDCAppRequest{ + ProjectId: project.GetId(), + Name: frame.UniqueResourcesID, + AuthMethodType: app.OIDCAuthMethodType_OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, + }) + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + app_id = "%s" + key_type = "KEY_TYPE_JSON" + expiration_date = "%s" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), app.GetAppId(), configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, project.GetId(), app.GetAppId()), + checkDestroy(frame, project.GetId(), app.GetAppId()), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteResource, err := frame.GetAppKey(frame, &management.GetAppKeyRequest{KeyId: rs.Primary.ID, ProjectId: projectId, AppId: appId}) + if err != nil { + return err + } + actual := remoteResource.GetKey().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") + if actual != expect { + return fmt.Errorf("expected %s, actual: %s", expect, actual) + } + return nil + } + } +} + +func checkDestroy(frame *test_utils.OrgTestFrame, projectId, appId string) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := checkRemoteProperty(frame, projectId, appId)("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} From bb9b24140f13b98e35b9f6e542b106cd4e14066e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 10 Jul 2023 15:14:37 +0200 Subject: [PATCH 168/260] dry --- zitadel/v2/action/resource_test.go | 15 +-------------- zitadel/v2/app_key/resource_test.go | 18 ++---------------- zitadel/v2/helper/test_utils/checks.go | 13 +++++++++++++ 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 7b78b9bf..62c688e2 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -4,9 +4,6 @@ import ( "fmt" "testing" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" @@ -38,7 +35,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame), - checkDestroy(frame), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame)), nil, nil, "", "", ) } @@ -59,13 +56,3 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.T } } } - -func checkDestroy(frame *test_utils.OrgTestFrame) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := checkRemoteProperty(frame)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - } -} diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 892820bf..94ce144c 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -4,13 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" @@ -51,7 +47,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame, project.GetId(), app.GetAppId()), - checkDestroy(frame, project.GetId(), app.GetAppId()), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId())), nil, nil, "", "", ) } @@ -72,13 +68,3 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string } } } - -func checkDestroy(frame *test_utils.OrgTestFrame, projectId, appId string) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := checkRemoteProperty(frame, projectId, appId)("")(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) - } - return nil - } -} diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index 50e7e800..ca575dc7 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -5,6 +5,9 @@ import ( "regexp" "time" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -25,6 +28,16 @@ func CheckAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { } } +func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(string) resource.TestCheckFunc) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := checkRemoteProperty("")(state) + if status.Code(err) != codes.NotFound { + return fmt.Errorf("expected not found error but got: %w", err) + } + return nil + } +} + func retryAMinute(try func() error) error { start := time.Now() for { From 7ac90f798db3eb97b0f9c56d392c9297fbf9af56 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 10 Jul 2023 16:44:28 +0200 Subject: [PATCH 169/260] test v6 resources --- zitadel/v2/application_api/resource_test.go | 63 +++++++++++++++ zitadel/v2/application_oidc/resource_test.go | 76 +++++++++++++++++++ .../resource_test.go | 61 +++++++++++++++ zitadel/v2/helper/test_utils/base_frame.go | 61 ++++++++++----- zitadel/v2/helper/test_utils/lifecyletest.go | 11 ++- .../helper/test_utils/provider_factories.go | 11 --- 6 files changed, 251 insertions(+), 32 deletions(-) create mode 100644 zitadel/v2/application_api/resource_test.go create mode 100644 zitadel/v2/application_oidc/resource_test.go create mode 100644 zitadel/v2/default_domain_claimed_message_text/resource_test.go delete mode 100644 zitadel/v2/helper/test_utils/provider_factories.go diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go new file mode 100644 index 00000000..fda938ed --- /dev/null +++ b/zitadel/v2/application_api/resource_test.go @@ -0,0 +1,63 @@ +package application_api_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELAppAPI(t *testing.T) { + resourceName := "zitadel_application_api" + initialProperty := "initialname" + updatedProperty := "updatedname" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + name = "%s" + auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, project.GetId()), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) + if err != nil { + return err + } + actual := remoteResource.GetApp().GetName() + if actual != expect { + return fmt.Errorf("expected %s, actual: %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go new file mode 100644 index 00000000..4d4b4803 --- /dev/null +++ b/zitadel/v2/application_oidc/resource_test.go @@ -0,0 +1,76 @@ +package application_oidc_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELAppOIDC(t *testing.T) { + resourceName := "zitadel_application_oidc" + initialProperty := "initialname" + updatedProperty := "updatedname" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + name = "%s" + redirect_uris = ["https://localhost.com"] + response_types = ["OIDC_RESPONSE_TYPE_CODE"] + grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] + post_logout_redirect_uris = ["https://localhost.com"] + app_type = "OIDC_APP_TYPE_WEB" + auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" + version = "OIDC_VERSION_1_0" + clock_skew = "0s" + dev_mode = true + access_token_type = "OIDC_TOKEN_TYPE_BEARER" + access_token_role_assertion = false + id_token_role_assertion = false + id_token_userinfo_assertion = false + additional_origins = [] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, project.GetId()), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) + if err != nil { + return err + } + actual := remoteResource.GetApp().GetName() + if actual != expect { + return fmt.Errorf("expected %s, actual: %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go new file mode 100644 index 00000000..d75c5234 --- /dev/null +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -0,0 +1,61 @@ +package default_domain_claimed_message_text_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELDefaultDomainClaimedMessageTextSameLanguage(t *testing.T) { + resourceName := "zitadel_default_domain_claimed_message_text" + initialProperty := "initialtitle" + updatedProperty := "updatedtitle" + language := "en" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + language = "%s" + title = "%s" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +}`, resourceName, frame.UniqueResourcesID, language, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, language), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, language)), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetCustomDomainClaimedMessageText(frame, &admin.GetCustomDomainClaimedMessageTextRequest{Language: lang}) + if err != nil { + return err + } + actual := remoteResource.GetCustomText().GetTitle() + if actual != expect { + return fmt.Errorf("expected %s, actual: %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 64275d38..6cab24cf 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -5,10 +5,16 @@ import ( "fmt" "os" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + + "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/zitadel/terraform-provider-zitadel/zitadel" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -21,10 +27,10 @@ const ( type BaseTestFrame struct { context.Context - ConfiguredProvider *schema.Provider - ClientInfo *helper.ClientInfo - ProviderSnippet, UniqueResourcesID string - TerraformName string + upgradedV5ProviderFactory, v6ProviderFactory func() (tfprotov6.ProviderServer, error) + ClientInfo *helper.ClientInfo + ProviderSnippet, UniqueResourcesID string + TerraformName string } func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { @@ -37,27 +43,46 @@ func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { "port": port, "token": tokenPath, })) - providerSnippet := fmt.Sprintf(` -provider "zitadel" { + if diag.HasError() { + return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) + } + + providerConfigSnippet := fmt.Sprintf(` domain = "%s" insecure = "%t" port = "%s" token = "%s" -} `, domain, insecure, port, tokenPath) - if diag.HasError() { - return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) - } + + providerSnippet := fmt.Sprintf(` +provider "zitadel" { + %s +} + +provider "upgraded-v5" { + %s +} +`, providerConfigSnippet, providerConfigSnippet) clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) uniqueID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) terraformName := fmt.Sprintf("%s.%s", resourceType, uniqueID) + upgradedV5Provider, err := tf5to6server.UpgradeServer(ctx, zitadel.Provider().GRPCProvider) + if err != nil { + return nil, err + } + return &BaseTestFrame{ - Context: ctx, - ConfiguredProvider: zitadelProvider, - ProviderSnippet: providerSnippet, - ClientInfo: clientInfo, - UniqueResourcesID: uniqueID, - TerraformName: terraformName, + Context: ctx, + upgradedV5ProviderFactory: func() (tfprotov6.ProviderServer, error) { + return upgradedV5Provider, nil + }, + v6ProviderFactory: func() (tfprotov6.ProviderServer, error) { + return providerserver.NewProtocol6(zitadel.NewProviderPV6())(), nil + }, + ProviderSnippet: providerSnippet, + ClientInfo: clientInfo, + UniqueResourcesID: uniqueID, + TerraformName: terraformName, }, nil } diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 806c01ff..494f7402 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -5,6 +5,8 @@ import ( "regexp" "testing" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -76,8 +78,11 @@ func RunLifecyleTest( }) } resource.Test(t, resource.TestCase{ - ProviderFactories: ZitadelProviderFactories(frame.ConfiguredProvider), - CheckDestroy: CheckAMinute(checkDestroy), - Steps: steps, + CheckDestroy: CheckAMinute(checkDestroy), + Steps: steps, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "upgraded-v5": frame.upgradedV5ProviderFactory, + "zitadel": frame.v6ProviderFactory, + }, }) } diff --git a/zitadel/v2/helper/test_utils/provider_factories.go b/zitadel/v2/helper/test_utils/provider_factories.go deleted file mode 100644 index bb110c6d..00000000 --- a/zitadel/v2/helper/test_utils/provider_factories.go +++ /dev/null @@ -1,11 +0,0 @@ -package test_utils - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -func ZitadelProviderFactories(provider *schema.Provider) map[string]func() (*schema.Provider, error) { - return map[string]func() (*schema.Provider, error){ - "zitadel": func() (*schema.Provider, error) { - return provider, nil - }, - } -} From 9a8685811adc643154798810abdb0f64d44513a2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 12 Jul 2023 15:28:52 +0200 Subject: [PATCH 170/260] test v6 provider resource --- zitadel/v2/action/resource_test.go | 1 + zitadel/v2/app_key/resource_test.go | 1 + zitadel/v2/application_api/resource_test.go | 1 + zitadel/v2/application_oidc/resource_test.go | 1 + .../resource_test.go | 5 +- .../v2/default_oidc_settings/resource_test.go | 1 + zitadel/v2/helper/test_utils/base_frame.go | 61 ++++++++----------- zitadel/v2/helper/test_utils/checks.go | 7 ++- zitadel/v2/helper/test_utils/lifecyletest.go | 15 ++--- .../idp_utils/idp_test_utils/lifecyletest.go | 1 + .../org_idp_test_utils/lifecyletest.go | 1 + zitadel/v2/trigger_actions/resource_test.go | 1 + 12 files changed, 46 insertions(+), 50 deletions(-) diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 62c688e2..cf66d685 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -35,6 +35,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame)), nil, nil, "", "", ) diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 94ce144c..c6985e15 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -47,6 +47,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame, project.GetId(), app.GetAppId()), + test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId())), nil, nil, "", "", ) diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index fda938ed..6f339dc7 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame, project.GetId()), + test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), nil, nil, "", "", ) diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 4d4b4803..80df82a6 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -53,6 +53,7 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame, project.GetId()), + test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), nil, nil, "", "", ) diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index d75c5234..0ef2ff60 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -2,6 +2,7 @@ package default_domain_claimed_message_text_test import ( "fmt" + "regexp" "testing" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" @@ -39,7 +40,9 @@ resource "%s" "%s" { initialProperty, updatedProperty, "", "", checkRemoteProperty(frame, language), - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, language)), + regexp.MustCompile(`^en$`), + // When deleted, the default should be returned + checkRemoteProperty(frame, language)("ZITADEL - Domain has been claimed"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 31859ddc..131a4272 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -34,6 +34,7 @@ resource "%s" "%s" { initialAccessTokenLifetime, updatedAccessTokenLifetime, "", "", checkAccessTokenLifetime(*frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, func(state *terraform.State) error { return nil }, nil, nil, "", "", ) diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 6cab24cf..1442b3ff 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -6,14 +6,10 @@ import ( "os" "github.com/hashicorp/terraform-plugin-framework/providerserver" - - "github.com/hashicorp/terraform-plugin-mux/tf5to6server" - + "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tfprotov6" - - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/terraform-provider-zitadel/zitadel" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -27,10 +23,11 @@ const ( type BaseTestFrame struct { context.Context - upgradedV5ProviderFactory, v6ProviderFactory func() (tfprotov6.ProviderServer, error) - ClientInfo *helper.ClientInfo - ProviderSnippet, UniqueResourcesID string - TerraformName string + ClientInfo *helper.ClientInfo + ProviderSnippet, UniqueResourcesID string + TerraformName string + v6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error) + v5ProviderFactories map[string]func() (tfprotov5.ProviderServer, error) } func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { @@ -46,43 +43,33 @@ func NewBaseTestFrame(resourceType string) (*BaseTestFrame, error) { if diag.HasError() { return nil, fmt.Errorf("unknown error configuring the test provider: %v", diag) } - - providerConfigSnippet := fmt.Sprintf(` + providerSnippet := fmt.Sprintf(` +provider "zitadel" { domain = "%s" insecure = "%t" port = "%s" token = "%s" -`, domain, insecure, port, tokenPath) - - providerSnippet := fmt.Sprintf(` -provider "zitadel" { - %s -} - -provider "upgraded-v5" { - %s } -`, providerConfigSnippet, providerConfigSnippet) +`, domain, insecure, port, tokenPath) clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) uniqueID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) terraformName := fmt.Sprintf("%s.%s", resourceType, uniqueID) - - upgradedV5Provider, err := tf5to6server.UpgradeServer(ctx, zitadel.Provider().GRPCProvider) - if err != nil { - return nil, err - } - - return &BaseTestFrame{ - Context: ctx, - upgradedV5ProviderFactory: func() (tfprotov6.ProviderServer, error) { - return upgradedV5Provider, nil - }, - v6ProviderFactory: func() (tfprotov6.ProviderServer, error) { - return providerserver.NewProtocol6(zitadel.NewProviderPV6())(), nil - }, + frame := &BaseTestFrame{ + Context: ctx, ProviderSnippet: providerSnippet, ClientInfo: clientInfo, UniqueResourcesID: uniqueID, TerraformName: terraformName, - }, nil + } + _, v5 := zitadelProvider.ResourcesMap[resourceType] + if v5 { + frame.v5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){"zitadel": func() (tfprotov5.ProviderServer, error) { + return zitadel.Provider().GRPCProvider(), nil + }} + } else { + frame.v6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){"zitadel": func() (tfprotov6.ProviderServer, error) { + return providerserver.NewProtocol6(zitadel.NewProviderPV6())(), nil + }} + } + return frame, nil } diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index ca575dc7..84d4159e 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -12,9 +12,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func CheckStateHasIDSet(frame BaseTestFrame) resource.TestCheckFunc { - // ZITADEL IDs have thirteen digits - idPattern := regexp.MustCompile(`\d{13}`) +// ZITADEL IDs have thirteen digits +var ZITADEL_GENERATED_ID_REGEX = regexp.MustCompile(`\d{13}`) + +func CheckStateHasIDSet(frame BaseTestFrame, idPattern *regexp.Regexp) resource.TestCheckFunc { return func(state *terraform.State) error { return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) } diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 494f7402..41faa1ae 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -5,8 +5,6 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -17,6 +15,7 @@ func RunLifecyleTest( initialProperty, updatedProperty, initialSecret, updatedSecret string, checkRemoteProperty func(expect string) resource.TestCheckFunc, + idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, wrongImportID, @@ -36,7 +35,7 @@ func RunLifecyleTest( Config: initialConfig, Check: resource.ComposeAggregateTestCheckFunc( CheckAMinute(checkRemoteProperty(initialProperty)), - CheckStateHasIDSet(frame), + CheckStateHasIDSet(frame, idPattern), ), }, { // Check updating name has a diff Config: updatedNameConfig, @@ -78,11 +77,9 @@ func RunLifecyleTest( }) } resource.Test(t, resource.TestCase{ - CheckDestroy: CheckAMinute(checkDestroy), - Steps: steps, - ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ - "upgraded-v5": frame.upgradedV5ProviderFactory, - "zitadel": frame.v6ProviderFactory, - }, + CheckDestroy: CheckAMinute(checkDestroy), + Steps: steps, + ProtoV6ProviderFactories: frame.v6ProviderFactories, + ProtoV5ProviderFactories: frame.v5ProviderFactories, }) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index c6a4fa39..2de85906 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -23,6 +23,7 @@ func RunInstanceIDPLifecyleTest( "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, CheckDestroy(frame), func(state *terraform.State) error { // Check the secret is imported correctly diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 5a55587e..7f843f71 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -25,6 +25,7 @@ func RunOrgLifecyleTest( "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, CheckDestroy(frame), func(state *terraform.State) error { // Check the secretAttribute is imported correctly diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 5d8773f9..8db5ead4 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -51,6 +51,7 @@ flow_type = "%s" initialTriggerType, updatedTriggerType, "", "", checkTriggerType(*frame, flowType), + test_utils.ZITADEL_GENERATED_ID_REGEX, checkDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), nil, nil, "", "", ) From 36b62d80d37ce65878f0d5b81cee08ceeaa6c7a0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 12 Jul 2023 19:59:21 +0200 Subject: [PATCH 171/260] fix: domain policy smtp sender --- zitadel/v2/default_domain_policy/funcs.go | 1 + 1 file changed, 1 insertion(+) diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index e6f9ec3c..c2d3a0d6 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -79,6 +79,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), validateOrgDomainVar: policy.GetValidateOrgDomains(), + smtpSenderVar: policy.GetSmtpSenderAddressMatchesInstanceDomain(), } for k, v := range set { From 2923e11f20d721f5085f05c946ee863736990e77 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 12 Jul 2023 19:59:43 +0200 Subject: [PATCH 172/260] enable testing non-string types --- zitadel/v2/action/resource_test.go | 10 ++-- zitadel/v2/app_key/resource_test.go | 10 ++-- zitadel/v2/application_api/resource_test.go | 10 ++-- zitadel/v2/application_oidc/resource_test.go | 10 ++-- .../resource_test.go | 8 +-- .../v2/default_domain_policy/resource_test.go | 56 +++++++++++++++++++ .../v2/default_oidc_settings/resource_test.go | 20 +++---- zitadel/v2/helper/test_utils/checks.go | 6 +- zitadel/v2/helper/test_utils/lifecyletest.go | 6 +- zitadel/v2/idp_utils/idp_test_utils/checks.go | 4 +- .../idp_utils/idp_test_utils/lifecyletest.go | 4 +- .../org_idp_test_utils/checks.go | 6 +- .../org_idp_test_utils/lifecyletest.go | 4 +- zitadel/v2/trigger_actions/resource_test.go | 10 ++-- 14 files changed, 113 insertions(+), 51 deletions(-) create mode 100644 zitadel/v2/default_domain_policy/resource_test.go diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index cf66d685..dbb7d563 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -22,7 +22,7 @@ func TestAccZITADELAction(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { + func(configProperty, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -36,13 +36,13 @@ resource "%s" "%s" { "", "", checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame)), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: rs.Primary.ID}) @@ -51,7 +51,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.T } actual := remoteResource.GetAction().GetScript() if actual != expect { - return fmt.Errorf("expected %s, actual: %s", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index c6985e15..3b94d73d 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -34,7 +34,7 @@ func TestAccZITADELAppKey(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { + func(configProperty, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -48,13 +48,13 @@ resource "%s" "%s" { "", "", checkRemoteProperty(frame, project.GetId(), app.GetAppId()), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId())), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId()), updatedProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteResource, err := frame.GetAppKey(frame, &management.GetAppKeyRequest{KeyId: rs.Primary.ID, ProjectId: projectId, AppId: appId}) @@ -63,7 +63,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string } actual := remoteResource.GetKey().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") if actual != expect { - return fmt.Errorf("expected %s, actual: %s", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 6f339dc7..18f8ab96 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -28,7 +28,7 @@ func TestAccZITADELAppAPI(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { + func(configProperty, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -41,13 +41,13 @@ resource "%s" "%s" { "", "", checkRemoteProperty(frame, project.GetId()), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) @@ -56,7 +56,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func( } actual := remoteResource.GetApp().GetName() if actual != expect { - return fmt.Errorf("expected %s, actual: %s", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 80df82a6..3358ae00 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -28,7 +28,7 @@ func TestAccZITADELAppOIDC(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { + func(configProperty, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -54,13 +54,13 @@ resource "%s" "%s" { "", "", checkRemoteProperty(frame, project.GetId()), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId())), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) @@ -69,7 +69,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func( } actual := remoteResource.GetApp().GetName() if actual != expect { - return fmt.Errorf("expected %s, actual: %s", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 0ef2ff60..dd086128 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -24,7 +24,7 @@ func TestAccZITADELDefaultDomainClaimedMessageTextSameLanguage(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { + func(configProperty, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -47,8 +47,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomDomainClaimedMessageText(frame, &admin.GetCustomDomainClaimedMessageTextRequest{Language: lang}) if err != nil { @@ -56,7 +56,7 @@ func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func( } actual := remoteResource.GetCustomText().GetTitle() if actual != expect { - return fmt.Errorf("expected %s, actual: %s", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go new file mode 100644 index 00000000..8cd58933 --- /dev/null +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -0,0 +1,56 @@ +package default_domain_policy_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccDefaultDomainPolicy(t *testing.T) { + resourceName := "zitadel_default_domain_policy" + initialProperty := true + updatedProperty := false + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + user_login_must_be_domain = %t + validate_org_domains = false + smtp_sender_address_matches_instance_domain = false +}`, resourceName, frame.UniqueResourcesID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckNothing, + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetDomainPolicy(frame, &admin.GetDomainPolicyRequest{}) + if err != nil { + return fmt.Errorf("getting policy failed: %w", err) + } + actual := resp.GetPolicy().GetUserLoginMustBeDomain() + if actual != expect { + return fmt.Errorf("expected %t, but got %t", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 131a4272..333e6c0f 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -13,8 +13,8 @@ import ( func TestAccDefaultOIDCSettings(t *testing.T) { resourceName := "zitadel_default_oidc_settings" - initialAccessTokenLifetime := "123h0m0s" - updatedAccessTokenLifetime := "456h0m0s" + initialProperty := "123h0m0s" + updatedProperty := "456h0m0s" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) @@ -22,7 +22,7 @@ func TestAccDefaultOIDCSettings(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(accessTokenLifetime, _ string) string { + func(accessTokenLifetime, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { access_token_lifetime = "%s" @@ -31,25 +31,25 @@ resource "%s" "%s" { refresh_token_expiration = "999h0m0s" }`, resourceName, frame.UniqueResourcesID, accessTokenLifetime) }, - initialAccessTokenLifetime, updatedAccessTokenLifetime, + initialProperty, updatedProperty, "", "", - checkAccessTokenLifetime(*frame), + checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - func(state *terraform.State) error { return nil }, + test_utils.CheckNothing, nil, nil, "", "", ) } -func checkAccessTokenLifetime(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { - return func(expectAccessTokenLifetime string) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetOIDCSettings(frame, &admin.GetOIDCSettingsRequest{}) if err != nil { return fmt.Errorf("getting oidc settings failed: %w", err) } actual := resp.GetSettings().GetAccessTokenLifetime().AsDuration().String() - if actual != expectAccessTokenLifetime { - return fmt.Errorf("expected access token lifetime %s, but got %s", expectAccessTokenLifetime, actual) + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index 84d4159e..3a5b76e6 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -29,9 +29,9 @@ func CheckAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { } } -func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(string) resource.TestCheckFunc) resource.TestCheckFunc { +func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(interface{}) resource.TestCheckFunc, validProperty interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - err := checkRemoteProperty("")(state) + err := checkRemoteProperty(validProperty)(state) if status.Code(err) != codes.NotFound { return fmt.Errorf("expected not found error but got: %w", err) } @@ -39,6 +39,8 @@ func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(string) resource. } } +func CheckNothing(*terraform.State) error { return nil } + func retryAMinute(try func() error) error { start := time.Now() for { diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 41faa1ae..c4a5a3dd 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -11,10 +11,10 @@ import ( func RunLifecyleTest( t *testing.T, frame BaseTestFrame, - resourceFunc func(initialProperty, initialSecret string) string, + resourceFunc func(initialProperty, initialSecret interface{}) string, initialProperty, updatedProperty, - initialSecret, updatedSecret string, - checkRemoteProperty func(expect string) resource.TestCheckFunc, + initialSecret, updatedSecret interface{}, + checkRemoteProperty func(expect interface{}) resource.TestCheckFunc, idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index f9a92f80..4b0fd3a9 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -11,8 +11,8 @@ import ( "google.golang.org/grpc/status" ) -func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { - return func(expectName string) resource.TestCheckFunc { +func CheckProviderName(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expectName interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: rs.Primary.ID}) diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index 2de85906..b9f45ef3 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -19,7 +19,9 @@ func RunInstanceIDPLifecyleTest( test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - resourceFunc, + func(initialProperty, initialSecret interface{}) string { + return resourceFunc(initialProperty.(string), initialSecret.(string)) + }, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 55a5dcaa..39802798 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -12,8 +12,8 @@ import ( "google.golang.org/grpc/status" ) -func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { - return func(expectName string) resource.TestCheckFunc { +func CheckProviderName(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expectName interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { rs := state.RootModule().Resources[frame.TerraformName] remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) @@ -22,7 +22,7 @@ func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.Test } actual := remoteProvider.GetIdp().GetName() if actual != expectName { - return fmt.Errorf("expected name %s, actual name: %s", expectName, actual) + return fmt.Errorf("expected name %s, but got name %s", expectName, actual) } return nil } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 7f843f71..bd84411c 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -21,7 +21,9 @@ func RunOrgLifecyleTest( test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - resourceFunc, + func(initialProperty, initialSecret interface{}) string { + return resourceFunc(initialProperty.(string), initialSecret.(string)) + }, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 8db5ead4..e7669147 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -39,7 +39,7 @@ func TestAccTriggerActions(t *testing.T) { test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(name, _ string) string { + func(name, _ interface{}) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,7 +50,7 @@ flow_type = "%s" }, initialTriggerType, updatedTriggerType, "", "", - checkTriggerType(*frame, flowType), + checkRemoteProperty(*frame, flowType), test_utils.ZITADEL_GENERATED_ID_REGEX, checkDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), nil, nil, "", "", @@ -59,8 +59,8 @@ flow_type = "%s" var errTriggerTypeNotFound = errors.New("trigger type not found") -func checkTriggerType(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { - return func(expectTriggerType string) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(interface{}) resource.TestCheckFunc { + return func(expectTriggerType interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { flowTypeValues := helper.EnumValueMap(trigger_actions.FlowTypes()) resp, err := frame.GetFlow(frame, &management.GetFlowRequest{Type: strconv.Itoa(int(flowTypeValues[flowType]))}) @@ -88,7 +88,7 @@ func checkTriggerType(frame test_utils.OrgTestFrame, flowType string) func(strin func checkDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []string) resource.TestCheckFunc { return func(state *terraform.State) error { for _, testTriggerType := range testTypes { - if err := checkTriggerType(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { + if err := checkRemoteProperty(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { return fmt.Errorf("expected error %v, but got %w", errTriggerTypeNotFound, err) } } From 34253da86004159b4c3e8504ced40f9dad59788c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 17 Jul 2023 10:57:19 +0200 Subject: [PATCH 173/260] test zitadel_default_login_texts (fails) --- .../resource_test.go | 3 +- .../resource_test.go | 65 ++++ .../v2/default_login_texts/resource_test.go | 344 ++++++++++++++++++ 3 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 zitadel/v2/default_init_message_text/resource_test.go create mode 100644 zitadel/v2/default_login_texts/resource_test.go diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index dd086128..d2e80706 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultDomainClaimedMessageTextSameLanguage(t *testing.T) { +func TestAccZITADELDefaultDomainClaimedMessageText(t *testing.T) { resourceName := "zitadel_default_domain_claimed_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" @@ -28,6 +28,7 @@ func TestAccZITADELDefaultDomainClaimedMessageTextSameLanguage(t *testing.T) { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" + title = "%s" pre_header = "pre_header example" subject = "subject example" diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go new file mode 100644 index 00000000..2f07f449 --- /dev/null +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -0,0 +1,65 @@ +package default_init_message_text_test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELDefaultInitMessageText(t *testing.T) { + resourceName := "zitadel_default_init_message_text" + initialProperty := "initialtitle" + updatedProperty := "updatedtitle" + language := "en" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + language = "%s" + + title = "%s" + pre_header = "pre_header example" + subject = "subject example" + greeting = "greeting example" + text = "text example" + button_text = "button_text example" + footer_text = "footer_text example" +}`, resourceName, frame.UniqueResourcesID, language, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, language), + regexp.MustCompile(`^en$`), + // When deleted, the default should be returned + checkRemoteProperty(frame, language)("ZITADEL - Initialize User"), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetCustomInitMessageText(frame, &admin.GetCustomInitMessageTextRequest{Language: lang}) + if err != nil { + return err + } + actual := remoteResource.GetCustomText().GetTitle() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go new file mode 100644 index 00000000..9d9935cc --- /dev/null +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -0,0 +1,344 @@ +package default_login_texts_test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELDefaultLoginTexts(t *testing.T) { + resourceName := "zitadel_default_login_texts" + initialProperty := "initialtitle" + updatedProperty := "updatedtitle" + language := "en" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + language = "%s" + + email_verification_done_text = { + cancel_button_text = "example" + description = "example" + login_button_text = "example" + next_button_text = "example" + title = "%s" + } + email_verification_text = { + code_label = "example" + description = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + external_registration_user_overview_text = { + back_button_text = "example" + description = "example" + email_label = "example" + firstname_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + nickname_label = "example" + phone_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + external_user_not_found_text = { + auto_register_button_text = "example" + description = "example" + link_button_text = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + } + footer_text = { + help = "example" + privacy_policy = "example" + tos = "example" + } + init_mfa_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_mfa_otp_text = { + cancel_button_text = "example" + code_label = "example" + description = "example" + description_otp = "example" + next_button_text = "example" + secret_label = "example" + title = "example" + } + init_mfa_prompt_text = { + description = "example" + next_button_text = "example" + otp_option = "example" + skip_button_text = "example" + title = "example" + u2f_option = "example" + } + init_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + init_password_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + init_password_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + initialize_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + initialize_user_text = { + code_label = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + resend_button_text = "example" + title = "example" + } + linking_user_done_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + } + login_text = { + description = "example" + description_linking_process = "example" + external_user_description = "example" + login_name_label = "example" + login_name_placeholder = "example" + next_button_text = "example" + register_button_text = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + user_name_placeholder = "example" + } + logout_text = { + description = "example" + login_button_text = "example" + title = "example" + } + mfa_providers_text = { + choose_other = "example" + otp = "example" + u2f = "example" + } + password_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_change_text = { + cancel_button_text = "example" + description = "example" + new_password_confirm_label = "example" + new_password_label = "example" + next_button_text = "example" + old_password_label = "example" + title = "example" + } + password_reset_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + password_text = { + back_button_text = "example" + confirmation = "example" + description = "example" + has_lowercase = "example" + has_number = "example" + has_symbol = "example" + has_uppercase = "example" + min_length = "example" + next_button_text = "example" + password_label = "example" + reset_link_text = "example" + title = "example" + } + passwordless_prompt_text = { + description = "example" + description_init = "example" + next_button_text = "example" + passwordless_button_text = "example" + skip_button_text = "example" + title = "example" + } + passwordless_registration_done_text = { + cancel_button_text = "example" + description = "example" + description_close = "example" + next_button_text = "example" + title = "example" + } + passwordless_registration_text = { + description = "example" + error_retry = "example" + not_supported = "example" + register_token_button_text = "example" + title = "example" + token_name_label = "example" + } + passwordless_text = { + description = "example" + error_retry = "example" + login_with_pw_button_text = "example" + not_supported = "example" + title = "example" + validate_token_button_text = "example" + } + registration_option_text = { + description = "example" + external_login_description = "example" + title = "example" + user_name_button_text = "example" + } + registration_org_text = { + description = "example" + email_label = "example" + firstname_label = "example" + lastname_label = "example" + orgname_label = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + save_button_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + registration_user_text = { + back_button_text = "example" + description = "example" + description_org_register = "example" + email_label = "example" + firstname_label = "example" + gender_label = "example" + language_label = "example" + lastname_label = "example" + next_button_text = "example" + password_confirm_label = "example" + password_label = "example" + privacy_link_text = "example" + title = "example" + tos_and_privacy_label = "example" + tos_confirm = "example" + tos_confirm_and = "example" + tos_link_text = "example" + username_label = "example" + } + select_account_text = { + description = "example" + description_linking_process = "example" + other_user = "example" + session_state_active = "example" + session_state_inactive = "example" + title = "example" + title_linking_process = "example" + user_must_be_member_of_org = "example" + } + success_login_text = { + auto_redirect_description = "example" + next_button_text = "example" + redirected_description = "example" + title = "example" + } + username_change_done_text = { + description = "example" + next_button_text = "example" + title = "example" + } + username_change_text = { + cancel_button_text = "example" + description = "example" + next_button_text = "example" + title = "example" + username_label = "example" + } + verify_mfa_otp_text = { + code_label = "example" + description = "example" + next_button_text = "example" + title = "example" + } + verify_mfa_u2f_text = { + description = "example" + error_retry = "example" + not_supported = "example" + title = "example" + validate_token_text = "example" + } +}`, resourceName, frame.UniqueResourcesID, language, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame, language), + regexp.MustCompile(`^en$`), + // When deleted, the default should be returned + checkRemoteProperty(frame, language)("E-Mail Verification"), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetCustomLoginTexts(frame, &admin.GetCustomLoginTextsRequest{Language: lang}) + if err != nil { + return err + } + actual := remoteResource.GetCustomText().GetEmailVerificationDoneText().GetTitle() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} From 97ef1cdb4f7f2a6c5ee45e1698fdb70f859d29e8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Jul 2023 14:42:16 +0200 Subject: [PATCH 174/260] test on two instances --- .github/workflows/pull_request.yaml | 2 +- CONTRIBUTING.md | 2 +- acceptance/Dockerfile | 3 +- acceptance/config.go | 38 ++ acceptance/config.json | 8 + acceptance/docker-compose.yaml | 6 +- acceptance/keys/.gitignore | 2 + acceptance/machinekey/.gitignore | 1 - acceptance/machinekey/.gitkeep | 0 acceptance/setup.sh | 278 +++++++++----- acceptance/zitadel.yaml | 12 +- docs/resources/org_idp_jwt.md | 4 +- zitadel/provider.go | 14 +- .../v2/default_label_policy/resource_test.go | 64 ++++ .../default_lockout_policy/resource_test.go | 54 +++ .../v2/default_login_policy/resource_test.go | 71 ++++ .../resource_test.go | 54 +++ .../resource_test.go | 65 ++++ .../resource_test.go | 58 +++ .../resource_test.go | 65 ++++ .../resource_test.go | 65 ++++ .../default_privacy_policy/resource_test.go | 56 +++ .../resource_test.go | 65 ++++ .../resource_test.go | 65 ++++ .../resource_test.go | 66 ++++ zitadel/v2/domain_policy/resource_test.go | 57 +++ zitadel/v2/helper/test_utils/base_frame.go | 28 +- zitadel/v2/helper/test_utils/checks.go | 1 + .../v2/helper/test_utils/instance_frame.go | 10 +- zitadel/v2/helper/test_utils/org_frame.go | 30 +- zitadel/v2/init_message_text/resource_test.go | 66 ++++ zitadel/v2/label_policy/resource_test.go | 65 ++++ zitadel/v2/lockout_policy/resource_test.go | 55 +++ zitadel/v2/login_policy/resource_test.go | 72 ++++ zitadel/v2/login_texts/resource_test.go | 345 ++++++++++++++++++ .../v2/notification_policy/resource_test.go | 55 +++ .../resource_test.go | 66 ++++ .../resource_test.go | 59 +++ .../resource_test.go | 66 ++++ .../resource_test.go | 66 ++++ zitadel/v2/privacy_policy/funcs.go | 2 +- zitadel/v2/privacy_policy/resource_test.go | 57 +++ .../resource_test.go | 66 ++++ .../resource_test.go | 66 ++++ 44 files changed, 2209 insertions(+), 141 deletions(-) create mode 100644 acceptance/config.go create mode 100644 acceptance/config.json create mode 100644 acceptance/keys/.gitignore delete mode 100644 acceptance/machinekey/.gitignore delete mode 100644 acceptance/machinekey/.gitkeep mode change 100644 => 100755 acceptance/setup.sh create mode 100644 zitadel/v2/default_label_policy/resource_test.go create mode 100644 zitadel/v2/default_lockout_policy/resource_test.go create mode 100644 zitadel/v2/default_login_policy/resource_test.go create mode 100644 zitadel/v2/default_notification_policy/resource_test.go create mode 100644 zitadel/v2/default_password_change_message_text/resource_test.go create mode 100644 zitadel/v2/default_password_complexity_policy/resource_test.go create mode 100644 zitadel/v2/default_password_reset_message_text/resource_test.go create mode 100644 zitadel/v2/default_passwordless_registration_message_text/resource_test.go create mode 100644 zitadel/v2/default_privacy_policy/resource_test.go create mode 100644 zitadel/v2/default_verify_email_message_text/resource_test.go create mode 100644 zitadel/v2/default_verify_phone_message_text/resource_test.go create mode 100644 zitadel/v2/domain_claimed_message_text/resource_test.go create mode 100644 zitadel/v2/domain_policy/resource_test.go create mode 100644 zitadel/v2/init_message_text/resource_test.go create mode 100644 zitadel/v2/label_policy/resource_test.go create mode 100644 zitadel/v2/lockout_policy/resource_test.go create mode 100644 zitadel/v2/login_policy/resource_test.go create mode 100644 zitadel/v2/login_texts/resource_test.go create mode 100644 zitadel/v2/notification_policy/resource_test.go create mode 100644 zitadel/v2/password_change_message_text/resource_test.go create mode 100644 zitadel/v2/password_complexity_policy/resource_test.go create mode 100644 zitadel/v2/password_reset_message_text/resource_test.go create mode 100644 zitadel/v2/passwordless_registration_message_text/resource_test.go create mode 100644 zitadel/v2/privacy_policy/resource_test.go create mode 100644 zitadel/v2/verify_email_message_text/resource_test.go create mode 100644 zitadel/v2/verify_phone_message_text/resource_test.go diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index a75cb44d..8209040b 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -38,7 +38,7 @@ jobs: run: docker compose run wait_for_zitadel - name: Run Acceptance Tests - run: TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... + run: TF_ACC=1 go test ./... - name: Save ZITADEL Logs working-directory: acceptance diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe18984e..fd216f08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ docker compose --file ./acceptance/docker-compose.yaml run setup Run the accepance tests using the machine key generated by ZITADEL. ```bash -TF_ACC=1 TF_ACC_ZITADEL_TOKEN=$(pwd)/acceptance/machinekey/zitadel-admin-sa.json go test ./... +TF_ACC=1 go test ./... ``` # Generate Docs diff --git a/acceptance/Dockerfile b/acceptance/Dockerfile index a2283d09..8d3525fa 100644 --- a/acceptance/Dockerfile +++ b/acceptance/Dockerfile @@ -1,6 +1,7 @@ FROM golang:1.19-alpine RUN apk add curl jq RUN go install github.com/zitadel/zitadel-tools@v0.4.0 -COPY setup.sh /setup.sh +COPY setup.sh config.json / RUN chmod +x /setup.sh +WORKDIR / ENTRYPOINT [ "/setup.sh" ] diff --git a/acceptance/config.go b/acceptance/config.go new file mode 100644 index 00000000..ef7cb70f --- /dev/null +++ b/acceptance/config.go @@ -0,0 +1,38 @@ +package acceptance + +import ( + _ "embed" + "encoding/json" +) + +var ( + //go:embed keys/instance-level-admin-sa.json + instanceLevelAdminSAJSON []byte + + //go:embed keys/org-level-admin-sa.json + orgLevelAdminSAJSON []byte + + //go:embed config.json + configJson []byte +) + +type Config struct { + OrgLevel IsolatedInstance + InstanceLevel IsolatedInstance +} + +type IsolatedInstance struct { + Domain string + AdminSAJSON []byte +} + +func GetConfig() Config { + val := Config{ + OrgLevel: IsolatedInstance{AdminSAJSON: orgLevelAdminSAJSON}, + InstanceLevel: IsolatedInstance{AdminSAJSON: instanceLevelAdminSAJSON}, + } + if err := json.Unmarshal(configJson, &val); err != nil { + panic(err) + } + return val +} diff --git a/acceptance/config.json b/acceptance/config.json new file mode 100644 index 00000000..87fe6d14 --- /dev/null +++ b/acceptance/config.json @@ -0,0 +1,8 @@ +{ + "orgLevel": { + "domain": "org-level-tests.default.127.0.0.1.sslip.io" + }, + "instanceLevel": { + "domain": "instance-level-tests.default.127.0.0.1.sslip.io" + } +} diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 29393ddc..69a150d4 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -8,7 +8,7 @@ services: ports: - "8080:8080" volumes: - - ./machinekey:/machinekey + - ./keys:/keys - ./zitadel.yaml:/zitadel.yaml depends_on: db: @@ -38,10 +38,10 @@ services: container_name: setup build: . environment: - KEY: /key/zitadel-admin-sa.json + KEYS_DIRECTORY: /keys SERVICE: http://zitadel:8080 volumes: - - "./machinekey:/key" + - "./keys:/keys" depends_on: wait_for_zitadel: condition: 'service_completed_successfully' diff --git a/acceptance/keys/.gitignore b/acceptance/keys/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/acceptance/keys/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/acceptance/machinekey/.gitignore b/acceptance/machinekey/.gitignore deleted file mode 100644 index 7c9f54d0..00000000 --- a/acceptance/machinekey/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zitadel-admin-sa.json diff --git a/acceptance/machinekey/.gitkeep b/acceptance/machinekey/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/acceptance/setup.sh b/acceptance/setup.sh old mode 100644 new mode 100755 index 303d9dd4..5404f03e --- a/acceptance/setup.sh +++ b/acceptance/setup.sh @@ -2,110 +2,220 @@ set -e -KEY=${KEY:-./machinekey/zitadel-admin-sa.json} -echo "Using key path ${KEY} to the instance admin service account." +############## +### CONFIG ### +############## -AUDIENCE=${AUDIENCE:-http://localhost:8080} -echo "Using audience ${AUDIENCE} for which the key is used." +KEYS_DIRECTORY=${KEYS_DIRECTORY:-./keys} -SERVICE=${SERVICE:-$AUDIENCE} -echo "Using the service ${SERVICE} to connect to ZITADEL. For example in docker compose this can differ from the audience." +if [ ! -d "${KEYS_DIRECTORY}" ]; then + echo "Directory ${KEYS_DIRECTORY} does not exist." + exit 1 +fi -AUDIENCE_HOST="$(echo $AUDIENCE | cut -d/ -f3)" -echo "Deferred the Host header ${AUDIENCE_HOST} which will be sent in requests that ZITADEL then maps to a virtual instance" +if [ ! -f "./config.json" ]; then + echo "File ./config.json does not exist." + exit 1 +fi -JWT=$(zitadel-tools key2jwt --key ${KEY} --audience ${AUDIENCE}) -echo "Created JWT from Admin service account key ${JWT}" +if [ ! -f "${KEYS_DIRECTORY}/system-api-sa.pem" ]; then + echo "File ${KEYS_DIRECTORY}/system-api-sa.pem does not exist." + exit 1 +fi -TOKEN_RESPONSE=$(curl -s --request POST \ - --url ${SERVICE}/oauth/v2/token \ - --header 'Content-Type: application/x-www-form-urlencoded' \ - --header "Host: ${AUDIENCE_HOST}" \ - --data grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \ - --data scope='openid profile email urn:zitadel:iam:org:project:id:zitadel:aud' \ - --data assertion="${JWT}") -echo "Got response from token endpoint:" -echo "${TOKEN_RESPONSE}" | jq +if [ ! -f "${KEYS_DIRECTORY}/org-level-admin-sa.json" ]; then + echo "File ${KEYS_DIRECTORY}/org-level-admin-sa.json does not exist." + echo "Did ZITADEL set up correctly?" + exit 1 +fi -TOKEN=$(echo -n ${TOKEN_RESPONSE} | jq --raw-output '.access_token') -echo "Extracted access token ${TOKEN}" +SYSTEM_API_PEM_KEY=${KEYS_DIRECTORY}/system-api-sa.pem +echo "Using path ${SYSTEM_API_PEM_KEY} to read the system api service account pem key from ." -ORG_RESPONSE=$(curl -s --request GET \ - --url ${SERVICE}/admin/v1/orgs/default \ - --header 'Accept: application/json' \ - --header "Authorization: Bearer ${TOKEN}" \ - --header "Host: ${AUDIENCE_HOST}") -echo "Got default org response:" -echo "${ORG_RESPONSE}" | jq +ORG_LEVEL_DOMAIN=$(cat ./config.json | jq --raw-output '.orgLevel.domain') +INSTANCE_LEVEL_DOMAIN=$(cat ./config.json | jq --raw-output '.instanceLevel.domain') -ORG_ID=$(echo -n ${ORG_RESPONSE} | jq --raw-output '.org.id') -echo "Extracted default org id ${ORG_ID}" +ORG_LEVEL_KEY=${KEYS_DIRECTORY}/org-level-admin-sa.json +echo "Using path ${ORG_LEVEL_KEY} to read the ${ORG_LEVEL_DOMAIN} instances admin service account key from." -HUMAN_USER_USERNAME="zitadel-admin@zitadel.localhost" -HUMAN_USER_PASSWORD="Password1!" +INSTANCE_LEVEL_KEY=${KEYS_DIRECTORY}/instance-level-admin-sa.json +echo "Using path ${INSTANCE_LEVEL_KEY} to write the ${INSTANCE_LEVEL_DOMAIN} instances admin service account key to." -HUMAN_USER_PAYLOAD=$(cat << EOM -{ - "userName": "${HUMAN_USER_USERNAME}", - "profile": { - "firstName": "ZITADEL", - "lastName": "Admin", - "displayName": "ZITADEL Admin", - "preferredLanguage": "en" - }, - "email": { - "email": "zitadel-admin@zitadel.localhost", - "isEmailVerified": true - }, - "password": "${HUMAN_USER_PASSWORD}", - "passwordChangeRequired": false -} -EOM -) -echo "Creating human user" -echo "${HUMAN_USER_PAYLOAD}" | jq +AUDIENCE=${AUDIENCE:-http://$ORG_LEVEL_DOMAIN:8080} +echo "Using audience ${AUDIENCE} for which the key is used." -HUMAN_USER_RESPONSE=$(curl -s --request POST \ - --url ${SERVICE}/management/v1/users/human/_import \ - --header 'Content-Type: application/json' \ - --header 'Accept: application/json' \ - --header "Authorization: Bearer ${TOKEN}" \ - --header "Host: ${AUDIENCE_HOST}" \ - --data-raw "${HUMAN_USER_PAYLOAD}") -echo "Create human user response" -echo "${HUMAN_USER_RESPONSE}" | jq - -if [ "$(echo -n "${HUMAN_USER_RESPONSE}" | jq --raw-output '.code')" == "6" ]; then - echo "admin user already exists" - exit 0 -fi +SERVICE=${SERVICE:-$AUDIENCE} +echo "Using the service ${SERVICE} to connect to ZITADEL. For example in docker compose this can differ from the audience." + +###################################### +### CREATE INSTANCE LEVEL INSTANCE ### +###################################### -HUMAN_USER_ID=$(echo -n ${HUMAN_USER_RESPONSE} | jq --raw-output '.userId') -echo "Extracted human user id ${HUMAN_USER_ID}" +echo "Creating SA_JWT for system API user" +SYSTEM_API_TOKEN=$(zitadel-tools key2jwt --key ${SYSTEM_API_PEM_KEY} --audience ${AUDIENCE} --issuer "system-api-sa") -HUMAN_ADMIN_PAYLOAD=$(cat << EOM +INSTANCE_LEVEL_INSTANCE_PAYLOAD=$(cat < ${INSTANCE_LEVEL_KEY} +fi + +######################### +### HUMAN USERS ######### +######################### + +create_human_admin () { + MGMT_AUDIENCE=$1 + MGMT_JSON_KEY=$2 + + echo "Creating human admin for ${MGMT_AUDIENCE}" + + AUDIENCE_HOST="$(echo $MGMT_AUDIENCE | cut -d/ -f3)" + echo "Deferred the Host header ${AUDIENCE_HOST} which will be sent in requests that ZITADEL then maps to a virtual instance" + + SA_JWT=$(zitadel-tools key2jwt --key ${MGMT_JSON_KEY} --audience ${MGMT_AUDIENCE}) + echo "Created JWT from Admin service account key ${SA_JWT}" + + TOKEN_RESPONSE=$(curl -s --request POST \ + --url ${SERVICE}/oauth/v2/token \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --header "Host: ${AUDIENCE_HOST}" \ + --data grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \ + --data scope='openid profile email urn:zitadel:iam:org:project:id:zitadel:aud' \ + --data assertion="${SA_JWT}") + echo "Got response from token endpoint:" + echo "${TOKEN_RESPONSE}" | jq + + TOKEN=$(echo ${TOKEN_RESPONSE} | jq --raw-output '.access_token') + echo "Extracted access token ${TOKEN}" + + ORG_RESPONSE=$(curl -s --request GET \ + --url ${SERVICE}/admin/v1/orgs/default \ + --header 'Accept: application/json' \ + --header "Authorization: Bearer ${TOKEN}" \ + --header "Host: ${AUDIENCE_HOST}") + echo "Got default org response:" + echo "${ORG_RESPONSE}" | jq + + ORG_ID=$(echo ${ORG_RESPONSE} | jq --raw-output '.org.id') + echo "Extracted default org id ${ORG_ID}" + + HUMAN_USER_USERNAME="zitadel-admin@zitadel.localhost" + HUMAN_USER_PASSWORD="Password1!" + + HUMAN_USER_PAYLOAD=$(cat < Date: Wed, 19 Jul 2023 17:14:59 +0200 Subject: [PATCH 175/260] make tests pass --- zitadel/v2/default_login_texts/resource_test.go | 2 +- .../v2/default_password_change_message_text/resource_test.go | 2 +- .../v2/default_password_reset_message_text/resource_test.go | 2 +- .../resource_test.go | 2 +- zitadel/v2/default_verify_email_message_text/resource_test.go | 2 +- zitadel/v2/default_verify_phone_message_text/resource_test.go | 2 +- zitadel/v2/domain_policy/resource_test.go | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index 9d9935cc..e849c84a 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -322,7 +322,7 @@ resource "%s" "%s" { checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("E-Mail Verification"), + checkRemoteProperty(frame, language)(""), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index ed2d366c..20359303 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -51,7 +51,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetDefaultPasswordChangeMessageText(frame, &admin.GetDefaultPasswordChangeMessageTextRequest{Language: lang}) + remoteResource, err := frame.GetCustomPasswordChangeMessageText(frame, &admin.GetCustomPasswordChangeMessageTextRequest{Language: lang}) if err != nil { return err } diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index f481b828..d22a7d95 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -51,7 +51,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetDefaultPasswordResetMessageText(frame, &admin.GetDefaultPasswordResetMessageTextRequest{Language: lang}) + remoteResource, err := frame.GetCustomPasswordResetMessageText(frame, &admin.GetCustomPasswordResetMessageTextRequest{Language: lang}) if err != nil { return err } diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 01b340fe..7f59cd0a 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -51,7 +51,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetDefaultPasswordlessRegistrationMessageText(frame, &admin.GetDefaultPasswordlessRegistrationMessageTextRequest{Language: lang}) + remoteResource, err := frame.GetCustomPasswordlessRegistrationMessageText(frame, &admin.GetCustomPasswordlessRegistrationMessageTextRequest{Language: lang}) if err != nil { return err } diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 0d8776ca..ae83551b 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -51,7 +51,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetDefaultVerifyEmailMessageText(frame, &admin.GetDefaultVerifyEmailMessageTextRequest{Language: lang}) + remoteResource, err := frame.GetCustomVerifyEmailMessageText(frame, &admin.GetCustomVerifyEmailMessageTextRequest{Language: lang}) if err != nil { return err } diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index c021f579..859a3ee5 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -51,7 +51,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetDefaultVerifyPhoneMessageText(frame, &admin.GetDefaultVerifyPhoneMessageTextRequest{Language: lang}) + remoteResource, err := frame.GetCustomVerifyPhoneMessageText(frame, &admin.GetCustomVerifyPhoneMessageTextRequest{Language: lang}) if err != nil { return err } diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 9497500d..ca6d9a1a 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -13,8 +13,8 @@ import ( func TestAccDomainPolicy(t *testing.T) { resourceName := "zitadel_domain_policy" - initialProperty := true - updatedProperty := false + initialProperty := false + updatedProperty := true frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) From 8c551fe811190bc2b4fa30deec64e920faac548d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 19 Jul 2023 18:58:01 +0200 Subject: [PATCH 176/260] test domain --- zitadel/v2/domain/resource_test.go | 82 ++++++++++++++++++++++++++++++ zitadel/v2/label_policy/funcs.go | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 zitadel/v2/domain/resource_test.go diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go new file mode 100644 index 00000000..4e1ffc9b --- /dev/null +++ b/zitadel/v2/domain/resource_test.go @@ -0,0 +1,82 @@ +package domain_test + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELDomain(t *testing.T) { + resourceName := "zitadel_domain" + initialProperty := "initial.default.127.0.0.1.sslip.io" + updatedProperty := "updated.default.127.0.0.1.sslip.io" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + is_primary = false +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, initialProperty, updatedProperty)), + checkDestroy(frame, updatedProperty), + nil, nil, "", "", + ) +} + +var ErrNotFound = errors.New("not found") + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(_ *terraform.State) error { + remoteResource, err := frame.ListOrgDomains(frame, &management.ListOrgDomainsRequest{ + Queries: []*org.DomainSearchQuery{{ + Query: &org.DomainSearchQuery_DomainNameQuery{ + DomainNameQuery: &org.DomainNameQuery{ + Name: expect.(string), + }, + }, + }}, + }) + if err != nil { + return err + } + if len(remoteResource.GetResult()) == 0 { + return fmt.Errorf("expected to find %s, but didn't: %w", expect, ErrNotFound) + } + return nil + } + } +} + +func checkDestroy(frame *test_utils.OrgTestFrame, expectNotFound string) resource.TestCheckFunc { + return func(state *terraform.State) error { + err := checkRemoteProperty(frame)(expectNotFound)(state) + if errors.Is(err, ErrNotFound) { + return nil + } + if err == nil { + return fmt.Errorf("expected to not find %s, but did", expectNotFound) + } + return err + } +} diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index fbf7fdbe..da79a92a 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -12,7 +12,7 @@ import ( ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") + tflog.Info(ctx, "started delete") clientinfo, ok := m.(*helper.ClientInfo) if !ok { From 2073172ede15ddde7a02808f850ed25acb81f304 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 20 Jul 2023 08:08:28 +0200 Subject: [PATCH 177/260] fix: add bool forceMfaLocalOnly to login policy --- zitadel/v2/default_login_policy/const.go | 1 + zitadel/v2/default_login_policy/funcs.go | 3 +++ zitadel/v2/default_login_policy/resource.go | 5 +++++ zitadel/v2/login_policy/const.go | 1 + zitadel/v2/login_policy/funcs.go | 4 ++++ zitadel/v2/login_policy/resource.go | 5 +++++ 6 files changed, 19 insertions(+) diff --git a/zitadel/v2/default_login_policy/const.go b/zitadel/v2/default_login_policy/const.go index eed1e292..f5659818 100644 --- a/zitadel/v2/default_login_policy/const.go +++ b/zitadel/v2/default_login_policy/const.go @@ -5,6 +5,7 @@ const ( allowRegisterVar = "allow_register" allowExternalIDPVar = "allow_external_idp" forceMFAVar = "force_mfa" + forceMFALocalOnlyVar = "force_mfa_local_only" passwordlessTypeVar = "passwordless_type" hidePasswordResetVar = "hide_password_reset" passwordCheckLifetimeVar = "password_check_lifetime" diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 222ac3ae..ecf33fea 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -42,6 +42,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia allowRegisterVar, allowExternalIDPVar, forceMFAVar, + forceMFALocalOnlyVar, passwordlessTypeVar, hidePasswordResetVar, ignoreUnknownUsernamesVar, @@ -87,6 +88,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), + ForceMfaLocalOnly: d.Get(forceMFALocalOnlyVar).(bool), }) if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update login policy: %v", err) @@ -224,6 +226,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn allowDomainDiscovery: resp.Policy.GetAllowDomainDiscovery(), disableLoginWithEmail: resp.Policy.GetDisableLoginWithEmail(), disableLoginWithPhone: resp.Policy.GetDisableLoginWithPhone(), + forceMFALocalOnlyVar: resp.Policy.GetForceMfaLocalOnly(), } respSecond, err := client.ListLoginPolicySecondFactors(ctx, &admin.ListLoginPolicySecondFactorsRequest{}) diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 4a649f06..1d1faed7 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -28,6 +28,11 @@ func GetResource() *schema.Resource { Required: true, Description: "defines if a user MUST use a multi factor to log in", }, + forceMFALocalOnlyVar: { + Type: schema.TypeBool, + Required: true, + Description: "if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login.", + }, passwordlessTypeVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/login_policy/const.go b/zitadel/v2/login_policy/const.go index ed75c06c..da0cdaae 100644 --- a/zitadel/v2/login_policy/const.go +++ b/zitadel/v2/login_policy/const.go @@ -6,6 +6,7 @@ const ( allowRegisterVar = "allow_register" allowExternalIDPVar = "allow_external_idp" forceMFAVar = "force_mfa" + forceMFALocalOnlyVar = "force_mfa_local_only" passwordlessTypeVar = "passwordless_type" hidePasswordResetVar = "hide_password_reset" passwordCheckLifetimeVar = "password_check_lifetime" diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 2799545a..26def736 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -55,6 +55,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia allowRegisterVar, allowExternalIDPVar, forceMFAVar, + forceMFALocalOnlyVar, passwordlessTypeVar, hidePasswordResetVar, ignoreUnknownUsernamesVar, @@ -105,6 +106,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), + ForceMFALocalOnly: d.Get(forceMFALocalOnlyVar).(bool), }) if err != nil { return diag.Errorf("failed to update login policy: %v", err) @@ -240,6 +242,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), + ForceMFALocalOnly: d.Get(forceMFALocalOnlyVar).(bool), }) if err != nil { return diag.Errorf("failed to create login policy: %v", err) @@ -330,6 +333,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn allowDomainDiscovery: policy.GetAllowDomainDiscovery(), disableLoginWithEmail: policy.GetDisableLoginWithEmail(), disableLoginWithPhone: policy.GetDisableLoginWithPhone(), + forceMFALocalOnlyVar: policy.GetForceMfaLocalOnly(), } respSecond, err := client.ListLoginPolicySecondFactors(ctx, &management.ListLoginPolicySecondFactorsRequest{}) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index b26337d8..0362412e 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -34,6 +34,11 @@ func GetResource() *schema.Resource { Required: true, Description: "defines if a user MUST use a multi factor to log in", }, + forceMFALocalOnlyVar: { + Type: schema.TypeBool, + Required: true, + Description: "if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login.", + }, passwordlessTypeVar: { Type: schema.TypeString, Required: true, From 15e561628a1bd2d2e4893592acae887b86bd58ea Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 20 Jul 2023 17:55:57 +0200 Subject: [PATCH 178/260] test org member --- zitadel/v2/domain/resource_test.go | 20 +----- zitadel/v2/helper/test_utils/checks.go | 7 +- zitadel/v2/human_user/resource_test.go | 67 +++++++++++++++++ zitadel/v2/org_member/resource_test.go | 79 +++++++++++++++++++++ zitadel/v2/trigger_actions/resource_test.go | 18 +---- 5 files changed, 155 insertions(+), 36 deletions(-) create mode 100644 zitadel/v2/human_user/resource_test.go create mode 100644 zitadel/v2/org_member/resource_test.go diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 4e1ffc9b..854d071d 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -1,7 +1,6 @@ package domain_test import ( - "errors" "fmt" "regexp" "testing" @@ -38,13 +37,11 @@ resource "%s" "%s" { "", "", checkRemoteProperty(frame), regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, initialProperty, updatedProperty)), - checkDestroy(frame, updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), nil, nil, "", "", ) } -var ErrNotFound = errors.New("not found") - func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(_ *terraform.State) error { @@ -61,22 +58,9 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resou return err } if len(remoteResource.GetResult()) == 0 { - return fmt.Errorf("expected to find %s, but didn't: %w", expect, ErrNotFound) + return fmt.Errorf("expected to find %s, but didn't: %w", expect, test_utils.ErrNotFound) } return nil } } } - -func checkDestroy(frame *test_utils.OrgTestFrame, expectNotFound string) resource.TestCheckFunc { - return func(state *terraform.State) error { - err := checkRemoteProperty(frame)(expectNotFound)(state) - if errors.Is(err, ErrNotFound) { - return nil - } - if err == nil { - return fmt.Errorf("expected to not find %s, but did", expectNotFound) - } - return err - } -} diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index fc3711f9..6463caca 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -1,6 +1,7 @@ package test_utils import ( + "errors" "fmt" "regexp" "time" @@ -30,11 +31,13 @@ func CheckAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { } } +var ErrNotFound = fmt.Errorf("not found") + func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(interface{}) resource.TestCheckFunc, validProperty interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { err := checkRemoteProperty(validProperty)(state) - if status.Code(err) != codes.NotFound { - return fmt.Errorf("expected not found error but got: %w", err) + if status.Code(err) != codes.NotFound && !errors.Is(err, ErrNotFound) { + return fmt.Errorf("expected not found error but got: %v: %w", err, ErrNotFound) } return nil } diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go new file mode 100644 index 00000000..475bb2cd --- /dev/null +++ b/zitadel/v2/human_user/resource_test.go @@ -0,0 +1,67 @@ +package human_user_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccZITADELHumanUser(t *testing.T) { + resourceName := "zitadel_human_user" + initialProperty := "test1@zitadel.com" + updatedProperty := "test2@zitadel.com" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, secretProperty interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + user_name = "test@zitadel.com" + first_name = "firstname" + last_name = "lastname" + nick_name = "nickname" + display_name = "displayname" + preferred_language = "de" + gender = "GENDER_MALE" + phone = "+41799999999" + is_phone_verified = true + email = "%s" + is_email_verified = true + initial_password = "Password1!" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + rs := state.RootModule().Resources[frame.TerraformName] + remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: rs.Primary.ID}) + if err != nil { + return err + } + actual := remoteResource.GetUser().GetHuman().GetEmail().GetEmail() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go new file mode 100644 index 00000000..f71500b0 --- /dev/null +++ b/zitadel/v2/org_member/resource_test.go @@ -0,0 +1,79 @@ +package org_member_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccOrgMember(t *testing.T) { + resourceName := "zitadel_org_member" + initialProperty := "ORG_OWNER" + updatedProperty := "ORG_OWNER_VIEWER" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ + UserName: frame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + userID := user.GetUserId() + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + user_id = "%s" + roles = ["%s"] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, user.GetUserId(), cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.ListOrgMembers(frame, &management.ListOrgMembersRequest{ + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{UserIdQuery: &member.UserIDQuery{UserId: userID}}, + }}, + }) + if err != nil { + return err + } + if len(resp.Result) == 0 || len(resp.Result[0].Roles) == 0 { + return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) + } + actual := resp.Result[0].Roles[0] + if expected != actual { + return fmt.Errorf("expected role %s, but got %s", expected, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index e7669147..77b3e493 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -1,7 +1,6 @@ package trigger_actions_test import ( - "errors" "fmt" "strconv" "testing" @@ -52,13 +51,11 @@ flow_type = "%s" "", "", checkRemoteProperty(*frame, flowType), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkDestroy(*frame, flowType, []string{initialTriggerType, updatedTriggerType}), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), initialTriggerType), nil, nil, "", "", ) } -var errTriggerTypeNotFound = errors.New("trigger type not found") - func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(interface{}) resource.TestCheckFunc { return func(expectTriggerType interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { @@ -80,18 +77,7 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(in return nil } } - return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, foundTypes, errTriggerTypeNotFound) - } - } -} - -func checkDestroy(frame test_utils.OrgTestFrame, flowType string, testTypes []string) resource.TestCheckFunc { - return func(state *terraform.State) error { - for _, testTriggerType := range testTypes { - if err := checkRemoteProperty(frame, flowType)(testTriggerType)(state); !errors.Is(err, errTriggerTypeNotFound) { - return fmt.Errorf("expected error %v, but got %w", errTriggerTypeNotFound, err) - } + return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, foundTypes, test_utils.ErrNotFound) } - return nil } } From 7cf19e0ea2d8ff5f3918cb2decd400bcd26f30f1 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 09:29:51 +0200 Subject: [PATCH 179/260] fix: replace role on key change --- zitadel/v2/project_role/resource.go | 1 + zitadel/v2/project_role/resource_test.go | 79 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 zitadel/v2/project_role/resource_test.go diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go index d5006e2e..2447e4a0 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/v2/project_role/resource.go @@ -23,6 +23,7 @@ func GetResource() *schema.Resource { keyVar: { Type: schema.TypeString, Required: true, + ForceNew: true, Description: "Key used for project role", }, displayNameVar: { diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go new file mode 100644 index 00000000..320b3378 --- /dev/null +++ b/zitadel/v2/project_role/resource_test.go @@ -0,0 +1,79 @@ +package project_role_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" +) + +func TestAccProjectRole(t *testing.T) { + resourceName := "zitadel_project_role" + initialProperty := "initialProperty" + updatedProperty := "updatedProperty" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + proj, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + projectID := proj.GetId() + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + role_key = "%s" + display_name = "display_name2" + group = "role_group" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, projectID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.ListProjectRoles(frame, &management.ListProjectRolesRequest{ + ProjectId: projectID, + Queries: []*project.RoleQuery{{ + Query: &project.RoleQuery_KeyQuery{ + KeyQuery: &project.RoleKeyQuery{Key: expected.(string)}, + }, + }}, + }) + if err != nil { + return err + } + actualRoles := resp.GetResult() + if len(actualRoles) == 0 { + return test_utils.ErrNotFound + } + if len(actualRoles) != 1 { + return fmt.Errorf("expected 1 role, but got %v", actualRoles) + } + actualRole := actualRoles[0].GetKey() + if actualRole != expected { + return fmt.Errorf("expected role key %s, but got %s", expected, actualRole) + } + return nil + } + } +} From 1c168430715b9f2d19fee6b3f2fe058ea94d2960 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 15:08:20 +0200 Subject: [PATCH 180/260] complete tests --- zitadel/v2/action/resource_test.go | 5 +- zitadel/v2/app_key/resource_test.go | 5 +- zitadel/v2/application_api/resource_test.go | 5 +- zitadel/v2/application_oidc/resource_test.go | 5 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- .../v2/default_login_texts/resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- zitadel/v2/domain/resource_test.go | 2 +- .../resource_test.go | 2 +- zitadel/v2/helper/test_utils/base_frame.go | 4 + zitadel/v2/helper/test_utils/org_frame.go | 44 ++++--- zitadel/v2/human_user/funcs.go | 5 +- zitadel/v2/human_user/resource_test.go | 5 +- zitadel/v2/idp_azure_ad/resource_test.go | 5 +- zitadel/v2/idp_github/resource_test.go | 5 +- zitadel/v2/idp_github_es/resource_test.go | 5 +- zitadel/v2/idp_gitlab/resource_test.go | 5 +- .../idp_gitlab_self_hosted/resource_test.go | 2 +- zitadel/v2/idp_google/resource_test.go | 5 +- zitadel/v2/idp_ldap/resource_test.go | 2 +- zitadel/v2/idp_utils/idp_test_utils/checks.go | 3 +- .../idp_utils/idp_test_utils/lifecyletest.go | 5 +- zitadel/v2/init_message_text/resource_test.go | 2 +- zitadel/v2/instance_member/resource_test.go | 80 +++++++++++++ zitadel/v2/login_texts/resource_test.go | 2 +- zitadel/v2/machine_key/resource_test.go | 67 +++++++++++ zitadel/v2/machine_user/funcs.go | 4 +- zitadel/v2/machine_user/resource_test.go | 57 +++++++++ zitadel/v2/org/resource_test.go | 60 ++++++++++ zitadel/v2/org_idp_azure_ad/resource_test.go | 2 +- zitadel/v2/org_idp_github/resource_test.go | 2 +- zitadel/v2/org_idp_github_es/resource_test.go | 2 +- zitadel/v2/org_idp_gitlab/resource_test.go | 2 +- .../resource_test.go | 2 +- zitadel/v2/org_idp_google/resource_test.go | 2 +- zitadel/v2/org_idp_ldap/resource_test.go | 2 +- .../org_idp_test_utils/checks.go | 3 +- .../org_idp_test_utils/lifecyletest.go | 5 +- zitadel/v2/org_member/resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- .../resource_test.go | 2 +- zitadel/v2/pat/resource_test.go | 66 +++++++++++ zitadel/v2/project/resource_test.go | 59 ++++++++++ zitadel/v2/project_grant/resource_test.go | 86 ++++++++++++++ zitadel/v2/project_grant_member/funcs.go | 2 +- .../v2/project_grant_member/resource_test.go | 109 ++++++++++++++++++ zitadel/v2/project_member/resource_test.go | 88 ++++++++++++++ zitadel/v2/sms_provider_twilio/const.go | 2 +- zitadel/v2/sms_provider_twilio/funcs.go | 10 +- zitadel/v2/sms_provider_twilio/resource.go | 2 +- .../v2/sms_provider_twilio/resource_test.go | 60 ++++++++++ zitadel/v2/smtp_config/const.go | 2 +- zitadel/v2/smtp_config/funcs.go | 8 +- zitadel/v2/smtp_config/resource.go | 2 +- zitadel/v2/smtp_config/resource_test.go | 63 ++++++++++ zitadel/v2/user_grant/resource_test.go | 94 +++++++++++++++ .../resource_test.go | 2 +- .../resource_test.go | 2 +- 64 files changed, 999 insertions(+), 95 deletions(-) create mode 100644 zitadel/v2/instance_member/resource_test.go create mode 100644 zitadel/v2/machine_key/resource_test.go create mode 100644 zitadel/v2/machine_user/resource_test.go create mode 100644 zitadel/v2/org/resource_test.go create mode 100644 zitadel/v2/pat/resource_test.go create mode 100644 zitadel/v2/project/resource_test.go create mode 100644 zitadel/v2/project_grant/resource_test.go create mode 100644 zitadel/v2/project_grant_member/resource_test.go create mode 100644 zitadel/v2/project_member/resource_test.go create mode 100644 zitadel/v2/sms_provider_twilio/resource_test.go create mode 100644 zitadel/v2/smtp_config/resource_test.go create mode 100644 zitadel/v2/user_grant/resource_test.go diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index dbb7d563..6f78f095 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELAction(t *testing.T) { +func TestAccAction(t *testing.T) { resourceName := "zitadel_action" initialProperty := "initialproperty" updatedProperty := "updatedproperty" @@ -44,8 +44,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: rs.Primary.ID}) + remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: frame.StateID(state)}) if err != nil { return err } diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 3b94d73d..207035f1 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELAppKey(t *testing.T) { +func TestAccAppKey(t *testing.T) { resourceName := "zitadel_application_key" initialProperty := "2500-01-01T08:45:00Z" updatedProperty := "2501-01-01T08:45:00Z" @@ -56,8 +56,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteResource, err := frame.GetAppKey(frame, &management.GetAppKeyRequest{KeyId: rs.Primary.ID, ProjectId: projectId, AppId: appId}) + remoteResource, err := frame.GetAppKey(frame, &management.GetAppKeyRequest{KeyId: frame.State(state).ID, ProjectId: projectId, AppId: appId}) if err != nil { return err } diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 18f8ab96..02758fc6 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELAppAPI(t *testing.T) { +func TestAccAppAPI(t *testing.T) { resourceName := "zitadel_application_api" initialProperty := "initialname" updatedProperty := "updatedname" @@ -49,8 +49,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) + remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: frame.State(state).ID, ProjectId: projectId}) if err != nil { return err } diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 3358ae00..6596866b 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELAppOIDC(t *testing.T) { +func TestAccAppOIDC(t *testing.T) { resourceName := "zitadel_application_oidc" initialProperty := "initialname" updatedProperty := "updatedname" @@ -62,8 +62,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: rs.Primary.ID, ProjectId: projectId}) + remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: frame.State(state).ID, ProjectId: projectId}) if err != nil { return err } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index d2e80706..5ede7fd4 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultDomainClaimedMessageText(t *testing.T) { +func TestAccDefaultDomainClaimedMessageText(t *testing.T) { resourceName := "zitadel_default_domain_claimed_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index 2f07f449..20d785ef 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultInitMessageText(t *testing.T) { +func TestAccDefaultInitMessageText(t *testing.T) { resourceName := "zitadel_default_init_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index e849c84a..378b32e1 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultLoginTexts(t *testing.T) { +func TestAccDefaultLoginTexts(t *testing.T) { resourceName := "zitadel_default_login_texts" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index 20359303..ac77ebb2 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultPasswordChangeMessageText(t *testing.T) { +func TestAccDefaultPasswordChangeMessageText(t *testing.T) { resourceName := "zitadel_default_password_change_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index d22a7d95..082d3f6b 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultPassswordResetMessageText(t *testing.T) { +func TestAccDefaultPassswordResetMessageText(t *testing.T) { resourceName := "zitadel_default_password_reset_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 7f59cd0a..8f71e2ef 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultPasswordlessRegistrationMessageText(t *testing.T) { +func TestAccDefaultPasswordlessRegistrationMessageText(t *testing.T) { resourceName := "zitadel_default_passwordless_registration_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index ae83551b..3c9a1cac 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultVerifyEmailMessageText(t *testing.T) { +func TestAccDefaultVerifyEmailMessageText(t *testing.T) { resourceName := "zitadel_default_verify_email_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index 859a3ee5..005a05d9 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDefaultVerifyPhoneMessageText(t *testing.T) { +func TestAccDefaultVerifyPhoneMessageText(t *testing.T) { resourceName := "zitadel_default_verify_phone_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 854d071d..085f8085 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -14,7 +14,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDomain(t *testing.T) { +func TestAccDomain(t *testing.T) { resourceName := "zitadel_domain" initialProperty := "initial.default.127.0.0.1.sslip.io" updatedProperty := "updated.default.127.0.0.1.sslip.io" diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index de9b4afa..374f00cf 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELDomainClaimedMessageText(t *testing.T) { +func TestAccDomainClaimedMessageText(t *testing.T) { resourceName := "zitadel_domain_claimed_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 65a70bad..b9381093 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -71,3 +71,7 @@ KEY } return frame, nil } + +func (b *BaseTestFrame) State(state *terraform.State) *terraform.InstanceState { + return state.RootModule().Resources[b.TerraformName].Primary +} diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index 362d9fa1..7a8bafb2 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -3,23 +3,31 @@ package test_utils import ( "context" - "github.com/zitadel/terraform-provider-zitadel/acceptance" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/zitadel-go/v2/pkg/client/admin" mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" -) -const ( - orgName = "terraform-tests" + "github.com/zitadel/terraform-provider-zitadel/acceptance" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) type OrgTestFrame struct { BaseTestFrame *mgmt.Client + Admin *admin.Client OrgID string } +func (o *OrgTestFrame) useOrgContext(orgID string) (err error) { + o.Client, err = helper.GetManagementClient(o.BaseTestFrame.ClientInfo, orgID) + if err != nil { + return err + } + o.Admin, err = helper.GetAdminClient(o.BaseTestFrame.ClientInfo) + o.OrgID = orgID + return err +} + func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { ctx := context.Background() cfg := acceptance.GetConfig().OrgLevel @@ -27,19 +35,23 @@ func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { if err != nil { return nil, err } - mgmtClient, err := helper.GetManagementClient(baseFrame.ClientInfo, "") - if err != nil { + orgFrame := &OrgTestFrame{ + BaseTestFrame: *baseFrame, + } + if err = orgFrame.useOrgContext(""); err != nil { return nil, err } - org, err := mgmtClient.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: "zitadel." + cfg.Domain}) + org, err := orgFrame.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: "zitadel." + cfg.Domain}) + orgFrame.OrgID = org.GetOrg().GetId() + return orgFrame, err +} + +func (o OrgTestFrame) AnotherOrg(name string) (*OrgTestFrame, error) { + org, err := o.Client.AddOrg(o, &management.AddOrgRequest{ + Name: name, + }) if err != nil { return nil, err } - orgID := org.GetOrg().GetId() - mgmtClient, err = helper.GetManagementClient(baseFrame.ClientInfo, orgID) - return &OrgTestFrame{ - BaseTestFrame: *baseFrame, - Client: mgmtClient, - OrgID: orgID, - }, err + return &o, o.useOrgContext(org.GetId()) } diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index 53bef6a5..04a86241 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -96,8 +96,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to create human user: %v", err) } d.SetId(respUser.UserId) - - return nil + // To avoid diffs for terraform plan -refresh=false right after creation, we query and set the computed values. + // The acceptance tests rely on this, too. + return read(ctx, d, m) } func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index 475bb2cd..6a8f08a0 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELHumanUser(t *testing.T) { +func TestAccHumanUser(t *testing.T) { resourceName := "zitadel_human_user" initialProperty := "test1@zitadel.com" updatedProperty := "test2@zitadel.com" @@ -52,8 +52,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: rs.Primary.ID}) + remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index 0e2a51d5..d44cca24 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -2,14 +2,15 @@ package idp_azure_ad_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPAzureAD(t *testing.T) { +func TestAccInstanceIdPAzureAD(t *testing.T) { resourceName := "zitadel_idp_azure_ad" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index 52e7fc8e..8b3c5362 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -2,14 +2,15 @@ package idp_github_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPGitHub(t *testing.T) { +func TestAccInstanceIdPGitHub(t *testing.T) { resourceName := "zitadel_idp_github" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index 45294a72..8958e775 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -2,14 +2,15 @@ package idp_github_es_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPGitHubES(t *testing.T) { +func TestAccInstanceIdPGitHubES(t *testing.T) { resourceName := "zitadel_idp_github_es" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index bd13a5c0..0a69b8c9 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -2,14 +2,15 @@ package idp_gitlab_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPGitLab(t *testing.T) { +func TestAccInstanceIdPGitLab(t *testing.T) { resourceName := "zitadel_idp_gitlab" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go index 141d998d..c81e7717 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPGitLabSelfHosted(t *testing.T) { +func TestAccInstanceIdPGitLabSelfHosted(t *testing.T) { resourceName := "zitadel_idp_gitlab_self_hosted" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index 81f38497..247e1ca4 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -2,14 +2,15 @@ package idp_google_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPGoogle(t *testing.T) { +func TestAccInstanceIdPGoogle(t *testing.T) { resourceName := "zitadel_idp_google" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/v2/idp_ldap/resource_test.go index ea464651..f629bf0d 100644 --- a/zitadel/v2/idp_ldap/resource_test.go +++ b/zitadel/v2/idp_ldap/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) -func TestAccZITADELInstanceIdPLDAP(t *testing.T) { +func TestAccInstanceIdPLDAP(t *testing.T) { resourceName := "zitadel_idp_ldap" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index 4b0fd3a9..e22b5f6b 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -14,8 +14,7 @@ import ( func CheckProviderName(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { return func(expectName interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: rs.Primary.ID}) + remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: frame.StateID(state)}) if err != nil { return err } diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index b9f45ef3..bce54ff3 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -29,15 +29,14 @@ func RunInstanceIDPLifecyleTest( CheckDestroy(frame), func(state *terraform.State) error { // Check the secret is imported correctly - currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes[secretAttribute] + actual := frame.State(state).Attributes[secretAttribute] if actual != importedSecret { return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) } return nil }, func(state *terraform.State) (string, error) { - lastState := state.RootModule().Resources[frame.TerraformName].Primary + lastState := frame.State(state) return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil }, "12345", diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 3087ee8f..3ad1ff04 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELInitMessageText(t *testing.T) { +func TestAccInitMessageText(t *testing.T) { resourceName := "zitadel_init_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go new file mode 100644 index 00000000..f415d112 --- /dev/null +++ b/zitadel/v2/instance_member/resource_test.go @@ -0,0 +1,80 @@ +package instance_member_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccInstanceMember(t *testing.T) { + resourceName := "zitadel_instance_member" + initialProperty := "ORG_OWNER" + updatedProperty := "ORG_OWNER_VIEWER" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ + UserName: frame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + userID := user.GetUserId() + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + user_id = "%s" + roles = ["%s"] +}`, resourceName, frame.UniqueResourcesID, userID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.Admin.ListIAMMembers(frame, &admin.ListIAMMembersRequest{ + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{UserIdQuery: &member.UserIDQuery{UserId: userID}}, + }}, + }) + if err != nil { + return err + } + if len(resp.Result) == 0 || len(resp.Result[0].Roles) == 0 { + return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) + } + actual := resp.Result[0].Roles[0] + if expected != actual { + return fmt.Errorf("expected role %s, but got %s", expected, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index 58cffbf3..b89db4c0 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELLoginTexts(t *testing.T) { +func TestAccLoginTexts(t *testing.T) { resourceName := "zitadel_login_texts" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go new file mode 100644 index 00000000..6db1168d --- /dev/null +++ b/zitadel/v2/machine_key/resource_test.go @@ -0,0 +1,67 @@ +package machine_key_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func TestAccMachineKey(t *testing.T) { + resourceName := "zitadel_machine_key" + initialProperty := "2050-01-01T00:00:00Z" + updatedProperty := "2051-01-01T00:00:00Z" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + user, err := frame.AddMachineUser(frame, &management.AddMachineUserRequest{ + UserName: frame.UniqueResourcesID, + Name: "Don't care", + }) + userID := user.GetUserId() + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + user_id = "%s" + key_type = "KEY_TYPE_JSON" + expiration_date = "%s" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetMachineKeyByIDs(frame, &management.GetMachineKeyByIDsRequest{ + UserId: userID, + KeyId: frame.State(state).ID, + }) + if err != nil { + return err + } + actual := resp.GetKey().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") + if expected != actual { + return fmt.Errorf("expected %s, but got %s", expected, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 29e1d0e5..6e302009 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -57,7 +57,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to create machine user: %v", err) } d.SetId(respUser.UserId) - return nil + // To avoid diffs for terraform plan -refresh=false right after creation, we query and set the computed values. + // The acceptance tests rely on this, too. + return read(ctx, d, m) } func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go new file mode 100644 index 00000000..f42634dd --- /dev/null +++ b/zitadel/v2/machine_user/resource_test.go @@ -0,0 +1,57 @@ +package machine_user_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccMachineUser(t *testing.T) { + resourceName := "zitadel_machine_user" + initialProperty := "Initial Service Account" + updatedProperty := "Updated Service Account" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, secretProperty interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + user_name = "%s" + name = "%s" + description = "description" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, frame.UniqueResourcesID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: frame.State(state).ID}) + if err != nil { + return err + } + actual := remoteResource.GetUser().GetMachine().GetName() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go new file mode 100644 index 00000000..a523b27e --- /dev/null +++ b/zitadel/v2/org/resource_test.go @@ -0,0 +1,60 @@ +package org_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccOrg(t *testing.T) { + resourceName := "zitadel_org" + initialProperty := "initialorgname" + updatedProperty := "updatedorgname" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + name = "%s" +}`, resourceName, frame.UniqueResourcesID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: frame.State(state).ID}) + if err != nil { + return err + } + actual := remoteResource.GetOrg().GetName() + if remoteResource.GetOrg().GetState() == org.OrgState_ORG_STATE_REMOVED { + return fmt.Errorf("org is removed: %w", test_utils.ErrNotFound) + } + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 056985e9..aca1250e 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) -func TestAccZITADELOrgIdPAzureAD(t *testing.T) { +func TestAccOrgIdPAzureAD(t *testing.T) { resourceName := "zitadel_org_idp_azure_ad" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index 5848e498..ea3c889d 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPGitHub(t *testing.T) { +func TestAccOrgIdPGitHub(t *testing.T) { resourceName := "zitadel_org_idp_github" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go index babd9d88..ffe5fc2d 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPGitHubES(t *testing.T) { +func TestAccOrgIdPGitHubES(t *testing.T) { resourceName := "zitadel_org_idp_github_es" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go index fcca111a..2f70aaaf 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPGitLab(t *testing.T) { +func TestAccOrgIdPGitLab(t *testing.T) { resourceName := "zitadel_org_idp_gitlab" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go index d975b5de..59a7acd3 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPGitLabSelfHosted(t *testing.T) { +func TestAccOrgIdPGitLabSelfHosted(t *testing.T) { resourceName := "zitadel_org_idp_gitlab_self_hosted" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go index 326849d5..c129df07 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPGoogle(t *testing.T) { +func TestAccOrgIdPGoogle(t *testing.T) { resourceName := "zitadel_org_idp_google" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index eb9c3b31..269905b2 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) -func TestAccZITADELOrgIdPLDAP(t *testing.T) { +func TestAccOrgIdPLDAP(t *testing.T) { resourceName := "zitadel_org_idp_ldap" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 39802798..89f48a5d 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -15,8 +15,7 @@ import ( func CheckProviderName(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { return func(expectName interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - rs := state.RootModule().Resources[frame.TerraformName] - remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: rs.Primary.ID}) + remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index bd84411c..1d667dd7 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -31,15 +31,14 @@ func RunOrgLifecyleTest( CheckDestroy(frame), func(state *terraform.State) error { // Check the secretAttribute is imported correctly - currentState := state.RootModule().Resources[frame.TerraformName].Primary - actual := currentState.Attributes[secretAttribute] + actual := frame.State(state).Attributes[secretAttribute] if actual != importedSecret { return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) } return nil }, func(state *terraform.State) (string, error) { - lastState := state.RootModule().Resources[frame.TerraformName].Primary + lastState := frame.State(state) return fmt.Sprintf("%s:%s:%s", lastState.Attributes[org_idp_utils.OrgIDVar], lastState.ID, importedSecret), nil }, "123:456", diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index f71500b0..89e083e7 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -44,7 +44,7 @@ resource "%s" "%s" { org_id = "%s" user_id = "%s" roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, user.GetUserId(), cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) }, initialProperty, updatedProperty, "", "", diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 7226a675..62a11f56 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELPasswordChangeMessageText(t *testing.T) { +func TestAccPasswordChangeMessageText(t *testing.T) { resourceName := "zitadel_password_change_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index ec7c915a..e2805d1a 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELPasswordResetMessageText(t *testing.T) { +func TestAccPasswordResetMessageText(t *testing.T) { resourceName := "zitadel_password_reset_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index c950859e..61427ba9 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELPasswordlessRegistrationMessageText(t *testing.T) { +func TestAccPasswordlessRegistrationMessageText(t *testing.T) { resourceName := "zitadel_passwordless_registration_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go new file mode 100644 index 00000000..5226a1ef --- /dev/null +++ b/zitadel/v2/pat/resource_test.go @@ -0,0 +1,66 @@ +package pat_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func TestAccPersonalAccessToken(t *testing.T) { + resourceName := "zitadel_personal_access_token" + initialProperty := "2050-01-01T00:00:00Z" + updatedProperty := "2051-01-01T00:00:00Z" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + user, err := frame.AddMachineUser(frame, &management.AddMachineUserRequest{ + UserName: frame.UniqueResourcesID, + Name: "Don't care", + }) + userID := user.GetUserId() + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + user_id = "%s" + expiration_date = "%s" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetPersonalAccessTokenByIDs(frame, &management.GetPersonalAccessTokenByIDsRequest{ + UserId: userID, + TokenId: frame.State(state).ID, + }) + if err != nil { + return err + } + actual := resp.GetToken().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") + if expected != actual { + return fmt.Errorf("expected %s, but got %s", expected, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go new file mode 100644 index 00000000..771431dd --- /dev/null +++ b/zitadel/v2/project/resource_test.go @@ -0,0 +1,59 @@ +package project_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccProject(t *testing.T) { + resourceName := "zitadel_project" + initialProperty := "initialproperty" + updatedProperty := "updatedproperty" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + project_role_assertion = true + project_role_check = true + has_project_check = true + private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetProjectByID(frame, &management.GetProjectByIDRequest{Id: frame.State(state).ID}) + if err != nil { + return err + } + actual := remoteResource.GetProject().GetName() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go new file mode 100644 index 00000000..93169130 --- /dev/null +++ b/zitadel/v2/project_grant/resource_test.go @@ -0,0 +1,86 @@ +package project_grant_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func TestAccProjectGrant(t *testing.T) { + resourceName := "zitadel_project_grant" + initialProperty := "initialProperty" + updatedProperty := "updatedProperty" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + projectID := project.GetId() + for _, role := range []string{initialProperty, updatedProperty} { + _, err = frame.AddProjectRole(frame, &management.AddProjectRoleRequest{ + ProjectId: projectID, + RoleKey: role, + DisplayName: role, + }) + if err != nil { + t.Fatalf("failed to create project role %s: %v", role, err) + } + } + org, err := frame.AddOrg(frame, &management.AddOrgRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create org: %v", err) + } + grantedOrgID := org.GetId() + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + granted_org_id = "%s" + role_keys = ["%s"] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, grantedOrgID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, projectID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetProjectGrantByID(frame, &management.GetProjectGrantByIDRequest{ + ProjectId: projectID, + GrantId: frame.StateID(state), + }) + if err != nil { + return err + } + actualRoleKeys := resp.GetProjectGrant().GetGrantedRoleKeys() + if len(actualRoleKeys) != 1 { + return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) + } + if expected != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + } + return nil + } + } +} diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index 94589882..2eb7d62a 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -130,7 +130,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn memberRes := resp.Result[0] set := map[string]interface{}{ userIDVar: userID, - orgIDVar: memberRes.GetDetails().GetResourceOwner(), + orgIDVar: org, projectIDVar: projectID, rolesVar: memberRes.GetRoles(), grantIDVar: grantID, diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go new file mode 100644 index 00000000..4406c381 --- /dev/null +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -0,0 +1,109 @@ +package project_grant_member_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func TestAccProjectGrantMember(t *testing.T) { + resourceName := "zitadel_project_grant_member" + initialProperty := "PROJECT_GRANT_OWNER" + updatedProperty := "PROJECT_GRANT_OWNER_VIEWER" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + projectID := project.GetId() + otherOrgFrame, err := frame.AnotherOrg(frame.UniqueResourcesID) + if err != nil { + t.Fatalf("failed to switch to another org: %v", err) + } + grant, err := frame.AddProjectGrant(frame, &management.AddProjectGrantRequest{ + ProjectId: projectID, + GrantedOrgId: otherOrgFrame.OrgID, + }) + if err != nil { + t.Fatalf("failed create project grant: %v", err) + } + grantID := grant.GetGrantId() + otherOrgUser, err := otherOrgFrame.ImportHumanUser(otherOrgFrame, &management.ImportHumanUserRequest{ + UserName: otherOrgFrame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + otherOrgUserID := otherOrgUser.GetUserId() + if err != nil { + t.Fatalf("failed to create otherOrgUser: %v", err) + } + test_utils.RunLifecyleTest( + t, + otherOrgFrame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + grant_id = "%s" + user_id = "%s" + roles = ["%s"] +}`, resourceName, otherOrgFrame.UniqueResourcesID, otherOrgFrame.OrgID, projectID, grantID, otherOrgUserID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, grantID, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.ListProjectGrantMembers(frame, &management.ListProjectGrantMembersRequest{ + ProjectId: projectID, + GrantId: grantID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{ + UserIdQuery: &member.UserIDQuery{ + UserId: userID, + }, + }, + }}, + }) + if err != nil { + return err + } + if len(resp.Result) != 1 { + return fmt.Errorf("expected 1 result, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) + } + actualRoleKeys := resp.Result[0].GetRoles() + if len(actualRoleKeys) != 1 { + return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) + } + if expected != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + } + return nil + } + } +} diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go new file mode 100644 index 00000000..5a0d9865 --- /dev/null +++ b/zitadel/v2/project_member/resource_test.go @@ -0,0 +1,88 @@ +package project_member_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccProjectMember(t *testing.T) { + resourceName := "zitadel_project_member" + initialProperty := "PROJECT_OWNER" + updatedProperty := "PROJECT_OWNER_VIEWER" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + projectID := project.GetId() + user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ + UserName: frame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + userID := user.GetUserId() + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + user_id = "%s" + roles = ["%s"] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, projectID, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.ListProjectMembers(frame, &management.ListProjectMembersRequest{ + ProjectId: projectID, + Queries: []*member.SearchQuery{{ + Query: &member.SearchQuery_UserIdQuery{UserIdQuery: &member.UserIDQuery{UserId: userID}}, + }}, + }) + if err != nil { + return err + } + if len(resp.Result) == 0 || len(resp.Result[0].Roles) == 0 { + return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) + } + actual := resp.Result[0].Roles[0] + if expected != actual { + return fmt.Errorf("expected role %s, but got %s", expected, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/sms_provider_twilio/const.go b/zitadel/v2/sms_provider_twilio/const.go index f17c362f..d0367b0f 100644 --- a/zitadel/v2/sms_provider_twilio/const.go +++ b/zitadel/v2/sms_provider_twilio/const.go @@ -2,6 +2,6 @@ package sms_provider_twilio const ( sidVar = "sid" - tokenVar = "token" + TokenVar = "token" senderNumberVar = "sender_number" ) diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go index 7aaf739a..4fe1209e 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -46,7 +46,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddSMSProviderTwilio(ctx, &admin.AddSMSProviderTwilioRequest{ Sid: d.Get(sidVar).(string), - Token: d.Get(tokenVar).(string), + Token: d.Get(TokenVar).(string), SenderNumber: d.Get(senderNumberVar).(string), }) if err != nil { @@ -81,10 +81,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChange(tokenVar) { + if d.HasChange(TokenVar) { _, err = client.UpdateSMSProviderTwilioToken(ctx, &admin.UpdateSMSProviderTwilioTokenRequest{ Id: d.Id(), - Token: d.Get(tokenVar).(string), + Token: d.Get(TokenVar).(string), }) if err != nil { return diag.Errorf("failed to update sms provider twilio: %v", err) @@ -122,8 +122,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn sidVar: resp.GetConfig().GetTwilio().GetSid(), senderNumberVar: resp.GetConfig().GetTwilio().GetSenderNumber(), } - if token, ok := d.GetOk(tokenVar); ok { - set[tokenVar] = token + if token, ok := d.GetOk(TokenVar); ok { + set[TokenVar] = token } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go index 43e61cf3..6e30fed7 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -13,7 +13,7 @@ func GetResource() *schema.Resource { Required: true, Description: "SID used to communicate with Twilio.", }, - tokenVar: { + TokenVar: { Type: schema.TypeString, Required: true, Description: "Token used to communicate with Twilio.", diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go new file mode 100644 index 00000000..a51b45ea --- /dev/null +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -0,0 +1,60 @@ +package sms_provider_twilio_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccSMSProviderTwilio(t *testing.T) { + resourceName := "zitadel_sms_provider_twilio" + initialProperty := "123456789" + updatedProperty := "987654321" + initialSecret := "initialSecret" + updatedSecret := "updatedSecret" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, secretProperty interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + sid = "sid" + sender_number = "%s" + token = "%s" +}`, resourceName, frame.UniqueResourcesID, configProperty, secretProperty) + }, + initialProperty, updatedProperty, + initialSecret, updatedSecret, + checkRemoteProperty(*frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckNothing, + nil, nil, "", sms_provider_twilio.TokenVar, + ) +} + +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetSMSProvider(frame, &admin.GetSMSProviderRequest{Id: frame.State(state).ID}) + if err != nil { + return fmt.Errorf("getting sms provider failed: %w", err) + } + actual := resp.GetConfig().GetTwilio().GetSenderNumber() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/smtp_config/const.go b/zitadel/v2/smtp_config/const.go index 289d1a6a..de45e186 100644 --- a/zitadel/v2/smtp_config/const.go +++ b/zitadel/v2/smtp_config/const.go @@ -6,5 +6,5 @@ const ( tlsVar = "tls" hostVar = "host" userVar = "user" - passwordVar = "password" + PasswordVar = "password" ) diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index 4703950b..733c8510 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -50,7 +50,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Host: d.Get(hostVar).(string), User: d.Get(userVar).(string), Tls: d.Get(tlsVar).(bool), - Password: d.Get(passwordVar).(string), + Password: d.Get(PasswordVar).(string), } resp, err := client.AddSMTPConfig(ctx, req) @@ -88,9 +88,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChange(passwordVar) { + if d.HasChange(PasswordVar) { _, err = client.UpdateSMTPConfigPassword(ctx, &admin.UpdateSMTPConfigPasswordRequest{ - Password: d.Get(passwordVar).(string), + Password: d.Get(PasswordVar).(string), }) if err != nil { return diag.Errorf("failed to update smtp config password: %v", err) @@ -128,7 +128,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn tlsVar: resp.GetSmtpConfig().GetTls(), hostVar: resp.GetSmtpConfig().GetHost(), userVar: resp.GetSmtpConfig().GetUser(), - passwordVar: d.Get(passwordVar).(string), + PasswordVar: d.Get(PasswordVar).(string), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index ee5b959e..a4d2e16e 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -33,7 +33,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "User used to communicate with your SMTP server.", }, - passwordVar: { + PasswordVar: { Type: schema.TypeString, Optional: true, Description: "Password used to communicate with your SMTP server.", diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go new file mode 100644 index 00000000..91052f99 --- /dev/null +++ b/zitadel/v2/smtp_config/resource_test.go @@ -0,0 +1,63 @@ +package smtp_config_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccSMTPConfig(t *testing.T) { + resourceName := "zitadel_smtp_config" + initialProperty := "initialProperty" + updatedProperty := "updatedProperty" + initialSecret := "initialSecret" + updatedSecret := "updatedSecret" + frame, err := test_utils.NewInstanceTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, secretProperty interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + sender_address = "address" + sender_name = "%s" + tls = true + host = "localhost:25" + user = "user" + password = "%s" +}`, resourceName, frame.UniqueResourcesID, configProperty, secretProperty) + }, + initialProperty, updatedProperty, + initialSecret, updatedSecret, + checkRemoteProperty(*frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckNothing, + nil, nil, "", smtp_config.PasswordVar, + ) +} + +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetSMTPConfig(frame, &admin.GetSMTPConfigRequest{}) + if err != nil { + return fmt.Errorf("getting smtp config failed: %w", err) + } + actual := resp.GetSmtpConfig().GetSenderName() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go new file mode 100644 index 00000000..dfe6263e --- /dev/null +++ b/zitadel/v2/user_grant/resource_test.go @@ -0,0 +1,94 @@ +package user_grant_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" +) + +func TestAccUserGrant(t *testing.T) { + resourceName := "zitadel_user_grant" + initialProperty := "initialProperty" + updatedProperty := "updatedProperty" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + project, err := frame.AddProject(frame, &management.AddProjectRequest{ + Name: frame.UniqueResourcesID, + }) + if err != nil { + t.Fatalf("failed to create project: %v", err) + } + projectID := project.GetId() + for _, role := range []string{initialProperty, updatedProperty} { + _, err = frame.AddProjectRole(frame, &management.AddProjectRoleRequest{ + ProjectId: projectID, + RoleKey: role, + DisplayName: role, + }) + if err != nil { + t.Fatalf("failed to create project role %s: %v", role, err) + } + } + user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ + UserName: frame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + if err != nil { + t.Fatalf("failed to create user: %v", err) + } + userID := user.GetUserId() + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(cfg, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + project_id = "%s" + user_id = "%s" + role_keys = ["%s"] +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, cfg) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(*frame, userID), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { + return func(expected interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetUserGrantByID(frame, &management.GetUserGrantByIDRequest{ + UserId: userID, + GrantId: frame.State(state).ID, + }) + if err != nil { + return err + } + actualRoleKeys := resp.GetUserGrant().GetRoleKeys() + if len(actualRoleKeys) != 1 { + return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) + } + if expected != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + } + return nil + } + } +} diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index ce86d3e8..499ca7e4 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELVerifyEmailMessageText(t *testing.T) { +func TestAccVerifyEmailMessageText(t *testing.T) { resourceName := "zitadel_verify_email_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index 0117c0fb..d589c0f2 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -12,7 +12,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func TestAccZITADELVerifyPhoneMessageText(t *testing.T) { +func TestAccVerifyPhoneMessageText(t *testing.T) { resourceName := "zitadel_verify_phone_message_text" initialProperty := "initialtitle" updatedProperty := "updatedtitle" From 2485d2d07eb6aba0b4750d9cd60f4fd3eda0a4a1 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 15:54:35 +0200 Subject: [PATCH 181/260] complete tests --- zitadel/v2/action/resource_test.go | 2 +- zitadel/v2/idp_utils/idp_test_utils/checks.go | 2 +- zitadel/v2/instance_member/resource_test.go | 4 +- zitadel/v2/org_idp_jwt/resource_test.go | 61 +++++++++++++++++++ zitadel/v2/org_idp_oidc/resource_test.go | 33 ++++++++++ zitadel/v2/project_grant/resource_test.go | 2 +- 6 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 zitadel/v2/org_idp_jwt/resource_test.go create mode 100644 zitadel/v2/org_idp_oidc/resource_test.go diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 6f78f095..432e35cd 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -44,7 +44,7 @@ resource "%s" "%s" { func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { return func(expect interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: frame.StateID(state)}) + remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: frame.State(state).ID}) if err != nil { return err } diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index e22b5f6b..a71d1eb6 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -14,7 +14,7 @@ import ( func CheckProviderName(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { return func(expectName interface{}) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: frame.StateID(state)}) + remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index f415d112..ecf64566 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -16,8 +16,8 @@ import ( func TestAccInstanceMember(t *testing.T) { resourceName := "zitadel_instance_member" - initialProperty := "ORG_OWNER" - updatedProperty := "ORG_OWNER_VIEWER" + initialProperty := "IAM_OWNER" + updatedProperty := "IAM_OWNER_VIEWER" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go new file mode 100644 index 00000000..e44e93a6 --- /dev/null +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -0,0 +1,61 @@ +package org_idp_jwt_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccOrgIDPJWT(t *testing.T) { + resourceName := "zitadel_org_idp_jwt" + initialProperty := "https://initialproperty.com" + updatedProperty := "https://updatedproperty.com" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + func(configProperty, _ interface{}) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + styling_type = "STYLING_TYPE_UNSPECIFIED" + jwt_endpoint = "%s" + issuer = "https://google.com" + keys_endpoint = "https://jwtendpoint.com/keys" + header_name = "x-auth-token" + auto_register = false +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, frame.UniqueResourcesID, configProperty) + }, + initialProperty, updatedProperty, + "", "", + checkRemoteProperty(frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { + return func(expect interface{}) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{Id: frame.State(state).ID}) + if err != nil { + return err + } + actual := remoteResource.GetIdp().GetJwtConfig().GetJwtEndpoint() + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go new file mode 100644 index 00000000..9b42c70f --- /dev/null +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -0,0 +1,33 @@ +package org_idp_oidc_test + +import ( + "fmt" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" +) + +func TestAccOrgIdPOIDC(t *testing.T) { + resourceName := "zitadel_org_idp_oidc" + frame, err := test_utils.NewOrgTestFrame(resourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { + return fmt.Sprintf(` +resource "%s" "%s" { + org_id = "%s" + name = "%s" + client_id = "aclientid" + client_secret = "%s" + styling_type = "STYLING_TYPE_UNSPECIFIED" + issuer = "https://google.com" + scopes = ["openid", "profile", "email"] + display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" + auto_register = false +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) + }, idp_utils.ClientSecretVar) +} diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 93169130..afe43c29 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -68,7 +68,7 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(i return func(state *terraform.State) error { resp, err := frame.GetProjectGrantByID(frame, &management.GetProjectGrantByIDRequest{ ProjectId: projectID, - GrantId: frame.StateID(state), + GrantId: frame.State(state).ID, }) if err != nil { return err From b7773e7fe904666a66119d73a37a30af3013e742 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 16:17:48 +0200 Subject: [PATCH 182/260] fix pipeline --- .github/workflows/pull_request.yaml | 12 ++---------- acceptance/keys/.gitignore | 1 + acceptance/keys/system-api-sa.pem | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 acceptance/keys/system-api-sa.pem diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 8209040b..a7ef0289 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -17,14 +17,6 @@ jobs: with: fetch-depth: 0 - - name: Make Machinekey Directory Writable - working-directory: acceptance - run: "chmod -R 777 machinekey" - - - name: Set up ZITADEL - working-directory: acceptance - run: docker compose up -d zitadel - - name: Set up Go uses: actions/setup-go@v3 with: @@ -33,9 +25,9 @@ jobs: - name: Download Go Modules run: go mod download - - name: Await ZITADEL + - name: Setup ZITADEL working-directory: acceptance - run: docker compose run wait_for_zitadel + run: docker compose run setup - name: Run Acceptance Tests run: TF_ACC=1 go test ./... diff --git a/acceptance/keys/.gitignore b/acceptance/keys/.gitignore index d6b7ef32..926b5abd 100644 --- a/acceptance/keys/.gitignore +++ b/acceptance/keys/.gitignore @@ -1,2 +1,3 @@ * !.gitignore +!system-api-sa.pem diff --git a/acceptance/keys/system-api-sa.pem b/acceptance/keys/system-api-sa.pem new file mode 100644 index 00000000..2c7a6e7f --- /dev/null +++ b/acceptance/keys/system-api-sa.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAzi+FFSJL7f5yw4KTwzgMP34ePGycm/M+kT0M7V4Cgx5V3EaD +IvTQKTLfBaEB45zb9LtjIXzDw0rXRoS2hO6th+CYQCz3KCvh09C0IzxZiB2IS3H/ +aT+5Bx9EFY+vnAkZjccbyG5YNRvmtOlnvIeIH7qZ0tEwkPfF5GEZNPJPtmy3UGV7 +iofdVQS1xRj73+aMw5rvH4D8IdyiAC3VekIbpt0Vj0SUX3DwKtog337BzTiPk3aX +RF0sbFhQoqdJRI8NqgZjCwjq9yfI5tyxYswn+JGzHGdHvW3idODlmwEt5K2pasiR +IWK2OGfq+w0EcltQHabuqEPgZlmhCkRdNfixBwIDAQABAoIBAA9jNoBkRdxmH/R9 +Wz+3gBqA9Aq4ZFuzJJk8QCm62V8ltWyyCnliYeKhPEm0QWrWOwghr/1AzW9Wt4g4 +wVJcabD5TwODF5L0626eZcM3bsscwR44TMJzEgD5EWC2j3mKqFCPaoBj08tq4KXh +wW8tgjgz+eTk3cYD583qfTIZX1+SzSMBpetTBsssQtGhhOB/xPiuL7hi+fXmV2rh +8mc9X6+wJ5u3zepsyK0vBeEDmurD4ZUIXFrZ0WCB/wNkSW9VKyoH+RC1asQAgqTz +glJ/NPbDJSKGvSBQydoKkqoXx7MVJ8VObFddfgo4dtOoz6YCfUVBHt8qy+E5rz5y +CICjL/kCgYEA9MnHntVVKNXtEFZPo02xgCwS3eG27ZwjYgJ1ZkCHM5BuL4MS7qbr +743/POs1Ctaok0udHl1PFB4uAG0URnmkUnWzcoJYb6Plv03F0LRdsnfuhehfIxLP +nWvxSm5n21H4ytfxm0BWY09JkLDnJZtXrgTILbuqb9Wy6TmAvUaF2YUCgYEA16Ec +ywSaLVdqPaVpsTxi7XpRJAB2Isjp6RffNEecta4S0LL7s/IO3QXDH9SYpgmgCTah +3aXhpT4hIFlpg3eBjVfbOwgqub8DgirnSQyQt99edUtHIK+K8nMdGxz6X6pfTKzK +asSH7qPlt5tz1621vC0ocXSZR7zm99/FgwILwBsCgYBOsP8nJFV4By1qbxSy3qsN +FR4LjiAMSoFlZHzxHhVYkjmZtH1FkwuNuwwuPT6T+WW/1DLyK/Tb9se7A1XdQgV9 +LLE/Qn/Dg+C7mvjYmuL0GHHpQkYzNDzh0m2DC/L/Il7kdn8I9anPyxFPHk9wW3vY +SVlAum+T/BLDvuSP9DfbMQKBgCc1j7PG8XYfOB1fj7l/volqPYjrYI/wssAE7Dxo +bTGIJrm2YhiVgmhkXNfT47IFfAlQ2twgBsjyZDmqqIoUWAVonV+9m29NMYkg3g+l +bkdRIa74ckWaRgzSK8+7VDfDFjMuFFyXwhP9z460gLsORkaie4Et75Vg3yrhkNvC +qnpTAoGBAMguDSWBbCewXnHlKGFpm+LH+OIvVKGEhtCSvfZojtNrg/JBeBebSL1n +mmT1cONO+0O5bz7uVaRd3JdnH2JFevY698zFfhVsjVCrm+fz31i5cxAgC39G2Lfl +YkTaa1AFLstnf348ZjuvBN3USUYZo3X3mxnS+uluVuRSGwIKsN0a +-----END RSA PRIVATE KEY----- From 911b927048d122b6cc18bfc1104932605c79bc1e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 16:29:30 +0200 Subject: [PATCH 183/260] fix setup --- .github/workflows/pull_request.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index a7ef0289..2d2c1a6d 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -25,6 +25,10 @@ jobs: - name: Download Go Modules run: go mod download + - name: Make Machinekey Directory Writable + working-directory: acceptance + run: "chmod -R 777 keys" + - name: Setup ZITADEL working-directory: acceptance run: docker compose run setup @@ -32,16 +36,16 @@ jobs: - name: Run Acceptance Tests run: TF_ACC=1 go test ./... - - name: Save ZITADEL Logs + - name: Save Docker Compose Logs working-directory: acceptance if: always() - run: docker compose logs zitadel > .zitadel.log + run: docker compose logs > .docker-compose.log - - name: Archive ZITADEL Logs + - name: Archive Docker Compose Logs if: always() uses: actions/upload-artifact@v3 with: name: pull-request-tests path: | - acceptance/.zitadel.log + acceptance/.docker-compose.log retention-days: 30 From dfaf50d9e5667e23e28e2bcb8533568b40b20cdb Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 16:56:25 +0200 Subject: [PATCH 184/260] restore previous test results --- .github/workflows/pull_request.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 2d2c1a6d..c0af2ce5 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -33,6 +33,20 @@ jobs: working-directory: acceptance run: docker compose run setup + - name: Set Cache Path + id: go-cache-path + run: echo "GO_CACHE_PATH=$(go env GOCACHE)" >> $GITHUB_OUTPUT + + - name: Restore Previous Results + uses: actions/cache/restore@v3 + id: cache + timeout-minutes: 1 + with: + key: acceptance-test-${{ hashFiles( 'go.*', 'acceptance', 'zitadel/**/*.go') }} + restore-keys: | + acceptance-test-postgres-core- + path: ${{ steps.go-cache-path.outputs.GO_CACHE_PATH }} + - name: Run Acceptance Tests run: TF_ACC=1 go test ./... From c5a8b5046c2db987ab70e26f80012e446a198b67 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 16:59:24 +0200 Subject: [PATCH 185/260] fix cache key --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index c0af2ce5..0f7b082c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -44,7 +44,7 @@ jobs: with: key: acceptance-test-${{ hashFiles( 'go.*', 'acceptance', 'zitadel/**/*.go') }} restore-keys: | - acceptance-test-postgres-core- + acceptance-test- path: ${{ steps.go-cache-path.outputs.GO_CACHE_PATH }} - name: Run Acceptance Tests From ac77f5df529b69c79956ab744fec47b8968a332d Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 17:23:12 +0200 Subject: [PATCH 186/260] cache results --- .github/workflows/pull_request.yaml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 0f7b082c..ceaf0453 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -33,26 +33,37 @@ jobs: working-directory: acceptance run: docker compose run setup - - name: Set Cache Path - id: go-cache-path - run: echo "GO_CACHE_PATH=$(go env GOCACHE)" >> $GITHUB_OUTPUT + - name: Set Cache Variables + id: go-cache-variables + run: | + echo "GO_CACHE_PATH=$(go env GOCACHE)" >> $GITHUB_OUTPUT + echo "GO_CACHE_KEY_PREFIX=${GO_CACHE_KEY_PREFIX}" >> $GITHUB_OUTPUT + echo "GO_CACHE_KEY=${GO_CACHE_KEY_PREFIX}${{ hashFiles( 'go.*', 'acceptance', 'zitadel/**/*.go') }}" >> $GITHUB_OUTPUT + env: + GO_CACHE_KEY_PREFIX: acceptance-test- - name: Restore Previous Results uses: actions/cache/restore@v3 id: cache timeout-minutes: 1 with: - key: acceptance-test-${{ hashFiles( 'go.*', 'acceptance', 'zitadel/**/*.go') }} - restore-keys: | - acceptance-test- - path: ${{ steps.go-cache-path.outputs.GO_CACHE_PATH }} + key: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY }} + restore-keys: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY_PREFIX }} + path: ${{ steps.go-cache-variables.outputs.GO_CACHE_PATH }} - name: Run Acceptance Tests run: TF_ACC=1 go test ./... + - name: Cache Results + if: always() + uses: actions/cache/save@v3 + with: + key: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY }} + path: ${{ steps.go-cache-variables.outputs.GO_CACHE_PATH }} + - name: Save Docker Compose Logs - working-directory: acceptance if: always() + working-directory: acceptance run: docker compose logs > .docker-compose.log - name: Archive Docker Compose Logs From a5b7b7f946f6e431ab18553118a39da32182abab Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 17:24:25 +0200 Subject: [PATCH 187/260] cache modules --- .github/workflows/pull_request.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index ceaf0453..b649419e 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -22,9 +22,6 @@ jobs: with: go-version: 1.19 - - name: Download Go Modules - run: go mod download - - name: Make Machinekey Directory Writable working-directory: acceptance run: "chmod -R 777 keys" @@ -51,6 +48,9 @@ jobs: restore-keys: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY_PREFIX }} path: ${{ steps.go-cache-variables.outputs.GO_CACHE_PATH }} + - name: Download Go Modules + run: go mod download + - name: Run Acceptance Tests run: TF_ACC=1 go test ./... From 72a64a589585a4f1989b7e4169e51c2d68b48623 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 21 Jul 2023 18:17:28 +0200 Subject: [PATCH 188/260] cover --- .github/workflows/pull_request.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index b649419e..2d331fdc 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -52,7 +52,14 @@ jobs: run: go mod download - name: Run Acceptance Tests - run: TF_ACC=1 go test ./... + run: TF_ACC=1 go test -coverprofile=profile.cov ./... + + - name: Publish Coverage + uses: codecov/codecov-action@v3.1.4 + with: + file: profile.cov + name: acceptance-tests + flags: acceptance-tests - name: Cache Results if: always() From 348824792fb192efb990eb49960fcda9e7299b62 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 24 Jul 2023 11:19:11 +0200 Subject: [PATCH 189/260] restore mtimes --- .github/workflows/pull_request.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 2d331fdc..6f22716c 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -17,6 +17,9 @@ jobs: with: fetch-depth: 0 + - name: Restore Timestamps for Go Test Caching + uses: chetan/git-restore-mtime-action@v2 + - name: Set up Go uses: actions/setup-go@v3 with: From 2e87004e466a03fbbd7c16ff2ee36b8abb16c9c8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 24 Jul 2023 12:13:51 +0200 Subject: [PATCH 190/260] restore mtimes --- .github/workflows/pull_request.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 6f22716c..c238ad5b 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -17,9 +17,6 @@ jobs: with: fetch-depth: 0 - - name: Restore Timestamps for Go Test Caching - uses: chetan/git-restore-mtime-action@v2 - - name: Set up Go uses: actions/setup-go@v3 with: @@ -54,6 +51,9 @@ jobs: - name: Download Go Modules run: go mod download + - name: Restore Timestamps for Go Test Caching + uses: chetan/git-restore-mtime-action@v2 + - name: Run Acceptance Tests run: TF_ACC=1 go test -coverprofile=profile.cov ./... From 03191ce04f029e19825002c883d5d9cf667f324e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 24 Jul 2023 12:37:25 +0200 Subject: [PATCH 191/260] use standard caching --- .github/workflows/pull_request.yaml | 32 ++--------------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index c238ad5b..bb0094eb 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -18,9 +18,9 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: '1.19' - name: Make Machinekey Directory Writable working-directory: acceptance @@ -30,30 +30,9 @@ jobs: working-directory: acceptance run: docker compose run setup - - name: Set Cache Variables - id: go-cache-variables - run: | - echo "GO_CACHE_PATH=$(go env GOCACHE)" >> $GITHUB_OUTPUT - echo "GO_CACHE_KEY_PREFIX=${GO_CACHE_KEY_PREFIX}" >> $GITHUB_OUTPUT - echo "GO_CACHE_KEY=${GO_CACHE_KEY_PREFIX}${{ hashFiles( 'go.*', 'acceptance', 'zitadel/**/*.go') }}" >> $GITHUB_OUTPUT - env: - GO_CACHE_KEY_PREFIX: acceptance-test- - - - name: Restore Previous Results - uses: actions/cache/restore@v3 - id: cache - timeout-minutes: 1 - with: - key: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY }} - restore-keys: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY_PREFIX }} - path: ${{ steps.go-cache-variables.outputs.GO_CACHE_PATH }} - - name: Download Go Modules run: go mod download - - name: Restore Timestamps for Go Test Caching - uses: chetan/git-restore-mtime-action@v2 - - name: Run Acceptance Tests run: TF_ACC=1 go test -coverprofile=profile.cov ./... @@ -64,13 +43,6 @@ jobs: name: acceptance-tests flags: acceptance-tests - - name: Cache Results - if: always() - uses: actions/cache/save@v3 - with: - key: ${{ steps.go-cache-variables.outputs.GO_CACHE_KEY }} - path: ${{ steps.go-cache-variables.outputs.GO_CACHE_PATH }} - - name: Save Docker Compose Logs if: always() working-directory: acceptance From 171449efdccb9d3fd2639b9a0b808c230b37cf65 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 16:59:31 +0200 Subject: [PATCH 192/260] pin zitadel version --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 69a150d4..d6707a91 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -3,7 +3,7 @@ version: '3.8' services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.31.4}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From 6aa53b2c11c20f16599b052c5a58af7274804cd3 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 17:02:18 +0200 Subject: [PATCH 193/260] go 1.20 --- .github/workflows/pull_request.yaml | 2 +- .github/workflows/release.yml | 2 +- acceptance/Dockerfile | 2 +- go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index bb0094eb..0246c117 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.19' + go-version-file: 'go.mod' - name: Make Machinekey Directory Writable working-directory: acceptance diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5180d35..be760909 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,4 +42,4 @@ jobs: env: GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} # GitHub sets this automatically - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/acceptance/Dockerfile b/acceptance/Dockerfile index 8d3525fa..c2c3fc64 100644 --- a/acceptance/Dockerfile +++ b/acceptance/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine +FROM golang:1.20-alpine RUN apk add curl jq RUN go install github.com/zitadel/zitadel-tools@v0.4.0 COPY setup.sh config.json / diff --git a/go.mod b/go.mod index da35549e..1cf76af5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zitadel/terraform-provider-zitadel -go 1.19 +go 1.20 require ( github.com/envoyproxy/protoc-gen-validate v1.0.1 From edeef3f75504502bf2bedc63d96be1f3f961e532 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 17:30:31 +0200 Subject: [PATCH 194/260] enforce formatted imports --- .github/workflows/pull_request.yaml | 30 ++++++++++++++++ .golangci.yml | 10 ++++++ CONTRIBUTING.md | 12 +++++-- go.mod | 28 +++++---------- go.sum | 55 +++++++++++------------------ tools.go | 8 ----- 6 files changed, 79 insertions(+), 64 deletions(-) create mode 100644 .golangci.yml delete mode 100644 tools.go diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 0246c117..e9d49227 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -3,6 +3,36 @@ name: Test Provider on: pull_request jobs: + + lint: + + runs-on: ubuntu-20.04 + + permissions: + contents: read + + steps: + + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + cache: false + + - name: Lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.53.3 + github-token: ${{ github.token }} + only-new-issues: true + skip-pkg-cache: true + skip-build-cache: true + test: runs-on: ubuntu-20.04 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..e0fbee72 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,10 @@ +linters: + disable-all: true + enable: + - goimports +linters-settings: + goimports: + # A comma-separated list of prefixes, which, if set, checks import paths + # with the given prefixes are grouped after 3rd-party packages. + # Default: "" + local-prefixes: github.com/zitadel/terraform-provider-zitadel diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd216f08..4516079d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,8 +36,16 @@ Run the accepance tests using the machine key generated by ZITADEL. TF_ACC=1 go test ./... ``` +# Ensure the code is formatted correctly + +```bash +go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3 run --fix +``` + # Generate Docs 1. Manually maintain files in /templates and /examples -1. Install the tool tfplugindocs with `go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs` -1. Generate the docs with `tfplugindocs generate` +1. Generate the docs +```bash +go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.14.1 generate + ``` diff --git a/go.mod b/go.mod index 1cf76af5..c7b62d3c 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,8 @@ require ( github.com/envoyproxy/protoc-gen-validate v1.0.1 github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 - github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-framework v0.15.0 github.com/hashicorp/terraform-plugin-go v0.14.3 github.com/hashicorp/terraform-plugin-log v0.8.0 @@ -17,23 +16,17 @@ require ( github.com/zitadel/oidc v1.13.4 github.com/zitadel/zitadel-go/v2 v2.0.14 golang.org/x/oauth2 v0.8.0 - google.golang.org/grpc v1.53.0 + google.golang.org/grpc v1.53.0-dev google.golang.org/protobuf v1.30.0 ) require ( - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/armon/go-radix v1.0.0 // indirect - github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/fatih/color v1.15.0 // indirect github.com/go-test/deep v1.0.7 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -52,31 +45,28 @@ require ( github.com/hashicorp/terraform-registry-address v0.1.0 // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect - github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mitchellh/cli v1.1.5 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect - github.com/posener/complete v1.2.3 // indirect - github.com/russross/blackfriday v1.6.0 // indirect - github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/cast v1.5.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.13.1 // indirect - golang.org/x/crypto v0.7.0 // indirect + golang.org/x/crypto v0.9.0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect + google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index ace72bfb..0f9e9312 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,7 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= @@ -21,10 +17,7 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE 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/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -35,10 +28,10 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/envoyproxy/protoc-gen-validate v1.0.1 h1:kt9FtLiooDc0vbwTLhdg3dyNX1K9Qwa1EK9LcD4jVUQ= github.com/envoyproxy/protoc-gen-validate v1.0.1/go.mod h1:0vj8bNkYbSTNS2PIyH87KZaeN4x9zpL9Qt8fQC7d+vs= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= @@ -69,14 +62,12 @@ 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/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -111,8 +102,6 @@ github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.16.0 h1:UKkeWRWb23do5LNAFlh/K3N0ymn1qTOO8c+85Albo3s= github.com/hashicorp/terraform-json v0.16.0/go.mod h1:v0Ufk9jJnk6tcIZvScHvetlKfiNTC+WS21mnXIlc0B0= -github.com/hashicorp/terraform-plugin-docs v0.14.1 h1:MikFi59KxrP/ewrZoaowrB9he5Vu4FtvhamZFustiA4= -github.com/hashicorp/terraform-plugin-docs v0.14.1/go.mod h1:k2NW8+t113jAus6bb5tQYQgEAX/KueE/u8X2Z45V1GM= github.com/hashicorp/terraform-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q= github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+3BL/DBBxFEki+j0= @@ -130,7 +119,6 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod 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/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -147,7 +135,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -163,9 +152,9 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 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/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -184,25 +173,20 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= -github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -211,7 +195,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +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/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -241,8 +226,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -324,10 +309,10 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 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-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= -google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/grpc v1.53.0-dev h1:Bi96+XIrXJLXPJUff19tRXb7mIijir7agn12zNMaPAg= +google.golang.org/grpc v1.53.0-dev/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= diff --git a/tools.go b/tools.go deleted file mode 100644 index f770edf2..00000000 --- a/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build tools -// +build tools - -package tools - -import ( - _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" -) From 7b38825f118dc398b447ed38ff0059565d0bbc97 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 17:31:08 +0200 Subject: [PATCH 195/260] gen docs --- docs/resources/org_idp_jwt.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 094141db..0c355353 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -18,7 +18,7 @@ resource zitadel_org_idp_jwt jwt_idp { styling_type = "STYLING_TYPE_UNSPECIFIED" jwt_endpoint = "https://jwtendpoint.com" issuer = "https://google.com" - keys_endpoint = "https://jwtendpoint.com/cfg" + keys_endpoint = "https://jwtendpoint.com/keys" header_name = "x-auth-token" auto_register = false } @@ -40,4 +40,4 @@ resource zitadel_org_idp_jwt jwt_idp { ### Read-Only -- `id` (String) The ID of this resource. +- `id` (String) The ID of this resource. \ No newline at end of file From f4d64fa882e0f71ec99cac355f99fb7377c3e3d4 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 17:32:12 +0200 Subject: [PATCH 196/260] format imports --- .../v2/default_domain_claimed_message_text/resource_test.go | 1 + zitadel/v2/default_domain_policy/resource_test.go | 1 + zitadel/v2/default_init_message_text/resource_test.go | 1 + zitadel/v2/default_label_policy/resource_test.go | 1 + zitadel/v2/default_lockout_policy/resource_test.go | 1 + zitadel/v2/default_login_policy/resource_test.go | 1 + zitadel/v2/default_login_texts/resource_test.go | 1 + zitadel/v2/default_notification_policy/resource_test.go | 1 + zitadel/v2/default_oidc_settings/resource_test.go | 1 + .../v2/default_password_change_message_text/resource_test.go | 1 + zitadel/v2/default_password_complexity_policy/resource_test.go | 1 + .../v2/default_password_reset_message_text/resource_test.go | 1 + .../resource_test.go | 1 + zitadel/v2/default_privacy_policy/resource_test.go | 1 + zitadel/v2/default_verify_email_message_text/resource_test.go | 1 + zitadel/v2/default_verify_phone_message_text/resource_test.go | 1 + zitadel/v2/domain_claimed_message_text/resource_test.go | 1 + zitadel/v2/domain_policy/resource_test.go | 1 + zitadel/v2/helper/test_utils/instance_frame.go | 3 ++- zitadel/v2/idp_azure_ad/datasource.go | 1 + zitadel/v2/idp_github/datasource.go | 1 + zitadel/v2/idp_github/resource.go | 1 + zitadel/v2/idp_github_es/datasource.go | 1 + zitadel/v2/idp_gitlab/datasource.go | 1 + zitadel/v2/idp_gitlab_self_hosted/datasource.go | 1 + zitadel/v2/idp_google/datasource.go | 1 + zitadel/v2/idp_ldap/datasource.go | 1 + zitadel/v2/idp_utils/idp_test_utils/checks.go | 3 ++- zitadel/v2/init_message_text/resource_test.go | 1 + zitadel/v2/label_policy/resource_test.go | 1 + zitadel/v2/lockout_policy/resource_test.go | 1 + zitadel/v2/login_policy/resource_test.go | 1 + zitadel/v2/login_texts/resource_test.go | 1 + zitadel/v2/machine_key/resource_test.go | 3 ++- zitadel/v2/notification_policy/resource_test.go | 1 + zitadel/v2/org_idp_azure_ad/datasource.go | 1 + zitadel/v2/org_idp_azure_ad/resource.go | 1 + zitadel/v2/org_idp_github/datasource.go | 1 + zitadel/v2/org_idp_github/resource.go | 1 + zitadel/v2/org_idp_github_es/datasource.go | 1 + zitadel/v2/org_idp_github_es/resource.go | 1 + zitadel/v2/org_idp_gitlab/datasource.go | 1 + zitadel/v2/org_idp_gitlab/resource.go | 1 + zitadel/v2/org_idp_gitlab_self_hosted/datasource.go | 1 + zitadel/v2/org_idp_gitlab_self_hosted/resource.go | 1 + zitadel/v2/org_idp_google/datasource.go | 1 + zitadel/v2/org_idp_google/resource.go | 1 + zitadel/v2/org_idp_ldap/datasource.go | 1 + zitadel/v2/org_idp_ldap/resource.go | 1 + zitadel/v2/password_change_message_text/resource_test.go | 1 + zitadel/v2/password_complexity_policy/resource_test.go | 1 + zitadel/v2/password_reset_message_text/resource_test.go | 1 + .../v2/passwordless_registration_message_text/resource_test.go | 1 + zitadel/v2/pat/resource_test.go | 3 ++- zitadel/v2/privacy_policy/resource_test.go | 1 + zitadel/v2/project_grant/resource_test.go | 3 ++- zitadel/v2/project_grant_member/resource_test.go | 3 ++- zitadel/v2/project_role/resource_test.go | 3 ++- zitadel/v2/sms_provider_twilio/resource_test.go | 1 + zitadel/v2/smtp_config/resource_test.go | 1 + zitadel/v2/user_grant/resource_test.go | 3 ++- zitadel/v2/verify_email_message_text/resource_test.go | 1 + zitadel/v2/verify_phone_message_text/resource_test.go | 1 + 63 files changed, 71 insertions(+), 8 deletions(-) diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 5ede7fd4..9ca07c8d 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index 8cd58933..52fb503e 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index 20d785ef..646543c1 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 9d941596..8b99e956 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index dadcb47f..dbb9c41e 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index d840aafb..a37a47a2 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index 378b32e1..e25d53f6 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 99bbd273..86b58c86 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 333e6c0f..403a225b 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index ac77ebb2..ff6f95e2 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 2b16547e..5b4f4d9e 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index 082d3f6b..22b4fc30 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 8f71e2ef..9a070b7f 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index 3a7832f7..fe8b8204 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 3c9a1cac..8df5ebba 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index 005a05d9..c0b89a0f 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index 374f00cf..42f5589a 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index ca6d9a1a..a5b07b1d 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/helper/test_utils/instance_frame.go b/zitadel/v2/helper/test_utils/instance_frame.go index 75ad727c..bb678dbb 100644 --- a/zitadel/v2/helper/test_utils/instance_frame.go +++ b/zitadel/v2/helper/test_utils/instance_frame.go @@ -3,9 +3,10 @@ package test_utils import ( "context" + "github.com/zitadel/zitadel-go/v2/pkg/client/admin" + "github.com/zitadel/terraform-provider-zitadel/acceptance" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/zitadel-go/v2/pkg/client/admin" ) type InstanceTestFrame struct { diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go index ae38d569..1f37f050 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -2,6 +2,7 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go index a8ec803b..ddf3cb0e 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/v2/idp_github/datasource.go @@ -2,6 +2,7 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index f3212694..94535392 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -2,6 +2,7 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go index f0556d16..d133e853 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/v2/idp_github_es/datasource.go @@ -2,6 +2,7 @@ package idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go index 8db640c3..3df2dda6 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -2,6 +2,7 @@ package idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go index fcc9ac96..d0779838 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -2,6 +2,7 @@ package idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go index 8d61ae8f..0cc78258 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/v2/idp_google/datasource.go @@ -2,6 +2,7 @@ package idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_ldap/datasource.go b/zitadel/v2/idp_ldap/datasource.go index 97fe7026..49a5d577 100644 --- a/zitadel/v2/idp_ldap/datasource.go +++ b/zitadel/v2/idp_ldap/datasource.go @@ -2,6 +2,7 @@ package idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index a71d1eb6..e2b52371 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -5,10 +5,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func CheckProviderName(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 3ad1ff04..0ff43ba7 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index aa78552e..d86e1ae1 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index 881eeb14..839e3236 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index b0a03a4f..0511b9d0 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index b89db4c0..86de56f4 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index 6db1168d..ff3360dd 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -6,8 +6,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccMachineKey(t *testing.T) { diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index 403796be..fbc61882 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index b40ad180..5719e8de 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -2,6 +2,7 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index 5defe974..d6b91af8 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -4,6 +4,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 5a7de757..984700b6 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -2,6 +2,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 4d31a42d..2c436ad9 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -2,6 +2,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index d7efac32..ab413b55 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -2,6 +2,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index 97ca3cf8..97442e81 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -2,6 +2,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index 0b74f7fa..b30198c0 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -2,6 +2,7 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index ca81b877..f08745cb 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -2,6 +2,7 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index 22f8bcaf..ebe1c761 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -2,6 +2,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index e5935907..a0733237 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -2,6 +2,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index 6bdfdc80..b4975069 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -2,6 +2,7 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 989cc632..40035b3a 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -2,6 +2,7 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go index 02c2cd15..74fc981e 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -2,6 +2,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/v2/org_idp_ldap/resource.go index 22ee99f6..40f2d2e1 100644 --- a/zitadel/v2/org_idp_ldap/resource.go +++ b/zitadel/v2/org_idp_ldap/resource.go @@ -2,6 +2,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 62a11f56..9600c367 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index cd7144c0..757c3bb2 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index e2805d1a..ae25528b 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index 61427ba9..e6ed6d9a 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index 5226a1ef..57a39949 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -6,8 +6,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccPersonalAccessToken(t *testing.T) { diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index f0082b6e..b758173d 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index afe43c29..3a476161 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -6,8 +6,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccProjectGrant(t *testing.T) { diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index 4406c381..b837a429 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -8,8 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccProjectGrantMember(t *testing.T) { diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index 320b3378..fe998527 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -6,9 +6,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccProjectRole(t *testing.T) { diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index a51b45ea..86df1453 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index 91052f99..9daa97aa 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index dfe6263e..4d101eea 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -6,8 +6,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccUserGrant(t *testing.T) { diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index 499ca7e4..f4627e04 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index d589c0f2..def654f5 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) From edac534ca2eb98e5b7846b4a7720b470eb2608bc Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 18:45:05 +0200 Subject: [PATCH 197/260] use generic comparable --- zitadel/v2/action/resource_test.go | 8 ++++---- zitadel/v2/app_key/resource_test.go | 8 ++++---- zitadel/v2/application_api/resource_test.go | 8 ++++---- zitadel/v2/application_oidc/resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../v2/default_domain_policy/resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../v2/default_label_policy/resource_test.go | 8 ++++---- .../default_lockout_policy/resource_test.go | 8 ++++---- .../v2/default_login_policy/resource_test.go | 8 ++++---- .../v2/default_login_texts/resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../v2/default_oidc_settings/resource_test.go | 10 +++++----- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../default_privacy_policy/resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- zitadel/v2/domain/resource_test.go | 10 +++++----- .../resource_test.go | 8 ++++---- zitadel/v2/domain_policy/resource_test.go | 8 ++++---- zitadel/v2/helper/test_utils/checks.go | 2 +- zitadel/v2/helper/test_utils/lifecyletest.go | 10 +++++----- zitadel/v2/human_user/resource_test.go | 20 +++++++++---------- zitadel/v2/idp_utils/idp_test_utils/checks.go | 4 ++-- .../idp_utils/idp_test_utils/lifecyletest.go | 6 ++---- zitadel/v2/init_message_text/resource_test.go | 8 ++++---- zitadel/v2/instance_member/resource_test.go | 14 ++++++------- zitadel/v2/label_policy/resource_test.go | 8 ++++---- zitadel/v2/lockout_policy/resource_test.go | 8 ++++---- zitadel/v2/login_policy/resource_test.go | 8 ++++---- zitadel/v2/login_texts/resource_test.go | 8 ++++---- zitadel/v2/machine_key/resource_test.go | 14 ++++++------- zitadel/v2/machine_user/resource_test.go | 8 ++++---- .../v2/notification_policy/resource_test.go | 8 ++++---- zitadel/v2/org/resource_test.go | 8 ++++---- zitadel/v2/org_idp_jwt/resource_test.go | 8 ++++---- .../org_idp_test_utils/checks.go | 4 ++-- .../org_idp_test_utils/lifecyletest.go | 6 ++---- zitadel/v2/org_member/resource_test.go | 14 ++++++------- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- zitadel/v2/pat/resource_test.go | 14 ++++++------- zitadel/v2/privacy_policy/resource_test.go | 8 ++++---- zitadel/v2/project/resource_test.go | 8 ++++---- zitadel/v2/project_grant/resource_test.go | 14 ++++++------- .../v2/project_grant_member/resource_test.go | 14 ++++++------- zitadel/v2/project_member/resource_test.go | 14 ++++++------- zitadel/v2/project_role/resource_test.go | 16 +++++++-------- .../v2/sms_provider_twilio/resource_test.go | 8 ++++---- zitadel/v2/smtp_config/resource_test.go | 15 ++++++++++---- zitadel/v2/trigger_actions/resource_test.go | 14 ++++++------- zitadel/v2/user_grant/resource_test.go | 14 ++++++------- .../resource_test.go | 8 ++++---- .../resource_test.go | 8 ++++---- 59 files changed, 272 insertions(+), 269 deletions(-) diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 432e35cd..f8764eb3 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -19,10 +19,10 @@ func TestAccAction(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -41,8 +41,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetAction(frame, &management.GetActionRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 207035f1..12d167d2 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -31,10 +31,10 @@ func TestAccAppKey(t *testing.T) { Name: frame.UniqueResourcesID, AuthMethodType: app.OIDCAuthMethodType_OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, }) - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -53,8 +53,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId, appId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetAppKey(frame, &management.GetAppKeyRequest{KeyId: frame.State(state).ID, ProjectId: projectId, AppId: appId}) if err != nil { diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 02758fc6..a387b002 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -25,10 +25,10 @@ func TestAccAppAPI(t *testing.T) { if err != nil { t.Fatalf("failed to create project: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -46,8 +46,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: frame.State(state).ID, ProjectId: projectId}) if err != nil { diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 6596866b..a96bc3bd 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -25,10 +25,10 @@ func TestAccAppOIDC(t *testing.T) { if err != nil { t.Fatalf("failed to create project: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -59,8 +59,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, projectId string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetAppByID(frame, &management.GetAppByIDRequest{AppId: frame.State(state).ID, ProjectId: projectId}) if err != nil { diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 9ca07c8d..8d5220ce 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultDomainClaimedMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomDomainClaimedMessageText(frame, &admin.GetCustomDomainClaimedMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index 52fb503e..afee7003 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultDomainPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { user_login_must_be_domain = %t @@ -40,8 +40,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetDomainPolicy(frame, &admin.GetDomainPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index 646543c1..bba4544c 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultInitMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomInitMessageText(frame, &admin.GetCustomInitMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 8b99e956..8a608fb1 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultLabelPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { primary_color = "%s" @@ -48,8 +48,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLabelPolicy(frame, &admin.GetLabelPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index dbb9c41e..7ff9b5c7 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultLockoutPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[uint64]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty uint64, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { max_password_attempts = "%d" @@ -38,8 +38,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(uint64) resource.TestCheckFunc { + return func(expect uint64) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLockoutPolicy(frame, &admin.GetLockoutPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index a37a47a2..cec51581 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultLoginPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { user_login = %t @@ -55,8 +55,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLoginPolicy(frame, &admin.GetLoginPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index e25d53f6..ad751faa 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultLoginTexts(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -328,8 +328,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomLoginTexts(frame, &admin.GetCustomLoginTextsRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 86b58c86..9f2b0dbb 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultNotificationPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { password_change = %t @@ -38,8 +38,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetNotificationPolicy(frame, &admin.GetNotificationPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 403a225b..02a041e8 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -20,17 +20,17 @@ func TestAccDefaultOIDCSettings(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(accessTokenLifetime, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { access_token_lifetime = "%s" id_token_lifetime = "777h0m0s" refresh_token_idle_expiration = "888h0m0s" refresh_token_expiration = "999h0m0s" -}`, resourceName, frame.UniqueResourcesID, accessTokenLifetime) +}`, resourceName, frame.UniqueResourcesID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -41,8 +41,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetOIDCSettings(frame, &admin.GetOIDCSettingsRequest{}) if err != nil { diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index ff6f95e2..e764ff7d 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultPasswordChangeMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordChangeMessageText(frame, &admin.GetCustomPasswordChangeMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 5b4f4d9e..a3fa074c 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultPasswordComplexityPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { min_length = "8" @@ -42,8 +42,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPasswordComplexityPolicy(frame, &admin.GetPasswordComplexityPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index 22b4fc30..e81e1dc3 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultPassswordResetMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordResetMessageText(frame, &admin.GetCustomPasswordResetMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 9a070b7f..58bc5785 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultPasswordlessRegistrationMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordlessRegistrationMessageText(frame, &admin.GetCustomPasswordlessRegistrationMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index fe8b8204..5b983419 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDefaultPrivacyPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { tos_link = "https://google.com" @@ -40,8 +40,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPrivacyPolicy(frame, &admin.GetPrivacyPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 8df5ebba..ac42daeb 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultVerifyEmailMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomVerifyEmailMessageText(frame, &admin.GetCustomVerifyEmailMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index c0b89a0f..a53e1ae0 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDefaultVerifyPhoneMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { language = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.InstanceTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomVerifyPhoneMessageText(frame, &admin.GetCustomVerifyPhoneMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 085f8085..98d7c1ef 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -22,10 +22,10 @@ func TestAccDomain(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -42,14 +42,14 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(_ *terraform.State) error { remoteResource, err := frame.ListOrgDomains(frame, &management.ListOrgDomainsRequest{ Queries: []*org.DomainSearchQuery{{ Query: &org.DomainSearchQuery_DomainNameQuery{ DomainNameQuery: &org.DomainNameQuery{ - Name: expect.(string), + Name: expect, }, }, }}, diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index 42f5589a..368d549e 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccDomainClaimedMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomDomainClaimedMessageText(frame, &management.GetCustomDomainClaimedMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index a5b07b1d..eda17b79 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccDomainPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -41,8 +41,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetDomainPolicy(frame, &management.GetDomainPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index 6463caca..cdc36e5e 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -33,7 +33,7 @@ func CheckAMinute(check resource.TestCheckFunc) resource.TestCheckFunc { var ErrNotFound = fmt.Errorf("not found") -func CheckIsNotFoundFromPropertyCheck(checkRemoteProperty func(interface{}) resource.TestCheckFunc, validProperty interface{}) resource.TestCheckFunc { +func CheckIsNotFoundFromPropertyCheck[P any](checkRemoteProperty func(P) resource.TestCheckFunc, validProperty P) resource.TestCheckFunc { return func(state *terraform.State) error { err := checkRemoteProperty(validProperty)(state) if status.Code(err) != codes.NotFound && !errors.Is(err, ErrNotFound) { diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index c4a5a3dd..43c74406 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -8,13 +8,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func RunLifecyleTest( +func RunLifecyleTest[P comparable]( t *testing.T, frame BaseTestFrame, - resourceFunc func(initialProperty, initialSecret interface{}) string, - initialProperty, updatedProperty, - initialSecret, updatedSecret interface{}, - checkRemoteProperty func(expect interface{}) resource.TestCheckFunc, + resourceFunc func(initialProperty P, initialSecret string) string, + initialProperty, updatedProperty P, + initialSecret, updatedSecret string, + checkRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index 6a8f08a0..8e60ed09 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -13,16 +13,16 @@ import ( func TestAccHumanUser(t *testing.T) { resourceName := "zitadel_human_user" - initialProperty := "test1@zitadel.com" - updatedProperty := "test2@zitadel.com" + initialProperty := "en" + updatedProperty := "de" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, secretProperty interface{}) string { + func(configProperty, secretProperty string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -31,14 +31,14 @@ resource "%s" "%s" { last_name = "lastname" nick_name = "nickname" display_name = "displayname" - preferred_language = "de" + preferred_language = "%s" gender = "GENDER_MALE" phone = "+41799999999" is_phone_verified = true - email = "%s" + email = "%s@example.com" is_email_verified = true initial_password = "Password1!" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty, frame.UniqueResourcesID) }, initialProperty, updatedProperty, "", "", @@ -49,14 +49,14 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } - actual := remoteResource.GetUser().GetHuman().GetEmail().GetEmail() + actual := remoteResource.GetUser().GetHuman().GetProfile().GetPreferredLanguage() if actual != expect { return fmt.Errorf("expected %s, but got %s", expect, actual) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index e2b52371..97bcce30 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -12,8 +12,8 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func CheckProviderName(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expectName interface{}) resource.TestCheckFunc { +func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expectName string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index bce54ff3..edd7d6f6 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -16,12 +16,10 @@ func RunInstanceIDPLifecyleTest( secretAttribute string, ) { const importedSecret = "an_imported_secret" - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(initialProperty, initialSecret interface{}) string { - return resourceFunc(initialProperty.(string), initialSecret.(string)) - }, + resourceFunc, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 0ff43ba7..5a03a83b 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccInitMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomInitMessageText(frame, &management.GetCustomInitMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index ecf64566..cee59ca1 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -37,15 +37,15 @@ func TestAccInstanceMember(t *testing.T) { if err != nil { t.Fatalf("failed to create user: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { user_id = "%s" roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -56,8 +56,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.Admin.ListIAMMembers(frame, &admin.ListIAMMembersRequest{ Queries: []*member.SearchQuery{{ @@ -71,8 +71,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(inte return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) } actual := resp.Result[0].Roles[0] - if expected != actual { - return fmt.Errorf("expected role %s, but got %s", expected, actual) + if expect != actual { + return fmt.Errorf("expected role %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index d86e1ae1..3461d5f8 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccLabelPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -49,8 +49,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLabelPolicy(frame, &management.GetLabelPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index 839e3236..c261ca3e 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccLockoutPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[uint64]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty uint64, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -39,8 +39,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(uint64) resource.TestCheckFunc { + return func(expect uint64) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLockoutPolicy(frame, &management.GetLockoutPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index 0511b9d0..158693b6 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccLoginPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -56,8 +56,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLoginPolicy(frame, &management.GetLoginPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index 86de56f4..53987598 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -22,10 +22,10 @@ func TestAccLoginTexts(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -329,8 +329,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomLoginTexts(frame, &management.GetCustomLoginTextsRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index ff3360dd..c29bb3cc 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -27,17 +27,17 @@ func TestAccMachineKey(t *testing.T) { if err != nil { t.Fatalf("failed to create user: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" user_id = "%s" key_type = "KEY_TYPE_JSON" expiration_date = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -48,8 +48,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetMachineKeyByIDs(frame, &management.GetMachineKeyByIDsRequest{ UserId: userID, @@ -59,8 +59,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(inte return err } actual := resp.GetKey().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") - if expected != actual { - return fmt.Errorf("expected %s, but got %s", expected, actual) + if expect != actual { + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go index f42634dd..1ad988f6 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/v2/machine_user/resource_test.go @@ -19,10 +19,10 @@ func TestAccMachineUser(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, secretProperty interface{}) string { + func(configProperty, secretProperty string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -40,8 +40,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetUserByID(frame, &management.GetUserByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index fbc61882..00083281 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccNotificationPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -39,8 +39,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetNotificationPolicy(frame, &management.GetNotificationPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index a523b27e..dbfd9112 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -22,10 +22,10 @@ func TestAccOrg(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { name = "%s" @@ -40,8 +40,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go index e44e93a6..be29fb41 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -19,10 +19,10 @@ func TestAccOrgIDPJWT(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -44,8 +44,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 89f48a5d..7770028a 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -12,8 +12,8 @@ import ( "google.golang.org/grpc/status" ) -func CheckProviderName(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expectName interface{}) resource.TestCheckFunc { +func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expectName string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 1d667dd7..21b4d53b 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -18,12 +18,10 @@ func RunOrgLifecyleTest( secretAttribute string, ) { const importedSecret = "an_imported_secret" - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(initialProperty, initialSecret interface{}) string { - return resourceFunc(initialProperty.(string), initialSecret.(string)) - }, + resourceFunc, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", CheckProviderName(frame), diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index 89e083e7..b8a5229b 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -35,16 +35,16 @@ func TestAccOrgMember(t *testing.T) { if err != nil { t.Fatalf("failed to create user: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" user_id = "%s" roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -55,8 +55,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.ListOrgMembers(frame, &management.ListOrgMembersRequest{ Queries: []*member.SearchQuery{{ @@ -70,8 +70,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(inte return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) } actual := resp.Result[0].Roles[0] - if expected != actual { - return fmt.Errorf("expected role %s, but got %s", expected, actual) + if expect != actual { + return fmt.Errorf("expected role %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 9600c367..74ad3fb6 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccPasswordChangeMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordChangeMessageText(frame, &management.GetCustomPasswordChangeMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index 757c3bb2..3fa266b7 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccPasswordComplexityPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[bool]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -43,8 +43,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { + return func(expect bool) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPasswordComplexityPolicy(frame, &management.GetPasswordComplexityPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index ae25528b..c83655ce 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccPasswordResetMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordResetMessageText(frame, &management.GetCustomPasswordResetMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index e6ed6d9a..544e39ae 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccPasswordlessRegistrationMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomPasswordlessRegistrationMessageText(frame, &management.GetCustomPasswordlessRegistrationMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index 57a39949..86de7380 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -27,16 +27,16 @@ func TestAccPersonalAccessToken(t *testing.T) { if err != nil { t.Fatalf("failed to create user: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" user_id = "%s" expiration_date = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -47,8 +47,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPersonalAccessTokenByIDs(frame, &management.GetPersonalAccessTokenByIDsRequest{ UserId: userID, @@ -58,8 +58,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(inte return err } actual := resp.GetToken().GetExpirationDate().AsTime().Format("2006-01-02T15:04:05Z") - if expected != actual { - return fmt.Errorf("expected %s, but got %s", expected, actual) + if expect != actual { + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index b758173d..d1b05dc0 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -20,10 +20,10 @@ func TestAccPrivacyPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -41,8 +41,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPrivacyPolicy(frame, &management.GetPrivacyPolicyRequest{}) if err != nil { diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go index 771431dd..ad289fab 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/v2/project/resource_test.go @@ -19,10 +19,10 @@ func TestAccProject(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -42,8 +42,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetProjectByID(frame, &management.GetProjectByIDRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 3a476161..7400eca3 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -43,17 +43,17 @@ func TestAccProjectGrant(t *testing.T) { t.Fatalf("failed to create org: %v", err) } grantedOrgID := org.GetId() - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" project_id = "%s" granted_org_id = "%s" role_keys = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, grantedOrgID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, grantedOrgID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -64,8 +64,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetProjectGrantByID(frame, &management.GetProjectGrantByIDRequest{ ProjectId: projectID, @@ -78,8 +78,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(i if len(actualRoleKeys) != 1 { return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) } - if expected != actualRoleKeys[0] { - return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + if expect != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expect, actualRoleKeys[0]) } return nil } diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index b837a429..27b8a6bb 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -55,10 +55,10 @@ func TestAccProjectGrantMember(t *testing.T) { if err != nil { t.Fatalf("failed to create otherOrgUser: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, otherOrgFrame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -66,7 +66,7 @@ resource "%s" "%s" { grant_id = "%s" user_id = "%s" roles = ["%s"] -}`, resourceName, otherOrgFrame.UniqueResourcesID, otherOrgFrame.OrgID, projectID, grantID, otherOrgUserID, cfg) +}`, resourceName, otherOrgFrame.UniqueResourcesID, otherOrgFrame.OrgID, projectID, grantID, otherOrgUserID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -77,8 +77,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, grantID, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, grantID, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.ListProjectGrantMembers(frame, &management.ListProjectGrantMembersRequest{ ProjectId: projectID, @@ -101,8 +101,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, grantID, user if len(actualRoleKeys) != 1 { return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) } - if expected != actualRoleKeys[0] { - return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + if expect != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expect, actualRoleKeys[0]) } return nil } diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go index 5a0d9865..13dd2a41 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/v2/project_member/resource_test.go @@ -42,17 +42,17 @@ func TestAccProjectMember(t *testing.T) { t.Fatalf("failed to create user: %v", err) } userID := user.GetUserId() - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" project_id = "%s" user_id = "%s" roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -63,8 +63,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.ListProjectMembers(frame, &management.ListProjectMembersRequest{ ProjectId: projectID, @@ -79,8 +79,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID, userID string return fmt.Errorf("expected 1 user with 1 role, but got %d: %w", len(resp.Result), test_utils.ErrNotFound) } actual := resp.Result[0].Roles[0] - if expected != actual { - return fmt.Errorf("expected role %s, but got %s", expected, actual) + if expect != actual { + return fmt.Errorf("expected role %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index fe998527..b12ed182 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -27,10 +27,10 @@ func TestAccProjectRole(t *testing.T) { t.Fatalf("failed to create project: %v", err) } projectID := proj.GetId() - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -38,7 +38,7 @@ resource "%s" "%s" { role_key = "%s" display_name = "display_name2" group = "role_group" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -49,14 +49,14 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.ListProjectRoles(frame, &management.ListProjectRolesRequest{ ProjectId: projectID, Queries: []*project.RoleQuery{{ Query: &project.RoleQuery_KeyQuery{ - KeyQuery: &project.RoleKeyQuery{Key: expected.(string)}, + KeyQuery: &project.RoleKeyQuery{Key: expect}, }, }}, }) @@ -71,8 +71,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, projectID string) func(i return fmt.Errorf("expected 1 role, but got %v", actualRoles) } actualRole := actualRoles[0].GetKey() - if actualRole != expected { - return fmt.Errorf("expected role key %s, but got %s", expected, actualRole) + if actualRole != expect { + return fmt.Errorf("expected role key %s, but got %s", expect, actualRole) } return nil } diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index 86df1453..3feeabd7 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -24,10 +24,10 @@ func TestAccSMSProviderTwilio(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, secretProperty interface{}) string { + func(configProperty, secretProperty string) string { return fmt.Sprintf(` resource "%s" "%s" { sid = "sid" @@ -44,8 +44,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetSMSProvider(frame, &admin.GetSMSProviderRequest{Id: frame.State(state).ID}) if err != nil { diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index 9daa97aa..d63f8f5b 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -4,6 +4,9 @@ import ( "fmt" "testing" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" @@ -24,10 +27,14 @@ func TestAccSMTPConfig(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + _, err = frame.RemoveSMTPConfig(frame, &admin.RemoveSMTPConfigRequest{}) + if err != nil && status.Code(err) != codes.NotFound { + t.Fatalf("failed to remove smtp config: %v", err) + } + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, secretProperty interface{}) string { + func(configProperty, secretProperty string) string { return fmt.Sprintf(` resource "%s" "%s" { sender_address = "address" @@ -47,8 +54,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetSMTPConfig(frame, &admin.GetSMTPConfigRequest{}) if err != nil { diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 77b3e493..3fa32da7 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -35,17 +35,17 @@ func TestAccTriggerActions(t *testing.T) { if err != nil { t.Fatalf("failed to create action: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(name, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" flow_type = "%s" trigger_type = "%s" action_ids = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, flowType, name, action.GetId()) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, flowType, configProperty, action.GetId()) }, initialTriggerType, updatedTriggerType, "", "", @@ -56,8 +56,8 @@ flow_type = "%s" ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(interface{}) resource.TestCheckFunc { - return func(expectTriggerType interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { flowTypeValues := helper.EnumValueMap(trigger_actions.FlowTypes()) resp, err := frame.GetFlow(frame, &management.GetFlowRequest{Type: strconv.Itoa(int(flowTypeValues[flowType]))}) @@ -73,11 +73,11 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, flowType string) func(in } foundType := typesMapping[int32(idInt)] foundTypes = append(foundTypes, foundType) - if foundType == expectTriggerType { + if foundType == expect { return nil } } - return fmt.Errorf("expected trigger type %s not found in %v: %w", expectTriggerType, foundTypes, test_utils.ErrNotFound) + return fmt.Errorf("expected trigger type %s not found in %v: %w", expect, foundTypes, test_utils.ErrNotFound) } } } diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index 4d101eea..e8412828 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -51,17 +51,17 @@ func TestAccUserGrant(t *testing.T) { t.Fatalf("failed to create user: %v", err) } userID := user.GetUserId() - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(cfg, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" project_id = "%s" user_id = "%s" role_keys = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, cfg) +}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, configProperty) }, initialProperty, updatedProperty, "", "", @@ -72,8 +72,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(interface{}) resource.TestCheckFunc { - return func(expected interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetUserGrantByID(frame, &management.GetUserGrantByIDRequest{ UserId: userID, @@ -86,8 +86,8 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame, userID string) func(inte if len(actualRoleKeys) != 1 { return fmt.Errorf("expected 1 role, but got %d", len(actualRoleKeys)) } - if expected != actualRoleKeys[0] { - return fmt.Errorf("expected role key %s, but got %s", expected, actualRoleKeys[0]) + if expect != actualRoleKeys[0] { + return fmt.Errorf("expected role key %s, but got %s", expect, actualRoleKeys[0]) } return nil } diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index f4627e04..2fae7be6 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccVerifyEmailMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomVerifyEmailMessageText(frame, &management.GetCustomVerifyEmailMessageTextRequest{Language: lang}) if err != nil { diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index def654f5..fe234644 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -22,10 +22,10 @@ func TestAccVerifyPhoneMessageText(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - test_utils.RunLifecyleTest( + test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - func(configProperty, _ interface{}) string { + func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { org_id = "%s" @@ -50,8 +50,8 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(interface{}) resource.TestCheckFunc { - return func(expect interface{}) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, lang string) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { remoteResource, err := frame.GetCustomVerifyPhoneMessageText(frame, &management.GetCustomVerifyPhoneMessageTextRequest{Language: lang}) if err != nil { From 523cc60290dcd805d24e71cbf422a8ce48d1b93e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 18:58:51 +0200 Subject: [PATCH 198/260] ignore typecheck on embedded keys --- .golangci.yml | 1 + acceptance/config.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index e0fbee72..ddafd30d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ linters: disable-all: true enable: + - typecheck - goimports linters-settings: goimports: diff --git a/acceptance/config.go b/acceptance/config.go index ef7cb70f..7931d290 100644 --- a/acceptance/config.go +++ b/acceptance/config.go @@ -6,9 +6,11 @@ import ( ) var ( + //nolint:typecheck //go:embed keys/instance-level-admin-sa.json instanceLevelAdminSAJSON []byte + //nolint:typecheck //go:embed keys/org-level-admin-sa.json orgLevelAdminSAJSON []byte From 4f8b3248a3cfb95b31e9506aa48d8b8cdb895928 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 19:02:42 +0200 Subject: [PATCH 199/260] increase lint timeout --- .golangci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index ddafd30d..4b703a46 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,5 @@ +run: + timeout: 10m linters: disable-all: true enable: From 1147418e76502c75477cf4b41aca8bf1a517d5c3 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 19:24:49 +0200 Subject: [PATCH 200/260] remove comment --- .golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4b703a46..b2ee2a94 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,7 +7,4 @@ linters: - goimports linters-settings: goimports: - # A comma-separated list of prefixes, which, if set, checks import paths - # with the given prefixes are grouped after 3rd-party packages. - # Default: "" local-prefixes: github.com/zitadel/terraform-provider-zitadel From bc315233981501944f69a077ecba9d8742cab57c Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 19:31:57 +0200 Subject: [PATCH 201/260] use gci linter --- .golangci.yml | 9 ++++++--- zitadel/provider.go | 3 +-- .../v2/default_domain_claimed_message_text/resource.go | 3 +-- zitadel/v2/default_init_message_text/resource.go | 3 +-- zitadel/v2/default_login_texts/resource.go | 3 +-- .../v2/default_password_change_message_text/resource.go | 3 +-- .../v2/default_password_reset_message_text/resource.go | 3 +-- .../resource.go | 3 +-- zitadel/v2/default_verify_email_message_text/resource.go | 3 +-- zitadel/v2/default_verify_phone_message_text/resource.go | 3 +-- zitadel/v2/domain_claimed_message_text/resource.go | 3 +-- zitadel/v2/init_message_text/resource.go | 3 +-- zitadel/v2/login_texts/resource.go | 3 +-- zitadel/v2/org_idp_azure_ad/resource.go | 3 +-- zitadel/v2/org_idp_utils/funcs.go | 1 - zitadel/v2/password_change_message_text/resource.go | 3 +-- zitadel/v2/password_reset_message_text/resource.go | 3 +-- .../passwordless_registration_message_text/resource.go | 3 +-- zitadel/v2/verify_email_message_text/resource.go | 3 +-- zitadel/v2/verify_phone_message_text/resource.go | 3 +-- 20 files changed, 24 insertions(+), 40 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b2ee2a94..798d30ab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,10 @@ linters: disable-all: true enable: - typecheck - - goimports + - gci linters-settings: - goimports: - local-prefixes: github.com/zitadel/terraform-provider-zitadel + gci: + sections: + - standard + - default + - prefix(github.com/zitadel/terraform-provider-zitadel) diff --git a/zitadel/provider.go b/zitadel/provider.go index 1b32e034..b171141b 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -3,8 +3,6 @@ package zitadel import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" - "github.com/hashicorp/terraform-plugin-framework/datasource" fdiag "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/provider" @@ -27,6 +25,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_texts" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_notification_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_change_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" diff --git a/zitadel/v2/default_domain_claimed_message_text/resource.go b/zitadel/v2/default_domain_claimed_message_text/resource.go index a5645fd0..58a77060 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_init_message_text/resource.go b/zitadel/v2/default_init_message_text/resource.go index 213ba65b..180c5cb0 100644 --- a/zitadel/v2/default_init_message_text/resource.go +++ b/zitadel/v2/default_init_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_login_texts/resource.go b/zitadel/v2/default_login_texts/resource.go index 3a60a1d9..161a51af 100644 --- a/zitadel/v2/default_login_texts/resource.go +++ b/zitadel/v2/default_login_texts/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_password_change_message_text/resource.go b/zitadel/v2/default_password_change_message_text/resource.go index 74224153..38ae24bc 100644 --- a/zitadel/v2/default_password_change_message_text/resource.go +++ b/zitadel/v2/default_password_change_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_password_reset_message_text/resource.go b/zitadel/v2/default_password_reset_message_text/resource.go index 56c6646a..e1618a75 100644 --- a/zitadel/v2/default_password_reset_message_text/resource.go +++ b/zitadel/v2/default_password_reset_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource.go b/zitadel/v2/default_passwordless_registration_message_text/resource.go index 3e18738d..5f70f59b 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_verify_email_message_text/resource.go b/zitadel/v2/default_verify_email_message_text/resource.go index 71986450..94a80b67 100644 --- a/zitadel/v2/default_verify_email_message_text/resource.go +++ b/zitadel/v2/default_verify_email_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/default_verify_phone_message_text/resource.go b/zitadel/v2/default_verify_phone_message_text/resource.go index 7b99702b..0cdb9c14 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource.go +++ b/zitadel/v2/default_verify_phone_message_text/resource.go @@ -10,9 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index 48fc8c6e..8aee1252 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go index 487b71a3..7eb8dbc6 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/v2/init_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index 66c405c7..f80ff810 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index d6b91af8..859ec1ea 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -1,10 +1,9 @@ package org_idp_azure_ad import ( - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index 2e9809d5..ad825ead 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -10,7 +10,6 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/v2/password_change_message_text/resource.go index c878455e..2584d820 100644 --- a/zitadel/v2/password_change_message_text/resource.go +++ b/zitadel/v2/password_change_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index 39504b22..efd9ce70 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go index 869cb18e..5b263239 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index 657c2de8..841cab1b 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index 1f9f5dd3..56c8320c 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -11,9 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/encoding/protojson" - textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" From dee70b60444a5c1a68e69e013f215c9394938ff0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 20:09:23 +0200 Subject: [PATCH 202/260] lint test files --- .github/workflows/pull_request.yaml | 5 +++++ acceptance/config.go | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index e9d49227..b6df7d49 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -24,6 +24,11 @@ jobs: go-version-file: 'go.mod' cache: false + - name: Avoid Typecheck Error On Embedded Fields + run: | + touch acceptance/keys/instance-level-admin-sa.json + touch acceptance/keys/org-level-admin-sa.json + - name: Lint uses: golangci/golangci-lint-action@v3 with: diff --git a/acceptance/config.go b/acceptance/config.go index 7931d290..ef7cb70f 100644 --- a/acceptance/config.go +++ b/acceptance/config.go @@ -6,11 +6,9 @@ import ( ) var ( - //nolint:typecheck //go:embed keys/instance-level-admin-sa.json instanceLevelAdminSAJSON []byte - //nolint:typecheck //go:embed keys/org-level-admin-sa.json orgLevelAdminSAJSON []byte From 920f44ecd52648c1353736ac4f5fe9c1439f3273 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 2 Aug 2023 20:09:59 +0200 Subject: [PATCH 203/260] format test files --- .../resource_test.go | 3 +-- zitadel/v2/default_domain_policy/resource_test.go | 3 +-- zitadel/v2/default_init_message_text/resource_test.go | 3 +-- zitadel/v2/default_label_policy/resource_test.go | 3 +-- zitadel/v2/default_lockout_policy/resource_test.go | 3 +-- zitadel/v2/default_login_policy/resource_test.go | 3 +-- zitadel/v2/default_login_texts/resource_test.go | 3 +-- .../v2/default_notification_policy/resource_test.go | 3 +-- zitadel/v2/default_oidc_settings/resource_test.go | 3 +-- .../resource_test.go | 3 +-- .../resource_test.go | 3 +-- .../resource_test.go | 3 +-- .../resource_test.go | 3 +-- zitadel/v2/default_privacy_policy/resource_test.go | 3 +-- .../resource_test.go | 3 +-- .../resource_test.go | 3 +-- zitadel/v2/domain/resource_test.go | 3 +-- .../v2/domain_claimed_message_text/resource_test.go | 3 +-- zitadel/v2/domain_policy/resource_test.go | 3 +-- zitadel/v2/helper/test_utils/checks.go | 5 ++--- zitadel/v2/idp_azure_ad/resource_test.go | 3 +-- zitadel/v2/idp_github/resource_test.go | 3 +-- zitadel/v2/idp_github_es/resource_test.go | 3 +-- zitadel/v2/idp_gitlab/resource_test.go | 3 +-- zitadel/v2/idp_google/resource_test.go | 3 +-- zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go | 4 ++-- zitadel/v2/init_message_text/resource_test.go | 3 +-- zitadel/v2/instance_member/resource_test.go | 3 +-- zitadel/v2/label_policy/resource_test.go | 3 +-- zitadel/v2/lockout_policy/resource_test.go | 3 +-- zitadel/v2/login_policy/resource_test.go | 3 +-- zitadel/v2/login_texts/resource_test.go | 3 +-- zitadel/v2/notification_policy/resource_test.go | 3 +-- zitadel/v2/org/resource_test.go | 6 ++---- zitadel/v2/org_idp_azure_ad/resource_test.go | 3 +-- zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go | 4 ++-- .../org_idp_utils/org_idp_test_utils/lifecyletest.go | 5 ++--- .../v2/password_change_message_text/resource_test.go | 3 +-- .../v2/password_complexity_policy/resource_test.go | 3 +-- .../v2/password_reset_message_text/resource_test.go | 3 +-- .../resource_test.go | 3 +-- zitadel/v2/privacy_policy/resource_test.go | 3 +-- zitadel/v2/project_grant_member/resource_test.go | 3 +-- zitadel/v2/sms_provider_twilio/resource_test.go | 6 ++---- zitadel/v2/smtp_config/resource_test.go | 11 ++++------- zitadel/v2/verify_email_message_text/resource_test.go | 3 +-- zitadel/v2/verify_phone_message_text/resource_test.go | 3 +-- 47 files changed, 56 insertions(+), 105 deletions(-) diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 8d5220ce..87996902 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index afee7003..d13aec6f 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index bba4544c..31fc6d19 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 8a608fb1..23d00553 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index 7ff9b5c7..4488ca20 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index cec51581..9979ebed 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index ad751faa..df312fb6 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 9f2b0dbb..af5b1530 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 02a041e8..bf6693a3 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index e764ff7d..2c2cd05e 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index a3fa074c..7a036852 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index e81e1dc3..10efad5e 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 58bc5785..bac25b57 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index 5b983419..7670f8e7 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index ac42daeb..56284e84 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index a53e1ae0..6dd500a7 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 98d7c1ef..81ce81c3 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -5,11 +5,10 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index 368d549e..a9fc9bab 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index eda17b79..1e91404e 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index cdc36e5e..719ff898 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -6,11 +6,10 @@ import ( "regexp" "time" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) // ZITADEL IDs have thirteen digits diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index d44cca24..07a17f6a 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index 8b3c5362..b0dca150 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index 8958e775..3c77b4cf 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index 0a69b8c9..3fad74fb 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index 247e1ca4..6938fc39 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index edd7d6f6..4e8ee449 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func RunInstanceIDPLifecyleTest( diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 5a03a83b..2b4e2c6e 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index cee59ca1..fa92d5aa 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index 3461d5f8..c4205454 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index c261ca3e..28ee7b1d 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index 158693b6..ca330729 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index 53987598..d735ca6b 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index 00083281..c78b8714 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index dbfd9112..8d628b91 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -4,12 +4,10 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index aca1250e..dc3502bf 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPAzureAD(t *testing.T) { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 7770028a..5b94252f 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -3,13 +3,13 @@ package org_idp_test_utils import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 21b4d53b..bb3568e2 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -4,11 +4,10 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func RunOrgLifecyleTest( diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 74ad3fb6..57cb281d 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index 3fa266b7..990331ff 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index c83655ce..523291f4 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index 544e39ae..98586d56 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index d1b05dc0..60802d87 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -4,10 +4,9 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index 27b8a6bb..35edf311 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -4,11 +4,10 @@ import ( "fmt" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index 3feeabd7..47be2c95 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -4,14 +4,12 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" ) func TestAccSMSProviderTwilio(t *testing.T) { diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index d63f8f5b..f41a43e0 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -4,17 +4,14 @@ import ( "fmt" "testing" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" - - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" ) func TestAccSMTPConfig(t *testing.T) { diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index 2fae7be6..37494530 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index fe234644..98207208 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -5,10 +5,9 @@ import ( "regexp" "testing" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) From 5b3a12871d0d67b8161430d78579eb046f72d02a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 22:09:00 +0200 Subject: [PATCH 204/260] fix flakiness --- zitadel/v2/domain_policy/resource_test.go | 12 ++++++---- zitadel/v2/org/remote_test.go | 29 +++++++++++++++++++++++ zitadel/v2/org/resource_test.go | 28 ++-------------------- 3 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 zitadel/v2/org/remote_test.go diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 1e91404e..9d049396 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -19,9 +19,13 @@ func TestAccDomainPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } + otherFrame, err := frame.AnotherOrg("domain-policy-org") + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } test_utils.RunLifecyleTest[bool]( t, - frame.BaseTestFrame, + otherFrame.BaseTestFrame, func(configProperty bool, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { @@ -29,13 +33,13 @@ resource "%s" "%s" { user_login_must_be_domain = %t validate_org_domains = false smtp_sender_address_matches_instance_domain = false -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) +}`, resourceName, otherFrame.UniqueResourcesID, otherFrame.OrgID, configProperty) }, initialProperty, updatedProperty, "", "", - checkRemoteProperty(*frame), + checkRemoteProperty(*otherFrame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*frame)(initialProperty), + checkRemoteProperty(*otherFrame)(initialProperty), nil, nil, "", "", ) } diff --git a/zitadel/v2/org/remote_test.go b/zitadel/v2/org/remote_test.go new file mode 100644 index 00000000..e2ec97d3 --- /dev/null +++ b/zitadel/v2/org/remote_test.go @@ -0,0 +1,29 @@ +package org_test + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" +) + +func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: frame.State(state).ID}) + if err != nil { + return err + } + actual := remoteResource.GetOrg().GetName() + if remoteResource.GetOrg().GetState() == org.OrgState_ORG_STATE_REMOVED { + return fmt.Errorf("org is removed: %w", test_utils.ErrNotFound) + } + if actual != expect { + return fmt.Errorf("expected %s, but got %s", expect, actual) + } + return nil + } + } +} diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index 8d628b91..a85580b7 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -4,22 +4,17 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccOrg(t *testing.T) { resourceName := "zitadel_org" - initialProperty := "initialorgname" - updatedProperty := "updatedorgname" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } + initialProperty := "initialorgname_" + frame.UniqueResourcesID + updatedProperty := "updatedorgname_" + frame.UniqueResourcesID test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, @@ -37,22 +32,3 @@ resource "%s" "%s" { nil, nil, "", "", ) } - -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { - return func(state *terraform.State) error { - remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: frame.State(state).ID}) - if err != nil { - return err - } - actual := remoteResource.GetOrg().GetName() - if remoteResource.GetOrg().GetState() == org.OrgState_ORG_STATE_REMOVED { - return fmt.Errorf("org is removed: %w", test_utils.ErrNotFound) - } - if actual != expect { - return fmt.Errorf("expected %s, but got %s", expect, actual) - } - return nil - } - } -} From 2e033ff81f69ba794fbd5824533811d277c6cb1e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 22:09:40 +0200 Subject: [PATCH 205/260] simplify setup --- CONTRIBUTING.md | 3 --- acceptance/docker-compose.yaml | 40 ++++++++++++++++------------------ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4516079d..1d9a3758 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,9 +23,6 @@ Run a local ZITADEL instance using docker compose. # To have the machine key written with the correct ownership, set your current users ID. export ZITADEL_DEV_UID="$(id -u)" -# Pull Images -docker compose --file ./acceptance/docker-compose.yaml pull - # Setup ZITADEL docker compose --file ./acceptance/docker-compose.yaml run setup ``` diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index d6707a91..bff6ae2b 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -1,37 +1,35 @@ version: '3.8' services: - zitadel: - user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.31.4}' - command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' - ports: - - "8080:8080" - volumes: - - ./keys:/keys - - ./zitadel.yaml:/zitadel.yaml - depends_on: - db: - condition: 'service_healthy' - db: image: 'cockroachdb/cockroach:v22.2.2' command: 'start-single-node --insecure --http-addr :9090' healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:9090/health?ready=1'] - interval: '10s' + interval: '2s' timeout: '30s' retries: 5 - start_period: '20s' ports: - "26257:26257" - "9090:9090" - wait_for_zitadel: - image: curlimages/curl:8.00.1 - command: [ "/bin/sh", "-c", "i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0" ] + zitadel: + user: '${ZITADEL_DEV_UID}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.31.6}' + command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' + ports: + - "8080:8080" + volumes: + - ./keys:/keys + - ./zitadel.yaml:/zitadel.yaml + healthcheck: + test: ['CMD', '/app/zitadel', 'ready'] + interval: '2s' + timeout: '30s' + retries: 5 depends_on: - - zitadel + db: + condition: 'service_healthy' setup: user: '${ZITADEL_DEV_UID}' @@ -43,5 +41,5 @@ services: volumes: - "./keys:/keys" depends_on: - wait_for_zitadel: - condition: 'service_completed_successfully' + zitadel: + condition: 'service_healthy' From dbd9c53f6765ae93aee686bf1eb39f136dd869e8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 22:09:59 +0200 Subject: [PATCH 206/260] test concurrency --- zitadel/v2/helper/test_utils/lifecyletest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 43c74406..46577636 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -76,7 +76,7 @@ func RunLifecyleTest[P comparable]( Check: checkImportState, }) } - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, ProtoV6ProviderFactories: frame.v6ProviderFactories, From 17e605fef015b4dafe4c44fe376b3e57f21ac603 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 22:15:59 +0200 Subject: [PATCH 207/260] lint --- zitadel/v2/org/remote_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zitadel/v2/org/remote_test.go b/zitadel/v2/org/remote_test.go index e2ec97d3..27cae84a 100644 --- a/zitadel/v2/org/remote_test.go +++ b/zitadel/v2/org/remote_test.go @@ -2,11 +2,13 @@ package org_test import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { From a6faf74277ac03f6e7513b20baa01dc6f0abcf99 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 22:33:07 +0200 Subject: [PATCH 208/260] update zitadel version --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index bff6ae2b..e5406c5c 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -15,7 +15,7 @@ services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.31.6}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.32.0}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From 55b007762164b20ae2ef66464f8ec809b90b4149 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 8 Aug 2023 23:23:55 +0200 Subject: [PATCH 209/260] await eventual consistency --- acceptance/zitadel.yaml | 3 + zitadel/v2/helper/test_utils/lifecyletest.go | 116 ++++++++++++------- 2 files changed, 74 insertions(+), 45 deletions(-) diff --git a/acceptance/zitadel.yaml b/acceptance/zitadel.yaml index 66b0c8f2..81f5cf78 100644 --- a/acceptance/zitadel.yaml +++ b/acceptance/zitadel.yaml @@ -26,3 +26,6 @@ Logstore: SystemAPIUsers: - system-api-sa: KeyData: "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF6aStGRlNKTDdmNXl3NEtUd3pnTQpQMzRlUEd5Y20vTStrVDBNN1Y0Q2d4NVYzRWFESXZUUUtUTGZCYUVCNDV6YjlMdGpJWHpEdzByWFJvUzJoTzZ0CmgrQ1lRQ3ozS0N2aDA5QzBJenhaaUIySVMzSC9hVCs1Qng5RUZZK3ZuQWtaamNjYnlHNVlOUnZtdE9sbnZJZUkKSDdxWjB0RXdrUGZGNUdFWk5QSlB0bXkzVUdWN2lvZmRWUVMxeFJqNzMrYU13NXJ2SDREOElkeWlBQzNWZWtJYgpwdDBWajBTVVgzRHdLdG9nMzM3QnpUaVBrM2FYUkYwc2JGaFFvcWRKUkk4TnFnWmpDd2pxOXlmSTV0eXhZc3duCitKR3pIR2RIdlczaWRPRGxtd0V0NUsycGFzaVJJV0syT0dmcSt3MEVjbHRRSGFidXFFUGdabG1oQ2tSZE5maXgKQndJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==" + +Projections: + RequeueEvery: 1s diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 46577636..fe4941ef 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -14,7 +14,7 @@ func RunLifecyleTest[P comparable]( resourceFunc func(initialProperty P, initialSecret string) string, initialProperty, updatedProperty P, initialSecret, updatedSecret string, - checkRemoteProperty func(expect P) resource.TestCheckFunc, + checkEventualRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, @@ -25,56 +25,82 @@ func RunLifecyleTest[P comparable]( initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProperty, initialSecret)) updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) - steps := []resource.TestStep{ - { // Check first plan has a diff - Config: initialConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check resource is created - Config: initialConfig, - Check: resource.ComposeAggregateTestCheckFunc( - CheckAMinute(checkRemoteProperty(initialProperty)), - CheckStateHasIDSet(frame, idPattern), - ), - }, { // Check updating name has a diff - Config: updatedNameConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { // Check remote state can be updated - Config: updatedNameConfig, - Check: CheckAMinute(checkRemoteProperty(updatedProperty)), - }, - } + steps := []resource.TestStep{{ + // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + PlanOnly: true, + }, { + // Check resource is created + // Eventual consistency doesn't allow us to expect not empty plans directly after apply + // Instead we await the remote property here with retries and expect an empty plan in the next step + RefreshState: false, + Config: initialConfig, + Check: resource.ComposeAggregateTestCheckFunc( + CheckAMinute(checkEventualRemoteProperty(initialProperty)), + CheckStateHasIDSet(frame, idPattern), + ), + }, { + // We expect an empty plan because we awaited eventual consistency above + Config: initialConfig, + PlanOnly: true, + ExpectNonEmptyPlan: false, + }, { + // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { + // Check remote state can be updated + RefreshState: false, + Config: updatedNameConfig, + Check: CheckAMinute(checkEventualRemoteProperty(updatedProperty)), + }, { + // We expect an empty plan because we awaited eventual consistency above + Config: updatedNameConfig, + ExpectNonEmptyPlan: false, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }} if secretAttribute != "" { - steps = append(steps, resource.TestStep{ // Check that secret has a diff - Config: updatedSecretConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, resource.TestStep{ // Check secret can be updated - Config: updatedSecretConfig, - }) + steps = append(steps, + // Check that secret has a diff + resource.TestStep{ + Config: updatedSecretConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + // Check secret can be updated + }, resource.TestStep{ + Config: updatedSecretConfig, + // We can't exect consistency here, but we can also not query secrets, so we just skip refreshing the state + RefreshState: false, + }, + ) importStateVerifyIgnore = []string{secretAttribute} } if wrongImportID != "" { - steps = append(steps, resource.TestStep{ // Expect import error if secret is not given - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateId: wrongImportID, - ExpectError: regexp.MustCompile(wrongImportID), - }) + steps = append(steps, + // Expect import error if secret is not given + resource.TestStep{ + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateId: wrongImportID, + ExpectError: regexp.MustCompile(wrongImportID), + }) } if checkImportState != nil { - steps = append(steps, resource.TestStep{ // Expect importing works - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateIdFunc: importStateIdFunc, - ImportStateVerify: true, - ImportStateVerifyIgnore: importStateVerifyIgnore, - Check: checkImportState, - }) + steps = append(steps, + // Expect importing works + resource.TestStep{ + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: importStateIdFunc, + ImportStateVerify: true, + ImportStateVerifyIgnore: importStateVerifyIgnore, + Check: checkImportState, + }) } resource.ParallelTest(t, resource.TestCase{ CheckDestroy: CheckAMinute(checkDestroy), From 5116b6d5f0631aee1504e55a105d63a581a66f9e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 00:04:31 +0200 Subject: [PATCH 210/260] Revert "await eventual consistency" This reverts commit 55b007762164b20ae2ef66464f8ec809b90b4149. --- acceptance/zitadel.yaml | 3 - zitadel/v2/helper/test_utils/lifecyletest.go | 116 +++++++------------ 2 files changed, 45 insertions(+), 74 deletions(-) diff --git a/acceptance/zitadel.yaml b/acceptance/zitadel.yaml index 81f5cf78..66b0c8f2 100644 --- a/acceptance/zitadel.yaml +++ b/acceptance/zitadel.yaml @@ -26,6 +26,3 @@ Logstore: SystemAPIUsers: - system-api-sa: KeyData: "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF6aStGRlNKTDdmNXl3NEtUd3pnTQpQMzRlUEd5Y20vTStrVDBNN1Y0Q2d4NVYzRWFESXZUUUtUTGZCYUVCNDV6YjlMdGpJWHpEdzByWFJvUzJoTzZ0CmgrQ1lRQ3ozS0N2aDA5QzBJenhaaUIySVMzSC9hVCs1Qng5RUZZK3ZuQWtaamNjYnlHNVlOUnZtdE9sbnZJZUkKSDdxWjB0RXdrUGZGNUdFWk5QSlB0bXkzVUdWN2lvZmRWUVMxeFJqNzMrYU13NXJ2SDREOElkeWlBQzNWZWtJYgpwdDBWajBTVVgzRHdLdG9nMzM3QnpUaVBrM2FYUkYwc2JGaFFvcWRKUkk4TnFnWmpDd2pxOXlmSTV0eXhZc3duCitKR3pIR2RIdlczaWRPRGxtd0V0NUsycGFzaVJJV0syT0dmcSt3MEVjbHRRSGFidXFFUGdabG1oQ2tSZE5maXgKQndJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==" - -Projections: - RequeueEvery: 1s diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index fe4941ef..46577636 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -14,7 +14,7 @@ func RunLifecyleTest[P comparable]( resourceFunc func(initialProperty P, initialSecret string) string, initialProperty, updatedProperty P, initialSecret, updatedSecret string, - checkEventualRemoteProperty func(expect P) resource.TestCheckFunc, + checkRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, @@ -25,82 +25,56 @@ func RunLifecyleTest[P comparable]( initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProperty, initialSecret)) updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) - steps := []resource.TestStep{{ - // Check first plan has a diff - Config: initialConfig, - ExpectNonEmptyPlan: true, - PlanOnly: true, - }, { - // Check resource is created - // Eventual consistency doesn't allow us to expect not empty plans directly after apply - // Instead we await the remote property here with retries and expect an empty plan in the next step - RefreshState: false, - Config: initialConfig, - Check: resource.ComposeAggregateTestCheckFunc( - CheckAMinute(checkEventualRemoteProperty(initialProperty)), - CheckStateHasIDSet(frame, idPattern), - ), - }, { - // We expect an empty plan because we awaited eventual consistency above - Config: initialConfig, - PlanOnly: true, - ExpectNonEmptyPlan: false, - }, { - // Check updating name has a diff - Config: updatedNameConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }, { - // Check remote state can be updated - RefreshState: false, - Config: updatedNameConfig, - Check: CheckAMinute(checkEventualRemoteProperty(updatedProperty)), - }, { - // We expect an empty plan because we awaited eventual consistency above - Config: updatedNameConfig, - ExpectNonEmptyPlan: false, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - }} + steps := []resource.TestStep{ + { // Check first plan has a diff + Config: initialConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check resource is created + Config: initialConfig, + Check: resource.ComposeAggregateTestCheckFunc( + CheckAMinute(checkRemoteProperty(initialProperty)), + CheckStateHasIDSet(frame, idPattern), + ), + }, { // Check updating name has a diff + Config: updatedNameConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, { // Check remote state can be updated + Config: updatedNameConfig, + Check: CheckAMinute(checkRemoteProperty(updatedProperty)), + }, + } if secretAttribute != "" { - steps = append(steps, - // Check that secret has a diff - resource.TestStep{ - Config: updatedSecretConfig, - ExpectNonEmptyPlan: true, - // ExpectNonEmptyPlan just works with PlanOnly set to true - PlanOnly: true, - // Check secret can be updated - }, resource.TestStep{ - Config: updatedSecretConfig, - // We can't exect consistency here, but we can also not query secrets, so we just skip refreshing the state - RefreshState: false, - }, - ) + steps = append(steps, resource.TestStep{ // Check that secret has a diff + Config: updatedSecretConfig, + ExpectNonEmptyPlan: true, + // ExpectNonEmptyPlan just works with PlanOnly set to true + PlanOnly: true, + }, resource.TestStep{ // Check secret can be updated + Config: updatedSecretConfig, + }) importStateVerifyIgnore = []string{secretAttribute} } if wrongImportID != "" { - steps = append(steps, - // Expect import error if secret is not given - resource.TestStep{ - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateId: wrongImportID, - ExpectError: regexp.MustCompile(wrongImportID), - }) + steps = append(steps, resource.TestStep{ // Expect import error if secret is not given + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateId: wrongImportID, + ExpectError: regexp.MustCompile(wrongImportID), + }) } if checkImportState != nil { - steps = append(steps, - // Expect importing works - resource.TestStep{ - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateIdFunc: importStateIdFunc, - ImportStateVerify: true, - ImportStateVerifyIgnore: importStateVerifyIgnore, - Check: checkImportState, - }) + steps = append(steps, resource.TestStep{ // Expect importing works + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: importStateIdFunc, + ImportStateVerify: true, + ImportStateVerifyIgnore: importStateVerifyIgnore, + Check: checkImportState, + }) } resource.ParallelTest(t, resource.TestCase{ CheckDestroy: CheckAMinute(checkDestroy), From f9a8580ac630277e81b6f21247dce0c4597d35ed Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 00:35:41 +0200 Subject: [PATCH 211/260] accept eventual consistency --- zitadel/v2/action/resource_test.go | 1 + zitadel/v2/app_key/resource_test.go | 1 + zitadel/v2/application_api/resource_test.go | 1 + zitadel/v2/application_oidc/resource_test.go | 1 + .../resource_test.go | 1 + zitadel/v2/default_domain_policy/resource_test.go | 1 + .../v2/default_init_message_text/resource_test.go | 1 + zitadel/v2/default_label_policy/resource_test.go | 1 + zitadel/v2/default_lockout_policy/resource_test.go | 1 + zitadel/v2/default_login_policy/resource_test.go | 1 + zitadel/v2/default_login_texts/resource_test.go | 1 + .../v2/default_notification_policy/resource_test.go | 1 + zitadel/v2/default_oidc_settings/resource_test.go | 1 + .../resource_test.go | 1 + .../resource_test.go | 1 + .../resource_test.go | 1 + .../resource_test.go | 1 + zitadel/v2/default_privacy_policy/resource_test.go | 1 + .../resource_test.go | 1 + .../resource_test.go | 1 + zitadel/v2/domain/resource_test.go | 1 + .../v2/domain_claimed_message_text/resource_test.go | 1 + zitadel/v2/domain_policy/resource_test.go | 1 + zitadel/v2/helper/test_utils/lifecyletest.go | 13 +++++++++++-- zitadel/v2/human_user/resource_test.go | 1 + zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go | 1 + zitadel/v2/instance_member/resource_test.go | 1 + zitadel/v2/label_policy/resource_test.go | 1 + zitadel/v2/lockout_policy/resource_test.go | 1 + zitadel/v2/login_policy/resource_test.go | 1 + zitadel/v2/login_texts/resource_test.go | 1 + zitadel/v2/machine_key/resource_test.go | 1 + zitadel/v2/machine_user/resource_test.go | 1 + zitadel/v2/notification_policy/resource_test.go | 1 + zitadel/v2/org/resource_test.go | 1 + zitadel/v2/org_idp_jwt/resource_test.go | 1 + .../org_idp_test_utils/lifecyletest.go | 1 + zitadel/v2/org_member/resource_test.go | 1 + .../password_change_message_text/resource_test.go | 1 + .../v2/password_complexity_policy/resource_test.go | 1 + .../v2/password_reset_message_text/resource_test.go | 1 + .../resource_test.go | 1 + zitadel/v2/pat/resource_test.go | 1 + zitadel/v2/privacy_policy/resource_test.go | 1 + zitadel/v2/project/resource_test.go | 1 + zitadel/v2/project_grant/resource_test.go | 1 + zitadel/v2/project_grant_member/resource_test.go | 1 + zitadel/v2/project_member/resource_test.go | 1 + zitadel/v2/project_role/resource_test.go | 1 + zitadel/v2/sms_provider_twilio/resource_test.go | 1 + zitadel/v2/smtp_config/resource_test.go | 1 + zitadel/v2/trigger_actions/resource_test.go | 1 + zitadel/v2/user_grant/resource_test.go | 1 + .../v2/verify_email_message_text/resource_test.go | 1 + .../v2/verify_phone_message_text/resource_test.go | 1 + 55 files changed, 65 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index f8764eb3..2d4c76db 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -34,6 +34,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 12d167d2..a8051a58 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -46,6 +46,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame, project.GetId(), app.GetAppId()), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId()), updatedProperty), diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index a387b002..99e82082 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -39,6 +39,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame, project.GetId()), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index a96bc3bd..d8cc32f0 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -52,6 +52,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame, project.GetId()), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 87996902..78f797bb 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index d13aec6f..d9580500 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -32,6 +32,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index 31fc6d19..c63c1964 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 23d00553..91075469 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index 4488ca20..74bdd78b 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -30,6 +30,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index 9979ebed..2c23207e 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -47,6 +47,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index df312fb6..4d4fc35a 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -319,6 +319,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index af5b1530..47cc1683 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -30,6 +30,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index bf6693a3..8b7a2c03 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -33,6 +33,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index 2c2cd05e..dbd76e7b 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 7a036852..62d3980c 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -34,6 +34,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index 10efad5e..36b3cf11 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index bac25b57..52b52888 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index 7670f8e7..2c1bdb4b 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -32,6 +32,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 56284e84..3f8c4dbb 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index 6dd500a7..69f709a6 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 81ce81c3..846b3c60 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -34,6 +34,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame), regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, initialProperty, updatedProperty)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index a9fc9bab..e6fa09b0 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 9d049396..05631425 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -37,6 +37,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*otherFrame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*otherFrame)(initialProperty), diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 46577636..433c8005 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -3,6 +3,7 @@ package test_utils import ( "fmt" "regexp" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -14,6 +15,7 @@ func RunLifecyleTest[P comparable]( resourceFunc func(initialProperty P, initialSecret string) string, initialProperty, updatedProperty P, initialSecret, updatedSecret string, + allowNonEmptyPlan bool, checkRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, checkDestroy, checkImportState resource.TestCheckFunc, @@ -77,8 +79,15 @@ func RunLifecyleTest[P comparable]( }) } resource.ParallelTest(t, resource.TestCase{ - CheckDestroy: CheckAMinute(checkDestroy), - Steps: steps, + CheckDestroy: CheckAMinute(checkDestroy), + Steps: steps, + ErrorCheck: func(err error) error { + if allowNonEmptyPlan && strings.Contains(err.Error(), "Step 2/4 error: After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { + t.Logf("Ignoring non-empty plan error because we can't guarantee consistency: %s", err.Error()) + return nil + } + return err + }, ProtoV6ProviderFactories: frame.v6ProviderFactories, ProtoV5ProviderFactories: frame.v5ProviderFactories, }) diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index 8e60ed09..79e9c954 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -42,6 +42,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index 4e8ee449..9120f97a 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -22,6 +22,7 @@ func RunInstanceIDPLifecyleTest( resourceFunc, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", + false, CheckProviderName(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, CheckDestroy(frame), diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index fa92d5aa..bd9d2f6d 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -48,6 +48,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*frame, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index c4205454..5093a284 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(initialProperty), diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index 28ee7b1d..dcb2c4f9 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -31,6 +31,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(uint64(0)), diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index ca330729..676fd41d 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -48,6 +48,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(initialProperty), diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index d735ca6b..bc418c63 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -320,6 +320,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index c29bb3cc..7764de03 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go index 1ad988f6..fd30c3ad 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/v2/machine_user/resource_test.go @@ -33,6 +33,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index c78b8714..dda16fb1 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -31,6 +31,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(true), diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index a85580b7..928f4ed1 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -26,6 +26,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go index be29fb41..a5fada5f 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -37,6 +37,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index bb3568e2..9499e129 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -23,6 +23,7 @@ func RunOrgLifecyleTest( resourceFunc, "an initial provider name", "an updated provider name", "an_initial_secret", "an_updated_secret", + false, CheckProviderName(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, CheckDestroy(frame), diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index b8a5229b..3a194db8 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -48,6 +48,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*frame, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 57cb281d..ea5513c3 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index 990331ff..bbfec642 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -35,6 +35,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(initialProperty), diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index 523291f4..bee49c27 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index 98586d56..57195677 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index 86de7380..2c32822d 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -40,6 +40,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index 60802d87..97ec471c 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -33,6 +33,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, checkRemoteProperty(*frame)(""), diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go index ad289fab..cc1e62ab 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/v2/project/resource_test.go @@ -35,6 +35,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 7400eca3..7f9c627f 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -57,6 +57,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + false, checkRemoteProperty(*frame, projectID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index 35edf311..089df40b 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -69,6 +69,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), ""), diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go index 13dd2a41..0b0457a9 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/v2/project_member/resource_test.go @@ -56,6 +56,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*frame, projectID, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, userID), ""), diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index b12ed182..26889ef1 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -42,6 +42,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*frame, projectID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index 47be2c95..a8fe37eb 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -35,6 +35,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, initialSecret, updatedSecret, + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index f41a43e0..83c82f1b 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -44,6 +44,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, initialSecret, updatedSecret, + false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckNothing, diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 3fa32da7..1b492acf 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -49,6 +49,7 @@ flow_type = "%s" }, initialTriggerType, updatedTriggerType, "", "", + false, checkRemoteProperty(*frame, flowType), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), initialTriggerType), diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index e8412828..fcecf353 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -65,6 +65,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(*frame, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index 37494530..30414b94 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index 98207208..4269a312 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned From 817d2a5edee0fc702b98412b716b40d4c4beceea Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 00:46:33 +0200 Subject: [PATCH 212/260] compile --- zitadel/v2/init_message_text/resource_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 2b4e2c6e..d2967a79 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -41,6 +41,7 @@ resource "%s" "%s" { }, initialProperty, updatedProperty, "", "", + true, checkRemoteProperty(frame, language), regexp.MustCompile(`^\d{18}_en$`), // When deleted, the default should be returned From e425001ecd4ac8411c1f7a495a2172efa92e3ae8 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 00:46:54 +0200 Subject: [PATCH 213/260] idempotent domain policy test --- zitadel/v2/domain_policy/resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 05631425..5152c9e4 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -19,7 +19,7 @@ func TestAccDomainPolicy(t *testing.T) { if err != nil { t.Fatalf("setting up test context failed: %v", err) } - otherFrame, err := frame.AnotherOrg("domain-policy-org") + otherFrame, err := frame.AnotherOrg("domain-policy-org-" + frame.UniqueResourcesID) if err != nil { t.Fatalf("setting up test context failed: %v", err) } From b2ea9ee71d7abb5a1282832a7a380b9aed9b47fa Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 00:49:25 +0200 Subject: [PATCH 214/260] debug --- zitadel/v2/helper/test_utils/lifecyletest.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 433c8005..6e194ed6 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -82,9 +82,11 @@ func RunLifecyleTest[P comparable]( CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, ErrorCheck: func(err error) error { - if allowNonEmptyPlan && strings.Contains(err.Error(), "Step 2/4 error: After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { + if err != nil && allowNonEmptyPlan { t.Logf("Ignoring non-empty plan error because we can't guarantee consistency: %s", err.Error()) - return nil + if strings.Contains(err.Error(), "Step 2/4 error: After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { + return nil + } } return err }, From 2f55bd029168dac0aefa15dcd7a325bdb864c92f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 01:07:28 +0200 Subject: [PATCH 215/260] ignore non-empty plan --- zitadel/v2/helper/test_utils/lifecyletest.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 6e194ed6..c2fc75b0 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -82,11 +82,9 @@ func RunLifecyleTest[P comparable]( CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, ErrorCheck: func(err error) error { - if err != nil && allowNonEmptyPlan { + if err != nil && allowNonEmptyPlan && strings.Contains(err.Error(), "After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { t.Logf("Ignoring non-empty plan error because we can't guarantee consistency: %s", err.Error()) - if strings.Contains(err.Error(), "Step 2/4 error: After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { - return nil - } + return nil } return err }, From 648aa15cdb8a1516c3a1e7bbc2be4b5d45965738 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 01:14:21 +0200 Subject: [PATCH 216/260] test: test org datasource --- zitadel/v2/helper/test_utils/base_frame.go | 7 +- .../v2/helper/test_utils/datasourcetest.go | 35 +++++ zitadel/v2/org/datasource_test.go | 121 ++++++++++++++++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 zitadel/v2/helper/test_utils/datasourcetest.go create mode 100644 zitadel/v2/org/datasource_test.go diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index b9381093..9da4e4d8 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -73,5 +73,10 @@ KEY } func (b *BaseTestFrame) State(state *terraform.State) *terraform.InstanceState { - return state.RootModule().Resources[b.TerraformName].Primary + resources := state.RootModule().Resources + resource := resources[b.TerraformName] + if resource != nil { + return resource.Primary + } + return resources["data."+b.TerraformName].Primary } diff --git a/zitadel/v2/helper/test_utils/datasourcetest.go b/zitadel/v2/helper/test_utils/datasourcetest.go new file mode 100644 index 00000000..7da72fb7 --- /dev/null +++ b/zitadel/v2/helper/test_utils/datasourcetest.go @@ -0,0 +1,35 @@ +package test_utils + +import ( + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func RunDatasourceTest( + t *testing.T, + frame BaseTestFrame, + config string, + awaitRemoteResource resource.TestCheckFunc, + expectProperties map[string]string, + expectError *regexp.Regexp, +) { + var checks []resource.TestCheckFunc + if awaitRemoteResource != nil { + checks = append(checks, CheckAMinute(awaitRemoteResource)) + } + for k, v := range expectProperties { + checks = append(checks, resource.TestCheckResourceAttr("data."+frame.TerraformName, k, v)) + } + resource.ParallelTest(t, resource.TestCase{ + Steps: []resource.TestStep{{ + Config: fmt.Sprintf("%s\n%s", frame.ProviderSnippet, config), + Check: resource.ComposeAggregateTestCheckFunc(checks...), + ExpectError: expectError, + }}, + ProtoV6ProviderFactories: frame.v6ProviderFactories, + ProtoV5ProviderFactories: frame.v5ProviderFactories, + }) +} diff --git a/zitadel/v2/org/datasource_test.go b/zitadel/v2/org/datasource_test.go new file mode 100644 index 00000000..dab7a4c4 --- /dev/null +++ b/zitadel/v2/org/datasource_test.go @@ -0,0 +1,121 @@ +package org_test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func TestAccOrgDatasource_ID(t *testing.T) { + datasourceName := "zitadel_org" + frame, err := test_utils.NewOrgTestFrame(datasourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + orgName := "org_datasource_" + frame.UniqueResourcesID + otherFrame, err := frame.AnotherOrg(orgName) + if err != nil { + t.Fatalf("could not switch to another org: %v", err) + } + test_utils.RunDatasourceTest( + t, + otherFrame.BaseTestFrame, + fmt.Sprintf(` +data "%s" "%s" { + id = "%s" +} +`, datasourceName, otherFrame.UniqueResourcesID, otherFrame.OrgID), + nil, + map[string]string{ + "id": otherFrame.OrgID, + "name": orgName, + "state": "ORG_STATE_ACTIVE", + }, + nil, + ) +} + +func TestAccOrgDatasource_Name(t *testing.T) { + datasourceName := "zitadel_org" + frame, err := test_utils.NewOrgTestFrame(datasourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + orgName := "org_datasource_" + frame.UniqueResourcesID + otherFrame, err := frame.AnotherOrg(orgName) + if err != nil { + t.Fatalf("could not switch to another org: %v", err) + } + test_utils.RunDatasourceTest( + t, + otherFrame.BaseTestFrame, + fmt.Sprintf(` +data "%s" "%s" { + name = "%s" +} +`, datasourceName, otherFrame.UniqueResourcesID, orgName), + checkRemoteProperty(otherFrame)(orgName), + map[string]string{ + "id": otherFrame.OrgID, + "name": orgName, + "state": "ORG_STATE_ACTIVE", + }, + nil, + ) +} + +func TestAccOrgDatasource_ID_Name_Match(t *testing.T) { + datasourceName := "zitadel_org" + frame, err := test_utils.NewOrgTestFrame(datasourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + orgName := "org_datasource_" + frame.UniqueResourcesID + otherFrame, err := frame.AnotherOrg(orgName) + if err != nil { + t.Fatalf("could not switch to another org: %v", err) + } + test_utils.RunDatasourceTest( + t, + otherFrame.BaseTestFrame, + fmt.Sprintf(` +data "%s" "%s" { + name = "%s" +} +`, datasourceName, otherFrame.UniqueResourcesID, orgName), + nil, + map[string]string{ + "id": otherFrame.OrgID, + "name": orgName, + "state": "ORG_STATE_ACTIVE", + }, + nil, + ) +} + +func TestAccOrgDatasource_ID_Name_Mismatch(t *testing.T) { + datasourceName := "zitadel_org" + frame, err := test_utils.NewOrgTestFrame(datasourceName) + if err != nil { + t.Fatalf("setting up test context failed: %v", err) + } + orgName := "org_datasource_" + frame.UniqueResourcesID + otherFrame, err := frame.AnotherOrg(orgName) + if err != nil { + t.Fatalf("could not switch to another org: %v", err) + } + test_utils.RunDatasourceTest( + t, + otherFrame.BaseTestFrame, + fmt.Sprintf(` +data "%s" "%s" { + name = "mismatching_org_name" +} +`, datasourceName, otherFrame.UniqueResourcesID), + nil, + nil, + regexp.MustCompile("the filters don't match exactly 1 org, but 0 orgs"), + ) +} From 51599288017296aa9332864781332e81da1cb03a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 01:17:34 +0200 Subject: [PATCH 217/260] fix err comparision --- zitadel/v2/helper/test_utils/lifecyletest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index c2fc75b0..b0f19fe2 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -82,7 +82,7 @@ func RunLifecyleTest[P comparable]( CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, ErrorCheck: func(err error) error { - if err != nil && allowNonEmptyPlan && strings.Contains(err.Error(), "After applying this test step and performing a `terraform refresh`, the plan was not empty After applying this test step and performing a "+"`terraform refresh`"+", the plan was not empty") { + if err != nil && allowNonEmptyPlan && strings.Contains(err.Error(), "After applying this test step and performing a `terraform refresh`, the plan was not empty") { t.Logf("Ignoring non-empty plan error because we can't guarantee consistency: %s", err.Error()) return nil } From 994dba2e62dbf4717a261e7e0998abf1c7de1192 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 01:31:11 +0200 Subject: [PATCH 218/260] feat: queriable org datasource --- zitadel/v2/org/const.go | 7 ++- zitadel/v2/org/datasource.go | 36 +++++++++-- zitadel/v2/org/funcs.go | 117 +++++++++++++++++++++++------------ zitadel/v2/org/resource.go | 12 +++- 4 files changed, 125 insertions(+), 47 deletions(-) diff --git a/zitadel/v2/org/const.go b/zitadel/v2/org/const.go index 8a14f9af..86dba678 100644 --- a/zitadel/v2/org/const.go +++ b/zitadel/v2/org/const.go @@ -1,6 +1,9 @@ package org const ( - nameVar = "name" - orgIDVar = "org_id" + orgIDVar = "id" + nameVar = "name" + domainVar = "domain" + stateVar = "state" + primaryDomainVar = "primary_domain" ) diff --git a/zitadel/v2/org/datasource.go b/zitadel/v2/org/datasource.go index 6127fb10..f9786ead 100644 --- a/zitadel/v2/org/datasource.go +++ b/zitadel/v2/org/datasource.go @@ -1,6 +1,13 @@ package org -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -8,16 +15,33 @@ func GetDatasource() *schema.Resource { Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", + Optional: true, + Description: "An organizations resource ID.", }, nameVar: { + Type: schema.TypeString, + Optional: true, + Description: "Name of the org.", + }, + domainVar: { + Type: schema.TypeString, + Optional: true, + Description: "A domain of the org.", + }, + stateVar: { + Type: schema.TypeString, + Optional: true, + Description: "State of the org" + helper.DescriptionEnumValuesList(org.OrgState_name), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(stateVar, value, org.OrgState_value) + }, + }, + primaryDomainVar: { Type: schema.TypeString, Computed: true, - Description: "Name of the org", + Description: "Primary domain of the org", }, }, - ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + ReadContext: queryDatasource, } } diff --git a/zitadel/v2/org/funcs.go b/zitadel/v2/org/funcs.go index ba95c169..f3b2eb8f 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/v2/org/funcs.go @@ -2,30 +2,27 @@ package org import ( "context" - "strings" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started delete") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetAdminClient(clientinfo) if err != nil { return diag.FromErr(err) } - _, err = client.RemoveOrg(ctx, &admin.RemoveOrgRequest{ OrgId: d.Id(), }) @@ -38,17 +35,14 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, "") if err != nil { return diag.FromErr(err) } - resp, err := client.AddOrg(ctx, &management.AddOrgRequest{ Name: d.Get(nameVar).(string), }) @@ -56,18 +50,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } d.SetId(resp.GetId()) - return nil } func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Id()) if err != nil { return diag.FromErr(err) @@ -82,47 +73,97 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } -func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - +func getByID(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started getByID") clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetAdminClient(clientinfo) if err != nil { return diag.FromErr(err) } - - resp, err := client.ListOrgs(ctx, &admin.ListOrgsRequest{}) - if err != nil { - return diag.Errorf("error while listing orgs: %v", err) - } - tflog.Debug(ctx, "found orgs", map[string]interface{}{ - "orglist": resp.Result, - }) - orgID := helper.GetID(d, orgIDVar) - tflog.Debug(ctx, "check if org is existing", map[string]interface{}{ - "id": orgID, + resp, err := client.GetOrgByID(ctx, &admin.GetOrgByIDRequest{ + Id: orgID, }) + if err != nil { + return diag.Errorf("error while getting org by id %s: %v", orgID, err) + } + return diag.FromErr(setResourceState(d, resp.GetOrg())) +} - for i := range resp.Result { - org := resp.Result[i] - if strings.Compare(org.GetId(), orgID) == 0 { - d.SetId(orgID) - tflog.Debug(ctx, "found org", map[string]interface{}{ - "id": orgID, - }) - if err := d.Set(nameVar, org.GetName()); err != nil { - return diag.Errorf("failed to set %s of org: %v", nameVar, err) - } - return nil +func queryDatasource(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started queryDatasource") + orgID := d.Get(orgIDVar).(string) + orgName := d.Get(nameVar).(string) + orgState := d.Get(stateVar).(string) + orgDomain := d.Get(domainVar).(string) + if orgID != "" && (orgName != "" || orgState != "" || orgDomain != "") { + return diag.Errorf("only %s or one or many in %s, %s and %s are supported", orgIDVar, nameVar, stateVar, domainVar) + } + if orgID != "" { + if err := getByID(ctx, d, m); err != nil { + return err } + return diag.FromErr(d.Set(orgIDVar, orgID)) + } + clientinfo, ok := m.(*helper.ClientInfo) + if !ok { + return diag.Errorf("failed to get client") + } + client, err := helper.GetAdminClient(clientinfo) + if err != nil { + return diag.FromErr(err) + } + req := &admin.ListOrgsRequest{} + if orgName != "" { + req.Queries = append(req.Queries, &org.OrgQuery{ + Query: &org.OrgQuery_NameQuery{ + NameQuery: &org.OrgNameQuery{Name: orgName}, + }, + }) + } + if orgState != "" { + req.Queries = append(req.Queries, &org.OrgQuery{ + Query: &org.OrgQuery_StateQuery{ + StateQuery: &org.OrgStateQuery{State: org.OrgState(org.OrgState_value[orgState])}, + }, + }) + } + if orgDomain != "" { + req.Queries = append(req.Queries, &org.OrgQuery{ + Query: &org.OrgQuery_DomainQuery{ + DomainQuery: &org.OrgDomainQuery{Domain: orgDomain}, + }, + }) + } + if len(req.Queries) == 0 { + return diag.Errorf("specify at least one filter") } + resp, err := client.ListOrgs(ctx, req) + if err != nil { + return diag.Errorf("error while getting org by id %s: %v", orgName, err) + } + if len(resp.Result) != 1 { + return diag.Errorf("the filters don't match exactly 1 org, but %d orgs", len(resp.Result)) + } + if err = setResourceState(d, resp.Result[0]); err != nil { + return diag.FromErr(err) + } + return diag.FromErr(d.Set(orgIDVar, resp.Result[0].Id)) +} - d.SetId("") - tflog.Debug(ctx, "org not found", map[string]interface{}{}) +func setResourceState(d *schema.ResourceData, remoteOrg *org.Org) error { + d.SetId(remoteOrg.Id) + if err := d.Set(nameVar, remoteOrg.Name); err != nil { + return err + } + if err := d.Set(primaryDomainVar, remoteOrg.PrimaryDomain); err != nil { + return err + } + if err := d.Set(stateVar, org.OrgState_name[int32(remoteOrg.State)]); err != nil { + return err + } return nil } diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go index 18279686..b0feed73 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/v2/org/resource.go @@ -13,10 +13,20 @@ func GetResource() *schema.Resource { Required: true, Description: "Name of the org", }, + primaryDomainVar: { + Type: schema.TypeString, + Computed: true, + Description: "Primary domain of the org", + }, + stateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the org", + }, }, CreateContext: create, DeleteContext: delete, - ReadContext: read, + ReadContext: getByID, UpdateContext: update, Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } From 4fdceeaff16fa277dfecad351ec1e1abddb4827e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 12:20:00 +0200 Subject: [PATCH 219/260] fix: validate ad tenant type --- zitadel/v2/idp_azure_ad/funcs.go | 23 ++++++++++++++++++----- zitadel/v2/org_idp_azure_ad/funcs.go | 12 ++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/v2/idp_azure_ad/funcs.go index 5e94073a..74f1e846 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/v2/idp_azure_ad/funcs.go @@ -2,6 +2,7 @@ package idp_azure_ad import ( "context" + "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -21,13 +22,17 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + tenant, err := ConstructTenant(d) + if err != nil { + return diag.FromErr(err) + } resp, err := client.AddAzureADProvider(ctx, &admin.AddAzureADProviderRequest{ Name: idp_utils.StringValue(d, idp_utils.NameVar), ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), Scopes: idp_utils.ScopesValue(d), ProviderOptions: idp_utils.ProviderOptionsValue(d), - Tenant: ConstructTenant(d), + Tenant: tenant, EmailVerified: idp_utils.BoolValue(d, EmailVerifiedVar), }) if err != nil { @@ -46,6 +51,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + tenant, err := ConstructTenant(d) + if err != nil { + return diag.FromErr(err) + } _, err = client.UpdateAzureADProvider(ctx, &admin.UpdateAzureADProviderRequest{ Id: d.Id(), Name: idp_utils.StringValue(d, idp_utils.NameVar), @@ -53,7 +62,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), Scopes: idp_utils.ScopesValue(d), ProviderOptions: idp_utils.ProviderOptionsValue(d), - Tenant: ConstructTenant(d), + Tenant: tenant, EmailVerified: idp_utils.BoolValue(d, EmailVerifiedVar), }) if err != nil { @@ -105,17 +114,21 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } -func ConstructTenant(d *schema.ResourceData) *idp.AzureADTenant { +func ConstructTenant(d *schema.ResourceData) (*idp.AzureADTenant, error) { tenant := &idp.AzureADTenant{} tenantId := idp_utils.StringValue(d, TenantIDVar) + tenantType := idp_utils.StringValue(d, TenantTypeVar) + if tenantId != "" && tenantType != "" { + return nil, fmt.Errorf("tenant_id and tenant_type are mutually exclusive, but got id %s and type %s", tenantId, tenantType) + } if tenantId != "" { tenant.Type = &idp.AzureADTenant_TenantId{ TenantId: tenantId, } } else { tenant.Type = &idp.AzureADTenant_TenantType{ - TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[idp_utils.StringValue(d, TenantTypeVar)]), + TenantType: idp.AzureADTenantType(idp.AzureADTenantType_value[tenantType]), } } - return tenant + return tenant, nil } diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go index 44adf409..510d9345 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -23,13 +23,17 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + tenant, err := idp_azure_ad.ConstructTenant(d) + if err != nil { + return diag.FromErr(err) + } resp, err := client.AddAzureADProvider(ctx, &management.AddAzureADProviderRequest{ Name: idp_utils.StringValue(d, idp_utils.NameVar), ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), Scopes: idp_utils.ScopesValue(d), ProviderOptions: idp_utils.ProviderOptionsValue(d), - Tenant: idp_azure_ad.ConstructTenant(d), + Tenant: tenant, EmailVerified: idp_utils.BoolValue(d, idp_azure_ad.EmailVerifiedVar), }) if err != nil { @@ -48,6 +52,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } + tenant, err := idp_azure_ad.ConstructTenant(d) + if err != nil { + return diag.FromErr(err) + } _, err = client.UpdateAzureADProvider(ctx, &management.UpdateAzureADProviderRequest{ Id: d.Id(), Name: idp_utils.StringValue(d, idp_utils.NameVar), @@ -55,7 +63,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), Scopes: idp_utils.ScopesValue(d), ProviderOptions: idp_utils.ProviderOptionsValue(d), - Tenant: idp_azure_ad.ConstructTenant(d), + Tenant: tenant, EmailVerified: idp_utils.BoolValue(d, idp_azure_ad.EmailVerifiedVar), }) if err != nil { From d2779e7812106456ef71b84ab17deaf6554ece05 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 9 Aug 2023 12:25:37 +0200 Subject: [PATCH 220/260] fix tests --- zitadel/v2/idp_azure_ad/resource_test.go | 3 +-- zitadel/v2/org_idp_azure_ad/resource_test.go | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index 0e2a51d5..fc8f4517 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -2,10 +2,10 @@ package idp_azure_ad_test import ( "fmt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) @@ -23,7 +23,6 @@ resource "%s" "%s" { client_secret = "%s" scopes = ["two", "scopes"] tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" - tenant_id = "atenantid" email_verified = true is_linking_allowed = false is_creation_allowed = true diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 056985e9..63441cfd 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -5,9 +5,8 @@ import ( "testing" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccZITADELOrgIdPAzureAD(t *testing.T) { @@ -25,7 +24,6 @@ resource "%s" "%s" { client_secret = "%s" scopes = ["two", "scopes"] tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" - tenant_id = "atenantid" email_verified = true is_linking_allowed = false is_creation_allowed = true From 5f66c60f579530580b4ab98520dc17b5ba801cb3 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Thu, 10 Aug 2023 17:12:46 +0200 Subject: [PATCH 221/260] fix: forceNew on version change in oidc apps --- zitadel/v2/application_oidc/funcs.go | 1 - zitadel/v2/application_oidc/resource.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index 19c6ddf1..b684e53f 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -70,7 +70,6 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia appTypeVar, authMethodTypeVar, postLogoutRedirectURIsVar, - versionVar, devModeVar, accessTokenTypeVar, accessTokenRoleAssertionVar, diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index 6e1c1455..ac468459 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -93,6 +93,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "Version" + helper.DescriptionEnumValuesList(app.OIDCVersion_name), Default: app.OIDCVersion_name[0], + ForceNew: true, }, devModeVar: { Type: schema.TypeBool, From 14e56a7bc8b486f96ad50d1ba76f198aaefc426a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 15 Aug 2023 13:07:43 +0200 Subject: [PATCH 222/260] separate list from get --- zitadel/provider.go | 1 + zitadel/v2/org/const.go | 3 ++ zitadel/v2/org/datasource.go | 53 +++++++++++++++++++++++- zitadel/v2/org/funcs.go | 80 +++++++++++++++++------------------- zitadel/v2/org/resource.go | 2 +- 5 files changed, 94 insertions(+), 45 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index b171141b..20caa8f3 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -197,6 +197,7 @@ func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ "zitadel_org": org.GetDatasource(), + "zitadel_orgs": org.ListDatasources(), "zitadel_human_user": human_user.GetDatasource(), "zitadel_machine_user": machine_user.GetDatasource(), "zitadel_project": project.GetDatasource(), diff --git a/zitadel/v2/org/const.go b/zitadel/v2/org/const.go index 86dba678..76793447 100644 --- a/zitadel/v2/org/const.go +++ b/zitadel/v2/org/const.go @@ -2,8 +2,11 @@ package org const ( orgIDVar = "id" + orgIDsVar = "ids" nameVar = "name" + nameMethodVar = "name_method" domainVar = "domain" + domainMethodVar = "domain_method" stateVar = "state" primaryDomainVar = "primary_domain" ) diff --git a/zitadel/v2/org/datasource.go b/zitadel/v2/org/datasource.go index f9786ead..04ce44cb 100644 --- a/zitadel/v2/org/datasource.go +++ b/zitadel/v2/org/datasource.go @@ -4,6 +4,7 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -15,19 +16,67 @@ func GetDatasource() *schema.Resource { Schema: map[string]*schema.Schema{ orgIDVar: { Type: schema.TypeString, - Optional: true, + Required: true, Description: "An organizations resource ID.", }, + nameVar: { + Type: schema.TypeString, + Computed: true, + Description: "Name of the org.", + }, + stateVar: { + Type: schema.TypeString, + Computed: true, + Description: "State of the org" + helper.DescriptionEnumValuesList(org.OrgState_name), + }, + primaryDomainVar: { + Type: schema.TypeString, + Computed: true, + Description: "Primary domain of the org", + }, + }, + ReadContext: get, + } +} + +func ListDatasources() *schema.Resource { + return &schema.Resource{ + Description: "Datasource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", + Schema: map[string]*schema.Schema{ + orgIDsVar: { + Type: schema.TypeList, + Computed: true, + Description: "A set of all organization IDs.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, nameVar: { Type: schema.TypeString, Optional: true, Description: "Name of the org.", }, + nameMethodVar: { + Type: schema.TypeString, + Optional: true, + Description: "Method for querying orgs by name" + helper.DescriptionEnumValuesList(object.TextQueryMethod_name), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(nameMethodVar, value, object.TextQueryMethod_value) + }, + Default: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS_IGNORE_CASE.String(), + }, domainVar: { Type: schema.TypeString, Optional: true, Description: "A domain of the org.", }, + domainMethodVar: { + Type: schema.TypeString, + Optional: true, + Description: "Method for querying orgs by domain" + helper.DescriptionEnumValuesList(object.TextQueryMethod_name), + ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { + return helper.EnumValueValidation(domainMethodVar, value, object.TextQueryMethod_value) + }, + InputDefault: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS_IGNORE_CASE.String(), + }, stateVar: { Type: schema.TypeString, Optional: true, @@ -42,6 +91,6 @@ func GetDatasource() *schema.Resource { Description: "Primary domain of the org", }, }, - ReadContext: queryDatasource, + ReadContext: list, } } diff --git a/zitadel/v2/org/funcs.go b/zitadel/v2/org/funcs.go index f3b2eb8f..9eb89f04 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/v2/org/funcs.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -73,8 +74,8 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } -func getByID(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started getByID") +func get(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started get") clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") @@ -90,24 +91,28 @@ func getByID(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Di if err != nil { return diag.Errorf("error while getting org by id %s: %v", orgID, err) } - return diag.FromErr(setResourceState(d, resp.GetOrg())) + remoteOrg := resp.GetOrg() + d.SetId(remoteOrg.Id) + if err := d.Set(nameVar, remoteOrg.Name); err != nil { + return diag.Errorf("error while setting org name %s: %v", remoteOrg.Name, err) + } + if err := d.Set(primaryDomainVar, remoteOrg.PrimaryDomain); err != nil { + return diag.Errorf("error while setting org primary domain %s: %v", remoteOrg.PrimaryDomain, err) + } + state := org.OrgState_name[int32(remoteOrg.State)] + if err := d.Set(stateVar, state); err != nil { + return diag.Errorf("error while setting org state %s: %v", state, err) + } + return nil } -func queryDatasource(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started queryDatasource") - orgID := d.Get(orgIDVar).(string) +func list(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + tflog.Info(ctx, "started list") orgName := d.Get(nameVar).(string) - orgState := d.Get(stateVar).(string) + orgNameMethod := d.Get(nameMethodVar).(string) orgDomain := d.Get(domainVar).(string) - if orgID != "" && (orgName != "" || orgState != "" || orgDomain != "") { - return diag.Errorf("only %s or one or many in %s, %s and %s are supported", orgIDVar, nameVar, stateVar, domainVar) - } - if orgID != "" { - if err := getByID(ctx, d, m); err != nil { - return err - } - return diag.FromErr(d.Set(orgIDVar, orgID)) - } + orgDomainMethod := d.Get(domainMethodVar).(string) + orgState := d.Get(stateVar).(string) clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") @@ -120,50 +125,41 @@ func queryDatasource(ctx context.Context, d *schema.ResourceData, m interface{}) if orgName != "" { req.Queries = append(req.Queries, &org.OrgQuery{ Query: &org.OrgQuery_NameQuery{ - NameQuery: &org.OrgNameQuery{Name: orgName}, + NameQuery: &org.OrgNameQuery{ + Name: orgName, + Method: object.TextQueryMethod(object.TextQueryMethod_value[orgNameMethod]), + }, }, }) } if orgState != "" { req.Queries = append(req.Queries, &org.OrgQuery{ Query: &org.OrgQuery_StateQuery{ - StateQuery: &org.OrgStateQuery{State: org.OrgState(org.OrgState_value[orgState])}, + StateQuery: &org.OrgStateQuery{ + State: org.OrgState(org.OrgState_value[orgState]), + }, }, }) } if orgDomain != "" { req.Queries = append(req.Queries, &org.OrgQuery{ Query: &org.OrgQuery_DomainQuery{ - DomainQuery: &org.OrgDomainQuery{Domain: orgDomain}, + DomainQuery: &org.OrgDomainQuery{ + Domain: orgDomain, + Method: object.TextQueryMethod(object.TextQueryMethod_value[orgDomainMethod]), + }, }, }) } - if len(req.Queries) == 0 { - return diag.Errorf("specify at least one filter") - } resp, err := client.ListOrgs(ctx, req) if err != nil { return diag.Errorf("error while getting org by id %s: %v", orgName, err) } - if len(resp.Result) != 1 { - return diag.Errorf("the filters don't match exactly 1 org, but %d orgs", len(resp.Result)) + orgIDs := make([]string, len(resp.Result)) + for i, org := range resp.Result { + orgIDs[i] = org.Id } - if err = setResourceState(d, resp.Result[0]); err != nil { - return diag.FromErr(err) - } - return diag.FromErr(d.Set(orgIDVar, resp.Result[0].Id)) -} - -func setResourceState(d *schema.ResourceData, remoteOrg *org.Org) error { - d.SetId(remoteOrg.Id) - if err := d.Set(nameVar, remoteOrg.Name); err != nil { - return err - } - if err := d.Set(primaryDomainVar, remoteOrg.PrimaryDomain); err != nil { - return err - } - if err := d.Set(stateVar, org.OrgState_name[int32(remoteOrg.State)]); err != nil { - return err - } - return nil + // If the ID is blank, the datasource is deleted and not usable. + d.SetId("-") + return diag.FromErr(d.Set(orgIDsVar, orgIDs)) } diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go index b0feed73..300d6ae2 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/v2/org/resource.go @@ -26,7 +26,7 @@ func GetResource() *schema.Resource { }, CreateContext: create, DeleteContext: delete, - ReadContext: getByID, + ReadContext: get, UpdateContext: update, Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } From 5c8e4dfaeb052d610ad158b65c9cae2cc3a1fc6a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 15 Aug 2023 15:18:12 +0200 Subject: [PATCH 223/260] test list and get org datasource --- zitadel/provider.go | 1 + zitadel/v2/helper/test_utils/base_frame.go | 7 +- .../v2/helper/test_utils/datasourcetest.go | 7 +- zitadel/v2/org/const.go | 10 +- zitadel/v2/org/datasource.go | 83 +++++++++++- zitadel/v2/org/datasource_test.go | 48 ++----- zitadel/v2/org/funcs.go | 119 ++++++++++++------ zitadel/v2/org/resource.go | 12 +- 8 files changed, 189 insertions(+), 98 deletions(-) diff --git a/zitadel/provider.go b/zitadel/provider.go index b171141b..20caa8f3 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -197,6 +197,7 @@ func Provider() *schema.Provider { return &schema.Provider{ DataSourcesMap: map[string]*schema.Resource{ "zitadel_org": org.GetDatasource(), + "zitadel_orgs": org.ListDatasources(), "zitadel_human_user": human_user.GetDatasource(), "zitadel_machine_user": machine_user.GetDatasource(), "zitadel_project": project.GetDatasource(), diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 9da4e4d8..89e2cb38 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -43,7 +43,7 @@ func NewBaseTestFrame(ctx context.Context, resourceType, domain string, jwtProfi provider "zitadel" { domain = "%s" insecure = "%t" - port = "%s" + port = "%s" jwt_profile_json = < Date: Thu, 17 Aug 2023 14:20:50 +0200 Subject: [PATCH 224/260] fmt examples --- docs/data-sources/action.md | 4 ++-- docs/data-sources/application_api.md | 4 ++-- docs/data-sources/application_oidc.md | 4 ++-- docs/data-sources/default_oidc_settings.md | 4 ++-- docs/data-sources/human_user.md | 4 ++-- docs/data-sources/machine_user.md | 4 ++-- docs/data-sources/org.md | 4 ++-- docs/data-sources/org_jwt_idp.md | 4 ++-- docs/data-sources/org_oidc_idp.md | 4 ++-- docs/data-sources/project.md | 4 ++-- docs/data-sources/project_role.md | 4 ++-- docs/data-sources/trigger_actions.md | 4 ++-- docs/resources/action.md | 2 +- docs/resources/application_api.md | 2 +- docs/resources/application_key.md | 2 +- docs/resources/application_oidc.md | 2 +- docs/resources/default_domain_claimed_message_text.md | 2 +- docs/resources/default_domain_policy.md | 2 +- docs/resources/default_init_message_text.md | 2 +- docs/resources/default_label_policy.md | 2 +- docs/resources/default_lockout_policy.md | 2 +- docs/resources/default_login_policy.md | 2 +- docs/resources/default_login_texts.md | 2 +- docs/resources/default_notification_policy.md | 2 +- docs/resources/default_oidc_settings.md | 8 ++++---- .../resources/default_password_change_message_text.md | 2 +- docs/resources/default_password_complexity_policy.md | 2 +- docs/resources/default_password_reset_message_text.md | 2 +- .../default_passwordless_registration_message_text.md | 2 +- docs/resources/default_privacy_policy.md | 9 +++++---- docs/resources/default_verify_email_message_text.md | 2 +- docs/resources/default_verify_phone_message_text.md | 2 +- docs/resources/domain.md | 6 +++--- docs/resources/domain_claimed_message_text.md | 2 +- docs/resources/domain_policy.md | 2 +- docs/resources/human_user.md | 2 +- docs/resources/init_message_text.md | 2 +- docs/resources/instance_member.md | 2 +- docs/resources/label_policy.md | 2 +- docs/resources/lockout_policy.md | 2 +- docs/resources/login_policy.md | 2 +- docs/resources/login_texts.md | 2 +- docs/resources/machine_key.md | 2 +- docs/resources/machine_user.md | 2 +- docs/resources/notification_policy.md | 2 +- docs/resources/org.md | 2 +- docs/resources/org_idp_jwt.md | 2 +- docs/resources/org_idp_oidc.md | 2 +- docs/resources/org_member.md | 2 +- docs/resources/password_change_message_text.md | 2 +- docs/resources/password_complexity_policy.md | 2 +- docs/resources/password_reset_message_text.md | 2 +- .../passwordless_registration_message_text.md | 2 +- docs/resources/personal_access_token.md | 2 +- docs/resources/privacy_policy.md | 11 ++++++----- docs/resources/project.md | 2 +- docs/resources/project_grant.md | 2 +- docs/resources/project_grant_member.md | 2 +- docs/resources/project_member.md | 2 +- docs/resources/project_role.md | 2 +- docs/resources/sms_provider_twilio.md | 2 +- docs/resources/smtp_config.md | 2 +- docs/resources/trigger_actions.md | 2 +- docs/resources/user_grant.md | 2 +- docs/resources/verify_email_message_text.md | 2 +- docs/resources/verify_phone_message_text.md | 2 +- examples/provider/data-sources/action.tf | 4 ++-- examples/provider/data-sources/application_api.tf | 4 ++-- examples/provider/data-sources/application_oidc.tf | 4 ++-- .../provider/data-sources/default_oidc_settings.tf | 4 ++-- examples/provider/data-sources/human_user.tf | 4 ++-- examples/provider/data-sources/machine_user.tf | 4 ++-- examples/provider/data-sources/org.tf | 4 ++-- examples/provider/data-sources/org_jwt_idp.tf | 4 ++-- examples/provider/data-sources/org_oidc_idp.tf | 4 ++-- examples/provider/data-sources/project.tf | 4 ++-- examples/provider/data-sources/project_role.tf | 4 ++-- examples/provider/data-sources/trigger_actions.tf | 4 ++-- examples/provider/resources/action.tf | 2 +- examples/provider/resources/app_key.tf | 2 +- examples/provider/resources/application_api.tf | 2 +- examples/provider/resources/application_oidc.tf | 2 +- .../resources/default_domain_claimed_message_text.tf | 2 +- examples/provider/resources/default_domain_policy.tf | 2 +- .../provider/resources/default_init_message_text.tf | 2 +- examples/provider/resources/default_label_policy.tf | 2 +- examples/provider/resources/default_lockout_policy.tf | 2 +- examples/provider/resources/default_login_policy.tf | 2 +- examples/provider/resources/default_login_texts.tf | 2 +- .../provider/resources/default_notification_policy.tf | 2 +- examples/provider/resources/default_oidc_settings.tf | 8 ++++---- .../resources/default_password_change_message_text.tf | 2 +- .../resources/default_password_complexity_policy.tf | 2 +- .../resources/default_password_reset_message_text.tf | 2 +- .../default_passwordless_registration_message_text.tf | 2 +- examples/provider/resources/default_privacy_policy.tf | 2 +- .../resources/default_verify_email_message_text.tf | 2 +- .../resources/default_verify_phone_message_text.tf | 2 +- examples/provider/resources/domain.tf | 6 +++--- .../provider/resources/domain_claimed_message_text.tf | 2 +- examples/provider/resources/domain_policy.tf | 2 +- examples/provider/resources/granted_human_user.tf | 2 +- examples/provider/resources/granted_org.tf | 2 +- examples/provider/resources/human_user.tf | 2 +- examples/provider/resources/init_message_text.tf | 2 +- examples/provider/resources/instance_member.tf | 2 +- examples/provider/resources/label_policy.tf | 2 +- examples/provider/resources/lockout_policy.tf | 2 +- examples/provider/resources/login_policy.tf | 2 +- examples/provider/resources/login_texts.tf | 2 +- examples/provider/resources/machine_key.tf | 2 +- examples/provider/resources/machine_user.tf | 2 +- examples/provider/resources/notification_policy.tf | 2 +- examples/provider/resources/org.tf | 2 +- examples/provider/resources/org_idp_jwt.tf | 2 +- examples/provider/resources/org_idp_oidc.tf | 2 +- examples/provider/resources/org_member.tf | 2 +- .../resources/password_change_message_text.tf | 2 +- .../provider/resources/password_complexity_policy.tf | 2 +- .../provider/resources/password_reset_message_text.tf | 2 +- .../passwordless_registration_message_text.tf | 2 +- examples/provider/resources/personal_access_token.tf | 2 +- examples/provider/resources/privacy_policy.tf | 2 +- examples/provider/resources/project.tf | 2 +- examples/provider/resources/project_grant.tf | 2 +- examples/provider/resources/project_grant_member.tf | 2 +- examples/provider/resources/project_member.tf | 2 +- examples/provider/resources/project_role.tf | 2 +- examples/provider/resources/sms_provider_twilio.tf | 2 +- examples/provider/resources/smtp_config.tf | 2 +- examples/provider/resources/trigger_actions.tf | 2 +- examples/provider/resources/user_grant.tf | 2 +- .../provider/resources/verify_email_message_text.tf | 2 +- .../provider/resources/verify_phone_message_text.tf | 2 +- 134 files changed, 177 insertions(+), 175 deletions(-) diff --git a/docs/data-sources/action.md b/docs/data-sources/action.md index de656e4b..2fe65cd5 100644 --- a/docs/data-sources/action.md +++ b/docs/data-sources/action.md @@ -12,12 +12,12 @@ Datasource representing an action belonging to an organization. ## Example Usage ```terraform -data zitadel_action action { +data "zitadel_action" "action" { org_id = data.zitadel_org.org.id action_id = "177073621691269123" } -output action { +output "action" { value = data.zitadel_action.action } ``` diff --git a/docs/data-sources/application_api.md b/docs/data-sources/application_api.md index 492948be..b611b17f 100644 --- a/docs/data-sources/application_api.md +++ b/docs/data-sources/application_api.md @@ -12,13 +12,13 @@ Datasource representing an API application belonging to a project, with all conf ## Example Usage ```terraform -data zitadel_application_api api_application { +data "zitadel_application_api" "api_application" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073625566806019" } -output api_application { +output "api_application" { value = data.zitadel_application_api.api_application } ``` diff --git a/docs/data-sources/application_oidc.md b/docs/data-sources/application_oidc.md index cd0ccc1f..d96e74f7 100644 --- a/docs/data-sources/application_oidc.md +++ b/docs/data-sources/application_oidc.md @@ -12,13 +12,13 @@ Datasource representing an OIDC application belonging to a project, with all con ## Example Usage ```terraform -data zitadel_application_oidc oidc_application { +data "zitadel_application_oidc" "oidc_application" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073626925760515" } -output oidc_application { +output "oidc_application" { value = data.zitadel_application_oidc.oidc_application } ``` diff --git a/docs/data-sources/default_oidc_settings.md b/docs/data-sources/default_oidc_settings.md index 85366afa..88a28399 100644 --- a/docs/data-sources/default_oidc_settings.md +++ b/docs/data-sources/default_oidc_settings.md @@ -12,9 +12,9 @@ Datasource representing the default oidc settings. ## Example Usage ```terraform -data zitadel_default_oidc_settings oidc_settings {} +data "zitadel_default_oidc_settings" "oidc_settings" {} -output oidc_settings { +output "oidc_settings" { value = data.zitadel_default_oidc_settings.oidc_settings } ``` diff --git a/docs/data-sources/human_user.md b/docs/data-sources/human_user.md index 1a10a0cc..56dc4235 100644 --- a/docs/data-sources/human_user.md +++ b/docs/data-sources/human_user.md @@ -12,12 +12,12 @@ Datasource representing a human user situated under an organization, which then ## Example Usage ```terraform -data zitadel_human_user human_user { +data "zitadel_human_user" "human_user" { org_id = data.zitadel_org.org.id user_id = "177073614158299139" } -output human_user { +output "human_user" { value = data.zitadel_human_user.human_user } ``` diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md index da5576ef..c1318e51 100644 --- a/docs/data-sources/machine_user.md +++ b/docs/data-sources/machine_user.md @@ -12,12 +12,12 @@ Datasource representing a serviceaccount situated under an organization, which t ## Example Usage ```terraform -data zitadel_machine_user machine_user { +data "zitadel_machine_user" "machine_user" { org_id = data.zitadel_org.org.id user_id = "177073617463410691" } -output machine_user { +output "machine_user" { value = data.zitadel_machine_user.machine_user } ``` diff --git a/docs/data-sources/org.md b/docs/data-sources/org.md index 1e761573..24bf45d0 100644 --- a/docs/data-sources/org.md +++ b/docs/data-sources/org.md @@ -12,11 +12,11 @@ Datasource representing an organization in ZITADEL, which is the highest level a ## Example Usage ```terraform -data zitadel_org org { +data "zitadel_org" "org" { org_id = "177073608051458051" } -output org { +output "org" { value = data.zitadel_org.org } ``` diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md index 8137ebd5..88e38692 100644 --- a/docs/data-sources/org_jwt_idp.md +++ b/docs/data-sources/org_jwt_idp.md @@ -12,12 +12,12 @@ Datasource representing a generic JWT IdP on the organization. ## Example Usage ```terraform -data zitadel_org_jwt_idp org_jwt_idp { +data "zitadel_org_jwt_idp" "org_jwt_idp" { org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } -output org_jwt_idp { +output "org_jwt_idp" { value = data.zitadel_org_jwt_idp.org_jwt_idp } ``` diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md index 4dfef712..3942590e 100644 --- a/docs/data-sources/org_oidc_idp.md +++ b/docs/data-sources/org_oidc_idp.md @@ -12,12 +12,12 @@ Datasource representing a generic OIDC IdP on the organization. ## Example Usage ```terraform -data zitadel_org_oidc_idp org_oidc_idp { +data "zitadel_org_oidc_idp" "org_oidc_idp" { org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } -output org_oidc_idp { +output "org_oidc_idp" { value = data.zitadel_org_oidc_idp.org_oidc_idp } ``` diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 741f04b4..b181c15c 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -12,12 +12,12 @@ Datasource representing the project, which can then be granted to different orga ## Example Usage ```terraform -data zitadel_project project { +data "zitadel_project" "project" { org_id = data.zitadel_org.org.id project_id = "177073620768522243" } -output project { +output "project" { value = data.zitadel_project.project } ``` diff --git a/docs/data-sources/project_role.md b/docs/data-sources/project_role.md index ccdd19e8..55e89ed7 100644 --- a/docs/data-sources/project_role.md +++ b/docs/data-sources/project_role.md @@ -12,13 +12,13 @@ Datasource representing the project roles, which can be given as authorizations ## Example Usage ```terraform -data zitadel_project_role project_role { +data "zitadel_project_role" "project_role" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id role_key = "key" } -output project_role { +output "project_role" { value = data.zitadel_project_role.project_role } ``` diff --git a/docs/data-sources/trigger_actions.md b/docs/data-sources/trigger_actions.md index 7c56c276..eba3488e 100644 --- a/docs/data-sources/trigger_actions.md +++ b/docs/data-sources/trigger_actions.md @@ -12,13 +12,13 @@ Resource representing triggers, when actions get started ## Example Usage ```terraform -data zitadel_trigger_actions trigger_actions { +data "zitadel_trigger_actions" "trigger_actions" { org_id = data.zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" } -output trigger_actions { +output "trigger_actions" { value = data.zitadel_trigger_actions.trigger_actions } ``` diff --git a/docs/resources/action.md b/docs/resources/action.md index 3252e976..bc0a3d40 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -12,7 +12,7 @@ Resource representing an action belonging to an organization. ## Example Usage ```terraform -resource zitadel_action action { +resource "zitadel_action" "action" { org_id = zitadel_org.org.id name = "actionname" script = "testscript" diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index b94cbfcf..a09becf9 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -12,7 +12,7 @@ Resource representing an API application belonging to a project, with all config ## Example Usage ```terraform -resource zitadel_application_api application_api { +resource "zitadel_application_api" "application_api" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 28189e7a..4cf470c5 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -12,7 +12,7 @@ Resource representing a app key ## Example Usage ```terraform -resource zitadel_application_key app_key { +resource "zitadel_application_key" "app_key" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id app_id = zitadel_application_api.application_api.id diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 8a0202fa..1e44aeb5 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -12,7 +12,7 @@ Resource representing an OIDC application belonging to a project, with all confi ## Example Usage ```terraform -resource zitadel_application_oidc application_oidc { +resource "zitadel_application_oidc" "application_oidc" { project_id = zitadel_project.project.id org_id = zitadel_org.org.id diff --git a/docs/resources/default_domain_claimed_message_text.md b/docs/resources/default_domain_claimed_message_text.md index 863b2996..8c18e215 100644 --- a/docs/resources/default_domain_claimed_message_text.md +++ b/docs/resources/default_domain_claimed_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_domain_claimed_message_text domain_claimed_en { +resource "zitadel_default_domain_claimed_message_text" "domain_claimed_en" { language = "en" title = "title example" diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md index 80da8ed6..6777bf92 100644 --- a/docs/resources/default_domain_policy.md +++ b/docs/resources/default_domain_policy.md @@ -12,7 +12,7 @@ Resource representing the default domain policy. ## Example Usage ```terraform -resource zitadel_default_domain_policy domain_policy { +resource "zitadel_default_domain_policy" "domain_policy" { user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/docs/resources/default_init_message_text.md b/docs/resources/default_init_message_text.md index 54be0f80..3312e5e6 100644 --- a/docs/resources/default_init_message_text.md +++ b/docs/resources/default_init_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_init_message_text init_en { +resource "zitadel_default_init_message_text" "init_en" { language = "en" title = "title example" diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index b4d737b4..eac97561 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -12,7 +12,7 @@ Resource representing the default label policy. ## Example Usage ```terraform -resource zitadel_default_label_policy label_policy { +resource "zitadel_default_label_policy" "label_policy" { primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md index cea2f992..1e5330d5 100644 --- a/docs/resources/default_lockout_policy.md +++ b/docs/resources/default_lockout_policy.md @@ -12,7 +12,7 @@ Resource representing the default lockout policy. ## Example Usage ```terraform -resource zitadel_default_lockout_policy lockout_policy { +resource "zitadel_default_lockout_policy" "lockout_policy" { max_password_attempts = "5" } ``` diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index ec7aaac5..d0d77006 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -12,7 +12,7 @@ Resource representing the default login policy. ## Example Usage ```terraform -resource zitadel_default_login_policy login_policy { +resource "zitadel_default_login_policy" "login_policy" { user_login = true allow_register = true allow_external_idp = true diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md index 8fc0784f..00d691e8 100644 --- a/docs/resources/default_login_texts.md +++ b/docs/resources/default_login_texts.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_login_texts login_texts_en { +resource "zitadel_default_login_texts" "login_texts_en" { language = "en" email_verification_done_text = { diff --git a/docs/resources/default_notification_policy.md b/docs/resources/default_notification_policy.md index a3ff90f0..f67cdf2b 100644 --- a/docs/resources/default_notification_policy.md +++ b/docs/resources/default_notification_policy.md @@ -12,7 +12,7 @@ Resource representing the default notification policy. ## Example Usage ```terraform -resource zitadel_default_notification_policy notification_policy { +resource "zitadel_default_notification_policy" "notification_policy" { password_change = false } ``` diff --git a/docs/resources/default_oidc_settings.md b/docs/resources/default_oidc_settings.md index 0251eb3a..090ec274 100644 --- a/docs/resources/default_oidc_settings.md +++ b/docs/resources/default_oidc_settings.md @@ -12,10 +12,10 @@ Resource representing the default oidc settings. ## Example Usage ```terraform -resource zitadel_default_oidc_settings oidc_settings { - access_token_lifetime = "12h0m0s" - id_token_lifetime = "12h0m0s" - refresh_token_expiration = "720h0m0s" +resource "zitadel_default_oidc_settings" "oidc_settings" { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" refresh_token_idle_expiration = "2160h0m0s" } ``` diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md index 50309af5..95f44b6f 100644 --- a/docs/resources/default_password_change_message_text.md +++ b/docs/resources/default_password_change_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_password_change_message_text password_change_en { +resource "zitadel_default_password_change_message_text" "password_change_en" { language = "en" title = "title example" diff --git a/docs/resources/default_password_complexity_policy.md b/docs/resources/default_password_complexity_policy.md index 4d87410b..54041abc 100644 --- a/docs/resources/default_password_complexity_policy.md +++ b/docs/resources/default_password_complexity_policy.md @@ -12,7 +12,7 @@ Resource representing the default password complexity policy. ## Example Usage ```terraform -resource zitadel_default_password_complexity_policy password_complexity_policy { +resource "zitadel_default_password_complexity_policy" "password_complexity_policy" { min_length = "8" has_uppercase = true has_lowercase = true diff --git a/docs/resources/default_password_reset_message_text.md b/docs/resources/default_password_reset_message_text.md index 82ef6aad..5ba3a324 100644 --- a/docs/resources/default_password_reset_message_text.md +++ b/docs/resources/default_password_reset_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_password_reset_message_text password_reset_en { +resource "zitadel_default_password_reset_message_text" "password_reset_en" { language = "en" title = "title example" diff --git a/docs/resources/default_passwordless_registration_message_text.md b/docs/resources/default_passwordless_registration_message_text.md index 5f6a119b..cfa8dc5e 100644 --- a/docs/resources/default_passwordless_registration_message_text.md +++ b/docs/resources/default_passwordless_registration_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_default_passwordless_registration_message_text" "passwordless_registration_en" { language = "en" title = "title example" diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index 9684a246..75bbfb6b 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -12,10 +12,11 @@ Resource representing the default privacy policy. ## Example Usage ```terraform -resource zitadel_default_privacy_policy privacy_policy { - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" +resource "zitadel_default_privacy_policy" "privacy_policy" { + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" } ``` diff --git a/docs/resources/default_verify_email_message_text.md b/docs/resources/default_verify_email_message_text.md index 58a05475..ea69bdd0 100644 --- a/docs/resources/default_verify_email_message_text.md +++ b/docs/resources/default_verify_email_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_verify_email_message_text verify_email_en { +resource "zitadel_default_verify_email_message_text" "verify_email_en" { language = "en" title = "title example" diff --git a/docs/resources/default_verify_phone_message_text.md b/docs/resources/default_verify_phone_message_text.md index 1e19d653..6b285e7c 100644 --- a/docs/resources/default_verify_phone_message_text.md +++ b/docs/resources/default_verify_phone_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_verify_phone_message_text verify_phone_en { +resource "zitadel_default_verify_phone_message_text" "verify_phone_en" { language = "en" title = "title example" diff --git a/docs/resources/domain.md b/docs/resources/domain.md index f4a971f3..43a600a3 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -12,9 +12,9 @@ Resource representing a domain of the organization. ## Example Usage ```terraform -resource zitadel_domain domain { - org_id = zitadel_org.org.id - name = "zitadel.default.127.0.0.1.sslip.io" +resource "zitadel_domain" "domain" { + org_id = zitadel_org.org.id + name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } ``` diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md index 0f5dbe02..2192fbb3 100644 --- a/docs/resources/domain_claimed_message_text.md +++ b/docs/resources/domain_claimed_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_domain_claimed_message_text domain_claimed_en { +resource "zitadel_domain_claimed_message_text" "domain_claimed_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 2a4ae722..ba00ea22 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -12,7 +12,7 @@ Resource representing the custom domain policy of an organization. ## Example Usage ```terraform -resource zitadel_domain_policy domain_policy { +resource "zitadel_domain_policy" "domain_policy" { org_id = zitadel_org.org.id user_login_must_be_domain = false validate_org_domains = false diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index fe47c469..325aa995 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -14,7 +14,7 @@ Resource representing a human user situated under an organization, which then ca ## Example Usage ```terraform -resource zitadel_human_user human_user { +resource "zitadel_human_user" "human_user" { org_id = zitadel_org.org.id user_name = "humanfull@localhost.com" first_name = "firstname" diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md index 0fba96e5..a47b324e 100644 --- a/docs/resources/init_message_text.md +++ b/docs/resources/init_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_init_message_text init_en { +resource "zitadel_init_message_text" "init_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 3779fbe3..6be4d463 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -12,7 +12,7 @@ Resource representing the membership of a user on an instance, defined with the ## Example Usage ```terraform -resource zitadel_instance_member instance_member { +resource "zitadel_instance_member" "instance_member" { user_id = zitadel_human_user.human_user.id roles = ["IAM_OWNER"] } diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index e5819ea9..99687202 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -12,7 +12,7 @@ Resource representing the custom label policy of an organization. ## Example Usage ```terraform -resource zitadel_label_policy label_policy { +resource "zitadel_label_policy" "label_policy" { org_id = zitadel_org.org.id primary_color = "#5469d4" hide_login_name_suffix = true diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index 17113399..dad7264a 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -12,7 +12,7 @@ Resource representing the custom lockout policy of an organization. ## Example Usage ```terraform -resource zitadel_lockout_policy lockout_policy { +resource "zitadel_lockout_policy" "lockout_policy" { org_id = zitadel_org.org.id max_password_attempts = "5" } diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 304a7233..ea623014 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -12,7 +12,7 @@ Resource representing the custom login policy of an organization. ## Example Usage ```terraform -resource zitadel_login_policy login_policy { +resource "zitadel_login_policy" "login_policy" { org_id = zitadel_org.org.id user_login = true allow_register = true diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index be4efd37..faf234fa 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_login_texts login_texts_en { +resource "zitadel_login_texts" "login_texts_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index d131fad7..af20b527 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -12,7 +12,7 @@ Resource representing a machine key ## Example Usage ```terraform -resource zitadel_machine_key machine_key { +resource "zitadel_machine_key" "machine_key" { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index d6b7ed04..cf504197 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -12,7 +12,7 @@ Resource representing a serviceaccount situated under an organization, which the ## Example Usage ```terraform -resource zitadel_machine_user machine_user { +resource "zitadel_machine_user" "machine_user" { org_id = zitadel_org.org.id user_name = "machine@localhost.com" name = "name" diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index 4c3e0476..dd193afd 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -12,7 +12,7 @@ Resource representing the custom notification policy of an organization. ## Example Usage ```terraform -resource zitadel_notification_policy notification_policy { +resource "zitadel_notification_policy" "notification_policy" { org_id = zitadel_org.org.id password_change = false } diff --git a/docs/resources/org.md b/docs/resources/org.md index 2084130b..28ff2063 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -12,7 +12,7 @@ Resource representing an organization in ZITADEL, which is the highest level aft ## Example Usage ```terraform -resource zitadel_org org { +resource "zitadel_org" "org" { name = "terraform-test" } ``` diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 0c355353..80113eab 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -12,7 +12,7 @@ Resource representing a generic JWT IdP of the organization. ## Example Usage ```terraform -resource zitadel_org_idp_jwt jwt_idp { +resource "zitadel_org_idp_jwt" "jwt_idp" { org_id = zitadel_org.org.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index 7d217b59..fa0654a4 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -12,7 +12,7 @@ Resource representing a generic OIDC IdP on the organization. ## Example Usage ```terraform -resource zitadel_org_idp_oidc oidc_idp { +resource "zitadel_org_idp_oidc" "oidc_idp" { org_id = zitadel_org.org.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 858846e7..8c2817a4 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -12,7 +12,7 @@ Resource representing the membership of a user on an organization, defined with ## Example Usage ```terraform -resource zitadel_org_member org_member { +resource "zitadel_org_member" "org_member" { org_id = zitadel_org.org.id user_id = zitadel_human_user.human_user.id roles = ["ORG_OWNER"] diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index 40dbcf1f..c50e8f4d 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_password_change_message_text password_change_en { +resource "zitadel_password_change_message_text" "password_change_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index e47ae90b..ca460d87 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -12,7 +12,7 @@ Resource representing the custom password complexity policy of an organization. ## Example Usage ```terraform -resource zitadel_password_complexity_policy password_complexity_policy { +resource "zitadel_password_complexity_policy" "password_complexity_policy" { org_id = zitadel_org.org.id min_length = "8" has_uppercase = true diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md index 2c0c6a40..10285062 100644 --- a/docs/resources/password_reset_message_text.md +++ b/docs/resources/password_reset_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_password_reset_message_text password_reset_en { +resource "zitadel_password_reset_message_text" "password_reset_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md index 4526496e..e30a0361 100644 --- a/docs/resources/passwordless_registration_message_text.md +++ b/docs/resources/passwordless_registration_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_passwordless_registration_message_text" "passwordless_registration_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 09c87b0d..6bfcf035 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -12,7 +12,7 @@ Resource representing a personal access token of a user ## Example Usage ```terraform -resource zitadel_personal_access_token pat { +resource "zitadel_personal_access_token" "pat" { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id expiration_date = "2519-04-01T08:45:00Z" diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 374a573b..9194badf 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -12,11 +12,12 @@ Resource representing the custom privacy policy of an organization. ## Example Usage ```terraform -resource zitadel_privacy_policy privacy_policy { - org_id = zitadel_org.org.id - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" +resource "zitadel_privacy_policy" "privacy_policy" { + org_id = zitadel_org.org.id + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" } ``` diff --git a/docs/resources/project.md b/docs/resources/project.md index 88612eea..80b112c9 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -12,7 +12,7 @@ Resource representing the project, which can then be granted to different organi ## Example Usage ```terraform -resource zitadel_project project { +resource "zitadel_project" "project" { name = "projectname" org_id = zitadel_org.org.id project_role_assertion = true diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 6f3fc0d1..f1d323dc 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -12,7 +12,7 @@ Resource representing the grant of a project to a different organization, also c ## Example Usage ```terraform -resource zitadel_project_grant project_grant { +resource "zitadel_project_grant" "project_grant" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id granted_org_id = zitadel_org.grantedorg.id diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 3a2587d2..c7b7470b 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -12,7 +12,7 @@ Resource representing the membership of a user on an granted project, defined wi ## Example Usage ```terraform -resource zitadel_project_grant_member project_grant_member { +resource "zitadel_project_grant_member" "project_grant_member" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id grant_id = zitadel_project_grant.project_grant.id diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index 14286715..6da813a1 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -12,7 +12,7 @@ Resource representing the membership of a user on an project, defined with the g ## Example Usage ```terraform -resource zitadel_project_member project_member { +resource "zitadel_project_member" "project_member" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id user_id = zitadel_human_user.human_user.id diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index 1624787c..5f2d4db1 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -12,7 +12,7 @@ Resource representing the project roles, which can be given as authorizations to ## Example Usage ```terraform -resource zitadel_project_role project_role { +resource "zitadel_project_role" "project_role" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id role_key = "key" diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index 1c30dcc9..9a7588f9 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -12,7 +12,7 @@ Resource representing the SMS provider Twilio configuration of an instance. ## Example Usage ```terraform -resource zitadel_sms_provider_twilio twilio { +resource "zitadel_sms_provider_twilio" "twilio" { sid = "sid" sender_number = "019920892" token = "token" diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index 6ca2635a..60123fc2 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -12,7 +12,7 @@ Resource representing the SMTP configuration of an instance. ## Example Usage ```terraform -resource zitadel_smtp_config smtp { +resource "zitadel_smtp_config" "smtp" { sender_address = "address" sender_name = "no-reply" tls = true diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index c2ca5fa0..3a627764 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -12,7 +12,7 @@ Resource representing triggers, when actions get started ## Example Usage ```terraform -resource zitadel_trigger_actions trigger_actions { +resource "zitadel_trigger_actions" "trigger_actions" { org_id = zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 78114dcc..f897d579 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -12,7 +12,7 @@ Resource representing the authorization given to a user directly, including the ## Example Usage ```terraform -resource zitadel_user_grant user_grant { +resource "zitadel_user_grant" "user_grant" { project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = ["key"] diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md index 00886751..51909e9b 100644 --- a/docs/resources/verify_email_message_text.md +++ b/docs/resources/verify_email_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_email_message_text verify_email_en { +resource "zitadel_verify_email_message_text" "verify_email_en" { org_id = zitadel_org.org.id language = "en" diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md index 3d00af67..7765ea26 100644 --- a/docs/resources/verify_phone_message_text.md +++ b/docs/resources/verify_phone_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_phone_message_text verify_phone_en { +resource "zitadel_verify_phone_message_text" "verify_phone_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/data-sources/action.tf b/examples/provider/data-sources/action.tf index b9fcb04f..49d93407 100644 --- a/examples/provider/data-sources/action.tf +++ b/examples/provider/data-sources/action.tf @@ -1,8 +1,8 @@ -data zitadel_action action { +data "zitadel_action" "action" { org_id = data.zitadel_org.org.id action_id = "177073621691269123" } -output action { +output "action" { value = data.zitadel_action.action } \ No newline at end of file diff --git a/examples/provider/data-sources/application_api.tf b/examples/provider/data-sources/application_api.tf index a0f30f72..e671938b 100644 --- a/examples/provider/data-sources/application_api.tf +++ b/examples/provider/data-sources/application_api.tf @@ -1,9 +1,9 @@ -data zitadel_application_api api_application { +data "zitadel_application_api" "api_application" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073625566806019" } -output api_application { +output "api_application" { value = data.zitadel_application_api.api_application } \ No newline at end of file diff --git a/examples/provider/data-sources/application_oidc.tf b/examples/provider/data-sources/application_oidc.tf index d70d1bcc..80f34a91 100644 --- a/examples/provider/data-sources/application_oidc.tf +++ b/examples/provider/data-sources/application_oidc.tf @@ -1,9 +1,9 @@ -data zitadel_application_oidc oidc_application { +data "zitadel_application_oidc" "oidc_application" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id app_id = "177073626925760515" } -output oidc_application { +output "oidc_application" { value = data.zitadel_application_oidc.oidc_application } \ No newline at end of file diff --git a/examples/provider/data-sources/default_oidc_settings.tf b/examples/provider/data-sources/default_oidc_settings.tf index 6ff3b5ba..ba3c51a6 100644 --- a/examples/provider/data-sources/default_oidc_settings.tf +++ b/examples/provider/data-sources/default_oidc_settings.tf @@ -1,5 +1,5 @@ -data zitadel_default_oidc_settings oidc_settings {} +data "zitadel_default_oidc_settings" "oidc_settings" {} -output oidc_settings { +output "oidc_settings" { value = data.zitadel_default_oidc_settings.oidc_settings } diff --git a/examples/provider/data-sources/human_user.tf b/examples/provider/data-sources/human_user.tf index 7570eaeb..922f9597 100644 --- a/examples/provider/data-sources/human_user.tf +++ b/examples/provider/data-sources/human_user.tf @@ -1,8 +1,8 @@ -data zitadel_human_user human_user { +data "zitadel_human_user" "human_user" { org_id = data.zitadel_org.org.id user_id = "177073614158299139" } -output human_user { +output "human_user" { value = data.zitadel_human_user.human_user } \ No newline at end of file diff --git a/examples/provider/data-sources/machine_user.tf b/examples/provider/data-sources/machine_user.tf index 10badde8..1981d492 100644 --- a/examples/provider/data-sources/machine_user.tf +++ b/examples/provider/data-sources/machine_user.tf @@ -1,8 +1,8 @@ -data zitadel_machine_user machine_user { +data "zitadel_machine_user" "machine_user" { org_id = data.zitadel_org.org.id user_id = "177073617463410691" } -output machine_user { +output "machine_user" { value = data.zitadel_machine_user.machine_user } \ No newline at end of file diff --git a/examples/provider/data-sources/org.tf b/examples/provider/data-sources/org.tf index 21b23ca7..a6baa792 100644 --- a/examples/provider/data-sources/org.tf +++ b/examples/provider/data-sources/org.tf @@ -1,7 +1,7 @@ -data zitadel_org org { +data "zitadel_org" "org" { org_id = "177073608051458051" } -output org { +output "org" { value = data.zitadel_org.org } diff --git a/examples/provider/data-sources/org_jwt_idp.tf b/examples/provider/data-sources/org_jwt_idp.tf index 08d47849..d0481292 100644 --- a/examples/provider/data-sources/org_jwt_idp.tf +++ b/examples/provider/data-sources/org_jwt_idp.tf @@ -1,8 +1,8 @@ -data zitadel_org_jwt_idp org_jwt_idp { +data "zitadel_org_jwt_idp" "org_jwt_idp" { org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } -output org_jwt_idp { +output "org_jwt_idp" { value = data.zitadel_org_jwt_idp.org_jwt_idp } \ No newline at end of file diff --git a/examples/provider/data-sources/org_oidc_idp.tf b/examples/provider/data-sources/org_oidc_idp.tf index 4d9e4c9e..a9bfdab9 100644 --- a/examples/provider/data-sources/org_oidc_idp.tf +++ b/examples/provider/data-sources/org_oidc_idp.tf @@ -1,8 +1,8 @@ -data zitadel_org_oidc_idp org_oidc_idp { +data "zitadel_org_oidc_idp" "org_oidc_idp" { org_id = data.zitadel_org.org.id idp_id = "177073612581240835" } -output org_oidc_idp { +output "org_oidc_idp" { value = data.zitadel_org_oidc_idp.org_oidc_idp } \ No newline at end of file diff --git a/examples/provider/data-sources/project.tf b/examples/provider/data-sources/project.tf index c252507d..22ddbd06 100644 --- a/examples/provider/data-sources/project.tf +++ b/examples/provider/data-sources/project.tf @@ -1,8 +1,8 @@ -data zitadel_project project { +data "zitadel_project" "project" { org_id = data.zitadel_org.org.id project_id = "177073620768522243" } -output project { +output "project" { value = data.zitadel_project.project } \ No newline at end of file diff --git a/examples/provider/data-sources/project_role.tf b/examples/provider/data-sources/project_role.tf index c4c00b91..79cccd4c 100644 --- a/examples/provider/data-sources/project_role.tf +++ b/examples/provider/data-sources/project_role.tf @@ -1,9 +1,9 @@ -data zitadel_project_role project_role { +data "zitadel_project_role" "project_role" { org_id = data.zitadel_org.org.id project_id = data.zitadel_project.project.id role_key = "key" } -output project_role { +output "project_role" { value = data.zitadel_project_role.project_role } \ No newline at end of file diff --git a/examples/provider/data-sources/trigger_actions.tf b/examples/provider/data-sources/trigger_actions.tf index f82a6594..f97940f6 100644 --- a/examples/provider/data-sources/trigger_actions.tf +++ b/examples/provider/data-sources/trigger_actions.tf @@ -1,9 +1,9 @@ -data zitadel_trigger_actions trigger_actions { +data "zitadel_trigger_actions" "trigger_actions" { org_id = data.zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" } -output trigger_actions { +output "trigger_actions" { value = data.zitadel_trigger_actions.trigger_actions } \ No newline at end of file diff --git a/examples/provider/resources/action.tf b/examples/provider/resources/action.tf index 8d1256b4..7c2d44be 100644 --- a/examples/provider/resources/action.tf +++ b/examples/provider/resources/action.tf @@ -1,4 +1,4 @@ -resource zitadel_action action { +resource "zitadel_action" "action" { org_id = zitadel_org.org.id name = "actionname" script = "testscript" diff --git a/examples/provider/resources/app_key.tf b/examples/provider/resources/app_key.tf index 3354852c..16435042 100644 --- a/examples/provider/resources/app_key.tf +++ b/examples/provider/resources/app_key.tf @@ -1,4 +1,4 @@ -resource zitadel_application_key app_key { +resource "zitadel_application_key" "app_key" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id app_id = zitadel_application_api.application_api.id diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index 57e96ab3..249071a6 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -1,4 +1,4 @@ -resource zitadel_application_api application_api { +resource "zitadel_application_api" "application_api" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id name = "applicationapi" diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index df1daa12..235c41ed 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,4 +1,4 @@ -resource zitadel_application_oidc application_oidc { +resource "zitadel_application_oidc" "application_oidc" { project_id = zitadel_project.project.id org_id = zitadel_org.org.id diff --git a/examples/provider/resources/default_domain_claimed_message_text.tf b/examples/provider/resources/default_domain_claimed_message_text.tf index ee5f7957..7bf3cdf6 100644 --- a/examples/provider/resources/default_domain_claimed_message_text.tf +++ b/examples/provider/resources/default_domain_claimed_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_domain_claimed_message_text domain_claimed_en { +resource "zitadel_default_domain_claimed_message_text" "domain_claimed_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_domain_policy.tf b/examples/provider/resources/default_domain_policy.tf index e0a64eaa..eb7ae054 100644 --- a/examples/provider/resources/default_domain_policy.tf +++ b/examples/provider/resources/default_domain_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_domain_policy domain_policy { +resource "zitadel_default_domain_policy" "domain_policy" { user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/examples/provider/resources/default_init_message_text.tf b/examples/provider/resources/default_init_message_text.tf index 1738cedc..4b266bda 100644 --- a/examples/provider/resources/default_init_message_text.tf +++ b/examples/provider/resources/default_init_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_init_message_text init_en { +resource "zitadel_default_init_message_text" "init_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_label_policy.tf b/examples/provider/resources/default_label_policy.tf index 082a48e8..7501997f 100644 --- a/examples/provider/resources/default_label_policy.tf +++ b/examples/provider/resources/default_label_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_label_policy label_policy { +resource "zitadel_default_label_policy" "label_policy" { primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/examples/provider/resources/default_lockout_policy.tf b/examples/provider/resources/default_lockout_policy.tf index 4a64e7e4..f692abe1 100644 --- a/examples/provider/resources/default_lockout_policy.tf +++ b/examples/provider/resources/default_lockout_policy.tf @@ -1,3 +1,3 @@ -resource zitadel_default_lockout_policy lockout_policy { +resource "zitadel_default_lockout_policy" "lockout_policy" { max_password_attempts = "5" } \ No newline at end of file diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index 43796d7c..607426da 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_login_policy login_policy { +resource "zitadel_default_login_policy" "login_policy" { user_login = true allow_register = true allow_external_idp = true diff --git a/examples/provider/resources/default_login_texts.tf b/examples/provider/resources/default_login_texts.tf index e0b9ff47..483ef072 100644 --- a/examples/provider/resources/default_login_texts.tf +++ b/examples/provider/resources/default_login_texts.tf @@ -1,4 +1,4 @@ -resource zitadel_default_login_texts login_texts_en { +resource "zitadel_default_login_texts" "login_texts_en" { language = "en" email_verification_done_text = { diff --git a/examples/provider/resources/default_notification_policy.tf b/examples/provider/resources/default_notification_policy.tf index 8d86b5ea..8251f39f 100644 --- a/examples/provider/resources/default_notification_policy.tf +++ b/examples/provider/resources/default_notification_policy.tf @@ -1,3 +1,3 @@ -resource zitadel_default_notification_policy notification_policy { +resource "zitadel_default_notification_policy" "notification_policy" { password_change = false } \ No newline at end of file diff --git a/examples/provider/resources/default_oidc_settings.tf b/examples/provider/resources/default_oidc_settings.tf index d81ecb04..b4777121 100644 --- a/examples/provider/resources/default_oidc_settings.tf +++ b/examples/provider/resources/default_oidc_settings.tf @@ -1,6 +1,6 @@ -resource zitadel_default_oidc_settings oidc_settings { - access_token_lifetime = "12h0m0s" - id_token_lifetime = "12h0m0s" - refresh_token_expiration = "720h0m0s" +resource "zitadel_default_oidc_settings" "oidc_settings" { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" refresh_token_idle_expiration = "2160h0m0s" } diff --git a/examples/provider/resources/default_password_change_message_text.tf b/examples/provider/resources/default_password_change_message_text.tf index e54125a8..0b9f29ec 100644 --- a/examples/provider/resources/default_password_change_message_text.tf +++ b/examples/provider/resources/default_password_change_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_password_change_message_text password_change_en { +resource "zitadel_default_password_change_message_text" "password_change_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_password_complexity_policy.tf b/examples/provider/resources/default_password_complexity_policy.tf index ec4970b9..bc393170 100644 --- a/examples/provider/resources/default_password_complexity_policy.tf +++ b/examples/provider/resources/default_password_complexity_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_password_complexity_policy password_complexity_policy { +resource "zitadel_default_password_complexity_policy" "password_complexity_policy" { min_length = "8" has_uppercase = true has_lowercase = true diff --git a/examples/provider/resources/default_password_reset_message_text.tf b/examples/provider/resources/default_password_reset_message_text.tf index b12a8b3f..3d0e3505 100644 --- a/examples/provider/resources/default_password_reset_message_text.tf +++ b/examples/provider/resources/default_password_reset_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_password_reset_message_text password_reset_en { +resource "zitadel_default_password_reset_message_text" "password_reset_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_passwordless_registration_message_text.tf b/examples/provider/resources/default_passwordless_registration_message_text.tf index a3c0fbd9..a6045b35 100644 --- a/examples/provider/resources/default_passwordless_registration_message_text.tf +++ b/examples/provider/resources/default_passwordless_registration_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_default_passwordless_registration_message_text" "passwordless_registration_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf index b0b20d09..bec1f849 100644 --- a/examples/provider/resources/default_privacy_policy.tf +++ b/examples/provider/resources/default_privacy_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_privacy_policy privacy_policy { +resource "zitadel_default_privacy_policy" "privacy_policy" { tos_link = "https://google.com" privacy_link = "https://google.com" help_link = "https://google.com" diff --git a/examples/provider/resources/default_verify_email_message_text.tf b/examples/provider/resources/default_verify_email_message_text.tf index 693de48f..c4cb6548 100644 --- a/examples/provider/resources/default_verify_email_message_text.tf +++ b/examples/provider/resources/default_verify_email_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_verify_email_message_text verify_email_en { +resource "zitadel_default_verify_email_message_text" "verify_email_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_verify_phone_message_text.tf b/examples/provider/resources/default_verify_phone_message_text.tf index f58c46c0..535fb651 100644 --- a/examples/provider/resources/default_verify_phone_message_text.tf +++ b/examples/provider/resources/default_verify_phone_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_verify_phone_message_text verify_phone_en { +resource "zitadel_default_verify_phone_message_text" "verify_phone_en" { language = "en" title = "title example" diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 9ace3bb3..2153b258 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,5 +1,5 @@ -resource zitadel_domain domain { - org_id = zitadel_org.org.id - name = "zitadel.default.127.0.0.1.sslip.io" +resource "zitadel_domain" "domain" { + org_id = zitadel_org.org.id + name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } \ No newline at end of file diff --git a/examples/provider/resources/domain_claimed_message_text.tf b/examples/provider/resources/domain_claimed_message_text.tf index e3f2c191..70c54922 100644 --- a/examples/provider/resources/domain_claimed_message_text.tf +++ b/examples/provider/resources/domain_claimed_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_domain_claimed_message_text domain_claimed_en { +resource "zitadel_domain_claimed_message_text" "domain_claimed_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index 70c02620..d0a6802c 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_domain_policy domain_policy { +resource "zitadel_domain_policy" "domain_policy" { org_id = zitadel_org.org.id user_login_must_be_domain = false validate_org_domains = false diff --git a/examples/provider/resources/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf index 42d32965..1c191902 100644 --- a/examples/provider/resources/granted_human_user.tf +++ b/examples/provider/resources/granted_human_user.tf @@ -1,4 +1,4 @@ -resource zitadel_human_user granted_human_user { +resource "zitadel_human_user" "granted_human_user" { org_id = zitadel_org.grantedorg.id user_name = "human@localhost" first_name = "firstname" diff --git a/examples/provider/resources/granted_org.tf b/examples/provider/resources/granted_org.tf index 73f0cb78..ed35493e 100644 --- a/examples/provider/resources/granted_org.tf +++ b/examples/provider/resources/granted_org.tf @@ -1,3 +1,3 @@ -resource zitadel_org grantedorg { +resource "zitadel_org" "grantedorg" { name = "terraform-test-granted" } diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 5370b14e..afb43704 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,4 +1,4 @@ -resource zitadel_human_user human_user { +resource "zitadel_human_user" "human_user" { org_id = zitadel_org.org.id user_name = "humanfull@localhost.com" first_name = "firstname" diff --git a/examples/provider/resources/init_message_text.tf b/examples/provider/resources/init_message_text.tf index e648014a..a4d508f9 100644 --- a/examples/provider/resources/init_message_text.tf +++ b/examples/provider/resources/init_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_init_message_text init_en { +resource "zitadel_init_message_text" "init_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/instance_member.tf b/examples/provider/resources/instance_member.tf index ddac2c4f..ded0d0c5 100644 --- a/examples/provider/resources/instance_member.tf +++ b/examples/provider/resources/instance_member.tf @@ -1,4 +1,4 @@ -resource zitadel_instance_member instance_member { +resource "zitadel_instance_member" "instance_member" { user_id = zitadel_human_user.human_user.id roles = ["IAM_OWNER"] } \ No newline at end of file diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index 7aaa6d23..8c829a99 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_label_policy label_policy { +resource "zitadel_label_policy" "label_policy" { org_id = zitadel_org.org.id primary_color = "#5469d4" hide_login_name_suffix = true diff --git a/examples/provider/resources/lockout_policy.tf b/examples/provider/resources/lockout_policy.tf index 4d8a6a05..3a40af5d 100644 --- a/examples/provider/resources/lockout_policy.tf +++ b/examples/provider/resources/lockout_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_lockout_policy lockout_policy { +resource "zitadel_lockout_policy" "lockout_policy" { org_id = zitadel_org.org.id max_password_attempts = "5" } \ No newline at end of file diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index f2470880..a48469de 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_login_policy login_policy { +resource "zitadel_login_policy" "login_policy" { org_id = zitadel_org.org.id user_login = true allow_register = true diff --git a/examples/provider/resources/login_texts.tf b/examples/provider/resources/login_texts.tf index ea13f4c6..4a4560bd 100644 --- a/examples/provider/resources/login_texts.tf +++ b/examples/provider/resources/login_texts.tf @@ -1,4 +1,4 @@ -resource zitadel_login_texts login_texts_en { +resource "zitadel_login_texts" "login_texts_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 3516c458..3ec28a93 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,4 +1,4 @@ -resource zitadel_machine_key machine_key { +resource "zitadel_machine_key" "machine_key" { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id key_type = "KEY_TYPE_JSON" diff --git a/examples/provider/resources/machine_user.tf b/examples/provider/resources/machine_user.tf index ae091cf6..de10b08b 100644 --- a/examples/provider/resources/machine_user.tf +++ b/examples/provider/resources/machine_user.tf @@ -1,4 +1,4 @@ -resource zitadel_machine_user machine_user { +resource "zitadel_machine_user" "machine_user" { org_id = zitadel_org.org.id user_name = "machine@localhost.com" name = "name" diff --git a/examples/provider/resources/notification_policy.tf b/examples/provider/resources/notification_policy.tf index a10f774c..8e1e180b 100644 --- a/examples/provider/resources/notification_policy.tf +++ b/examples/provider/resources/notification_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_notification_policy notification_policy { +resource "zitadel_notification_policy" "notification_policy" { org_id = zitadel_org.org.id password_change = false } \ No newline at end of file diff --git a/examples/provider/resources/org.tf b/examples/provider/resources/org.tf index 8dbaa015..b81594ae 100644 --- a/examples/provider/resources/org.tf +++ b/examples/provider/resources/org.tf @@ -1,3 +1,3 @@ -resource zitadel_org org { +resource "zitadel_org" "org" { name = "terraform-test" } \ No newline at end of file diff --git a/examples/provider/resources/org_idp_jwt.tf b/examples/provider/resources/org_idp_jwt.tf index 6f316a25..1eaeafc4 100644 --- a/examples/provider/resources/org_idp_jwt.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -1,4 +1,4 @@ -resource zitadel_org_idp_jwt jwt_idp { +resource "zitadel_org_idp_jwt" "jwt_idp" { org_id = zitadel_org.org.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index ce1606d3..0e6d30cc 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,4 +1,4 @@ -resource zitadel_org_idp_oidc oidc_idp { +resource "zitadel_org_idp_oidc" "oidc_idp" { org_id = zitadel_org.org.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" diff --git a/examples/provider/resources/org_member.tf b/examples/provider/resources/org_member.tf index 56bb57dc..2cdad780 100644 --- a/examples/provider/resources/org_member.tf +++ b/examples/provider/resources/org_member.tf @@ -1,4 +1,4 @@ -resource zitadel_org_member org_member { +resource "zitadel_org_member" "org_member" { org_id = zitadel_org.org.id user_id = zitadel_human_user.human_user.id roles = ["ORG_OWNER"] diff --git a/examples/provider/resources/password_change_message_text.tf b/examples/provider/resources/password_change_message_text.tf index abfbb1f0..7c5eb138 100644 --- a/examples/provider/resources/password_change_message_text.tf +++ b/examples/provider/resources/password_change_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_password_change_message_text password_change_en { +resource "zitadel_password_change_message_text" "password_change_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf index 08534b5e..21ccd635 100644 --- a/examples/provider/resources/password_complexity_policy.tf +++ b/examples/provider/resources/password_complexity_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_password_complexity_policy password_complexity_policy { +resource "zitadel_password_complexity_policy" "password_complexity_policy" { org_id = zitadel_org.org.id min_length = "8" has_uppercase = true diff --git a/examples/provider/resources/password_reset_message_text.tf b/examples/provider/resources/password_reset_message_text.tf index 807e8bb5..82adbb3b 100644 --- a/examples/provider/resources/password_reset_message_text.tf +++ b/examples/provider/resources/password_reset_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_password_reset_message_text password_reset_en { +resource "zitadel_password_reset_message_text" "password_reset_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/passwordless_registration_message_text.tf b/examples/provider/resources/passwordless_registration_message_text.tf index d43a8a0a..a6a1f20b 100644 --- a/examples/provider/resources/passwordless_registration_message_text.tf +++ b/examples/provider/resources/passwordless_registration_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_passwordless_registration_message_text" "passwordless_registration_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/personal_access_token.tf b/examples/provider/resources/personal_access_token.tf index 7596eb8b..eb401ee1 100644 --- a/examples/provider/resources/personal_access_token.tf +++ b/examples/provider/resources/personal_access_token.tf @@ -1,4 +1,4 @@ -resource zitadel_personal_access_token pat { +resource "zitadel_personal_access_token" "pat" { org_id = zitadel_org.org.id user_id = zitadel_machine_user.machine_user.id expiration_date = "2519-04-01T08:45:00Z" diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index 5dc3491a..63f0171e 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_privacy_policy privacy_policy { +resource "zitadel_privacy_policy" "privacy_policy" { org_id = zitadel_org.org.id tos_link = "https://google.com" privacy_link = "https://google.com" diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 3c445ddc..f5d9da6b 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,4 +1,4 @@ -resource zitadel_project project { +resource "zitadel_project" "project" { name = "projectname" org_id = zitadel_org.org.id project_role_assertion = true diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 9c5c0178..599585d8 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,4 +1,4 @@ -resource zitadel_project_grant project_grant { +resource "zitadel_project_grant" "project_grant" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id granted_org_id = zitadel_org.grantedorg.id diff --git a/examples/provider/resources/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf index 27875252..e4a614a0 100644 --- a/examples/provider/resources/project_grant_member.tf +++ b/examples/provider/resources/project_grant_member.tf @@ -1,4 +1,4 @@ -resource zitadel_project_grant_member project_grant_member { +resource "zitadel_project_grant_member" "project_grant_member" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id grant_id = zitadel_project_grant.project_grant.id diff --git a/examples/provider/resources/project_member.tf b/examples/provider/resources/project_member.tf index d31aebca..63ebafa3 100644 --- a/examples/provider/resources/project_member.tf +++ b/examples/provider/resources/project_member.tf @@ -1,4 +1,4 @@ -resource zitadel_project_member project_member { +resource "zitadel_project_member" "project_member" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id user_id = zitadel_human_user.human_user.id diff --git a/examples/provider/resources/project_role.tf b/examples/provider/resources/project_role.tf index 1b56ff5a..8a7f390e 100644 --- a/examples/provider/resources/project_role.tf +++ b/examples/provider/resources/project_role.tf @@ -1,4 +1,4 @@ -resource zitadel_project_role project_role { +resource "zitadel_project_role" "project_role" { org_id = zitadel_org.org.id project_id = zitadel_project.project.id role_key = "key" diff --git a/examples/provider/resources/sms_provider_twilio.tf b/examples/provider/resources/sms_provider_twilio.tf index 0a4334fc..32834fdd 100644 --- a/examples/provider/resources/sms_provider_twilio.tf +++ b/examples/provider/resources/sms_provider_twilio.tf @@ -1,4 +1,4 @@ -resource zitadel_sms_provider_twilio twilio { +resource "zitadel_sms_provider_twilio" "twilio" { sid = "sid" sender_number = "019920892" token = "token" diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf index 7f81a237..7461be9b 100644 --- a/examples/provider/resources/smtp_config.tf +++ b/examples/provider/resources/smtp_config.tf @@ -1,4 +1,4 @@ -resource zitadel_smtp_config smtp { +resource "zitadel_smtp_config" "smtp" { sender_address = "address" sender_name = "no-reply" tls = true diff --git a/examples/provider/resources/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf index 4bf115de..0ca0cbfc 100644 --- a/examples/provider/resources/trigger_actions.tf +++ b/examples/provider/resources/trigger_actions.tf @@ -1,4 +1,4 @@ -resource zitadel_trigger_actions trigger_actions { +resource "zitadel_trigger_actions" "trigger_actions" { org_id = zitadel_org.org.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 77a1cb65..57eebc4f 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,4 +1,4 @@ -resource zitadel_user_grant user_grant { +resource "zitadel_user_grant" "user_grant" { project_id = zitadel_project.project.id org_id = zitadel_org.org.id role_keys = ["key"] diff --git a/examples/provider/resources/verify_email_message_text.tf b/examples/provider/resources/verify_email_message_text.tf index e0648cc6..fc5c0bd4 100644 --- a/examples/provider/resources/verify_email_message_text.tf +++ b/examples/provider/resources/verify_email_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_verify_email_message_text verify_email_en { +resource "zitadel_verify_email_message_text" "verify_email_en" { org_id = zitadel_org.org.id language = "en" diff --git a/examples/provider/resources/verify_phone_message_text.tf b/examples/provider/resources/verify_phone_message_text.tf index 4a57d174..8f4f50c6 100644 --- a/examples/provider/resources/verify_phone_message_text.tf +++ b/examples/provider/resources/verify_phone_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_verify_phone_message_text verify_phone_en { +resource "zitadel_verify_phone_message_text" "verify_phone_en" { org_id = zitadel_org.org.id language = "en" From 328debc5aa59e461a67374b354c057473a149189 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 17 Aug 2023 14:50:22 +0200 Subject: [PATCH 225/260] test examples --- examples/provider/resources/action.tf | 6 +-- examples/provider/resources/app_key.tf | 7 --- .../provider/resources/application_key.tf | 7 +++ zitadel/v2/action/resource_test.go | 1 + zitadel/v2/app_key/resource_test.go | 11 ++++ zitadel/v2/helper/test_utils/base_frame.go | 2 + zitadel/v2/helper/test_utils/import_id.go | 54 +++++++++++++++++++ zitadel/v2/helper/test_utils/lifecyletest.go | 20 ++++--- zitadel/v2/helper/test_utils/org_frame.go | 11 +++- 9 files changed, 101 insertions(+), 18 deletions(-) delete mode 100644 examples/provider/resources/app_key.tf create mode 100644 examples/provider/resources/application_key.tf create mode 100644 zitadel/v2/helper/test_utils/import_id.go diff --git a/examples/provider/resources/action.tf b/examples/provider/resources/action.tf index 8d1256b4..807228de 100644 --- a/examples/provider/resources/action.tf +++ b/examples/provider/resources/action.tf @@ -1,7 +1,7 @@ -resource zitadel_action action { - org_id = zitadel_org.org.id +resource "zitadel_action" "action" { + org_id = data.zitadel_org.org.id name = "actionname" script = "testscript" timeout = "10s" allowed_to_fail = true -} \ No newline at end of file +} diff --git a/examples/provider/resources/app_key.tf b/examples/provider/resources/app_key.tf deleted file mode 100644 index 3354852c..00000000 --- a/examples/provider/resources/app_key.tf +++ /dev/null @@ -1,7 +0,0 @@ -resource zitadel_application_key app_key { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - app_id = zitadel_application_api.application_api.id - key_type = "KEY_TYPE_JSON" - expiration_date = "2519-04-01T08:45:00Z" -} \ No newline at end of file diff --git a/examples/provider/resources/application_key.tf b/examples/provider/resources/application_key.tf new file mode 100644 index 00000000..286d9497 --- /dev/null +++ b/examples/provider/resources/application_key.tf @@ -0,0 +1,7 @@ +resource "zitadel_application_key" "app_key" { + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id + app_id = data.zitadel_application_api.application_api.id + key_type = "KEY_TYPE_JSON" + expiration_date = "2519-04-01T08:45:00Z" +} diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 2d4c76db..b852b5a7 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -22,6 +22,7 @@ func TestAccAction(t *testing.T) { test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, + frame.OrgExampleDatasource, func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index a8051a58..1a19cab3 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -34,6 +34,17 @@ func TestAccAppKey(t *testing.T) { test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, + fmt.Sprintf(`%s +data "zitadel_project" "project" { + id = "%s" + org_id = data.zitadel_org.org.id +} +data "zitadel_application_api" "application_api" { + id = "%s" + org_id = data.zitadel_org.org.id + project_id = data.zitadel_project.project.id +} +`, frame.OrgExampleDatasource, project.GetId(), app.GetAppId()), func(configProperty, _ string) string { return fmt.Sprintf(` resource "%s" "%s" { diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index b9381093..77d77799 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -23,6 +23,7 @@ type BaseTestFrame struct { context.Context ClientInfo *helper.ClientInfo ProviderSnippet, UniqueResourcesID string + ResourceType string TerraformName string v6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error) v5ProviderFactories map[string]func() (tfprotov5.ProviderServer, error) @@ -58,6 +59,7 @@ KEY ClientInfo: clientInfo, UniqueResourcesID: uniqueID, TerraformName: terraformName, + ResourceType: resourceType, } _, v5 := zitadelProvider.ResourcesMap[resourceType] if v5 { diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/v2/helper/test_utils/import_id.go new file mode 100644 index 00000000..348c35d8 --- /dev/null +++ b/zitadel/v2/helper/test_utils/import_id.go @@ -0,0 +1,54 @@ +package test_utils + +import ( + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +var _ resource.ImportStateIdFunc = ImportNothing + +func ImportResourceId(frame BaseTestFrame) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + return frame.State(state).ID, nil + } +} + +func ImportOrgId(frame *OrgTestFrame) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + return frame.OrgID, nil + } +} + +func ImportStateAttribute(frame BaseTestFrame, attr string) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + primary := frame.State(state) + val, ok := primary.Attributes[attr] + if !ok { + return "", fmt.Errorf("attribute %s not found in attributes %+v", attr, primary.Attributes) + } + return quoteString(val), nil + } +} + +func ImportNothing(_ *terraform.State) (string, error) { return "", nil } + +func ConcatImportStateIdFuncs(funcs ...resource.ImportStateIdFunc) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + parts := make([]string, len(funcs)) + for i, f := range funcs { + part, err := f(state) + if err != nil { + return "", err + } + parts[i] = part + } + return strings.Join(parts, ":"), nil + } +} + +func quoteString(s string) string { + return fmt.Sprintf(`"%s"`, s) +} diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index b0f19fe2..32196c8e 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -2,6 +2,8 @@ package test_utils import ( "fmt" + "os" + "path" "regexp" "strings" "testing" @@ -12,6 +14,7 @@ import ( func RunLifecyleTest[P comparable]( t *testing.T, frame BaseTestFrame, + addedExampleConfig string, resourceFunc func(initialProperty P, initialSecret string) string, initialProperty, updatedProperty P, initialSecret, updatedSecret string, @@ -24,28 +27,33 @@ func RunLifecyleTest[P comparable]( secretAttribute string, ) { var importStateVerifyIgnore []string - initialConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(initialProperty, initialSecret)) - updatedNameConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) + updatedPropertyConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) + examplePath := path.Join("..", "..", "..", "examples", "provider", "resources", strings.Replace(frame.ResourceType, "zitadel_", "", 1)+".tf") + rawExampleConfig, err := os.ReadFile(examplePath) + if err != nil { + t.Fatalf("error reading example file: %v", err) + } + exampleConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, addedExampleConfig, string(rawExampleConfig)) steps := []resource.TestStep{ { // Check first plan has a diff - Config: initialConfig, + Config: exampleConfig, ExpectNonEmptyPlan: true, // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, }, { // Check resource is created - Config: initialConfig, + Config: exampleConfig, Check: resource.ComposeAggregateTestCheckFunc( CheckAMinute(checkRemoteProperty(initialProperty)), CheckStateHasIDSet(frame, idPattern), ), }, { // Check updating name has a diff - Config: updatedNameConfig, + Config: updatedPropertyConfig, ExpectNonEmptyPlan: true, // ExpectNonEmptyPlan just works with PlanOnly set to true PlanOnly: true, }, { // Check remote state can be updated - Config: updatedNameConfig, + Config: updatedPropertyConfig, Check: CheckAMinute(checkRemoteProperty(updatedProperty)), }, } diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index 7a8bafb2..0a33b249 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -2,6 +2,7 @@ package test_utils import ( "context" + "fmt" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" @@ -14,8 +15,9 @@ import ( type OrgTestFrame struct { BaseTestFrame *mgmt.Client - Admin *admin.Client - OrgID string + Admin *admin.Client + OrgID string + OrgExampleDatasource string } func (o *OrgTestFrame) useOrgContext(orgID string) (err error) { @@ -43,6 +45,11 @@ func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { } org, err := orgFrame.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: "zitadel." + cfg.Domain}) orgFrame.OrgID = org.GetOrg().GetId() + orgFrame.OrgExampleDatasource = fmt.Sprintf(` +data "zitadel_org" "org" { + id = "%s" +} +`, orgFrame.OrgID) return orgFrame, err } From 993cc2cfd3a96b0f5b8e64c9fc455d0656ec3c93 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 17 Aug 2023 16:17:13 +0200 Subject: [PATCH 226/260] fix tests --- zitadel/v2/default_privacy_policy/resource_test.go | 1 + zitadel/v2/privacy_policy/resource_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index 2c1bdb4b..ec0d3271 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -27,6 +27,7 @@ func TestAccDefaultPrivacyPolicy(t *testing.T) { resource "%s" "%s" { tos_link = "https://google.com" privacy_link = "https://google.com" + support_email = "support@email.com" help_link = "%s" }`, resourceName, frame.UniqueResourcesID, configProperty) }, diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index 97ec471c..557a523f 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -28,6 +28,7 @@ resource "%s" "%s" { org_id = "%s" tos_link = "https://google.com" privacy_link = "https://google.com" + support_email = "support@email.com" help_link = "%s" }`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) }, From cf7189968adacaa9ee780f1bc6f878585bedfa57 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 10:51:08 +0200 Subject: [PATCH 227/260] standardize state identifiers --- docs/data-sources/action.md | 10 ++-- docs/data-sources/application_api.md | 12 ++--- docs/data-sources/application_oidc.md | 12 ++--- docs/data-sources/default_oidc_settings.md | 6 +-- docs/data-sources/human_user.md | 10 ++-- docs/data-sources/idp_azure_ad.md | 4 +- docs/data-sources/idp_github.md | 4 +- docs/data-sources/idp_github_es.md | 4 +- docs/data-sources/idp_gitlab.md | 4 +- docs/data-sources/idp_gitlab_self_hosted.md | 4 +- docs/data-sources/idp_google.md | 4 +- docs/data-sources/idp_ldap.md | 4 +- docs/data-sources/machine_user.md | 10 ++-- docs/data-sources/org.md | 8 +-- docs/data-sources/org_idp_azure_ad.md | 4 +- docs/data-sources/org_idp_github.md | 4 +- docs/data-sources/org_idp_github_es.md | 4 +- docs/data-sources/org_idp_gitlab.md | 4 +- .../org_idp_gitlab_self_hosted.md | 4 +- docs/data-sources/org_idp_google.md | 4 +- docs/data-sources/org_idp_ldap.md | 4 +- docs/data-sources/org_jwt_idp.md | 10 ++-- docs/data-sources/org_oidc_idp.md | 10 ++-- docs/data-sources/project.md | 10 ++-- docs/data-sources/project_role.md | 10 ++-- docs/data-sources/trigger_actions.md | 8 +-- docs/resources/action.md | 4 +- docs/resources/application_api.md | 6 +-- docs/resources/application_key.md | 10 ++-- docs/resources/application_oidc.md | 6 +-- .../default_domain_claimed_message_text.md | 2 +- docs/resources/default_domain_policy.md | 2 +- docs/resources/default_init_message_text.md | 2 +- docs/resources/default_label_policy.md | 2 +- docs/resources/default_lockout_policy.md | 2 +- docs/resources/default_login_policy.md | 2 +- docs/resources/default_login_texts.md | 2 +- docs/resources/default_notification_policy.md | 2 +- docs/resources/default_oidc_settings.md | 8 +-- .../default_password_change_message_text.md | 2 +- .../default_password_complexity_policy.md | 2 +- .../default_password_reset_message_text.md | 2 +- ..._passwordless_registration_message_text.md | 2 +- docs/resources/default_privacy_policy.md | 9 ++-- .../default_verify_email_message_text.md | 2 +- .../default_verify_phone_message_text.md | 2 +- docs/resources/domain.md | 6 +-- docs/resources/domain_claimed_message_text.md | 4 +- docs/resources/domain_policy.md | 4 +- docs/resources/human_user.md | 4 +- docs/resources/idp_azure_ad.md | 2 +- docs/resources/idp_github.md | 2 +- docs/resources/idp_github_es.md | 2 +- docs/resources/idp_gitlab.md | 2 +- docs/resources/idp_gitlab_self_hosted.md | 2 +- docs/resources/idp_google.md | 2 +- docs/resources/idp_ldap.md | 2 +- docs/resources/init_message_text.md | 4 +- docs/resources/instance_member.md | 4 +- docs/resources/label_policy.md | 4 +- docs/resources/lockout_policy.md | 4 +- docs/resources/login_policy.md | 6 +-- docs/resources/login_texts.md | 4 +- docs/resources/machine_key.md | 6 +-- docs/resources/machine_user.md | 4 +- docs/resources/notification_policy.md | 4 +- docs/resources/org.md | 2 +- docs/resources/org_idp_azure_ad.md | 4 +- docs/resources/org_idp_github.md | 4 +- docs/resources/org_idp_github_es.md | 4 +- docs/resources/org_idp_gitlab.md | 4 +- docs/resources/org_idp_gitlab_self_hosted.md | 4 +- docs/resources/org_idp_google.md | 4 +- docs/resources/org_idp_jwt.md | 4 +- docs/resources/org_idp_ldap.md | 4 +- docs/resources/org_idp_oidc.md | 4 +- docs/resources/org_member.md | 6 +-- .../resources/password_change_message_text.md | 4 +- docs/resources/password_complexity_policy.md | 4 +- docs/resources/password_reset_message_text.md | 4 +- .../passwordless_registration_message_text.md | 4 +- docs/resources/personal_access_token.md | 6 +-- docs/resources/privacy_policy.md | 11 ++-- docs/resources/project.md | 4 +- docs/resources/project_grant.md | 10 ++-- docs/resources/project_grant_member.md | 10 ++-- docs/resources/project_member.md | 8 +-- docs/resources/project_role.md | 6 +-- docs/resources/sms_provider_twilio.md | 2 +- docs/resources/smtp_config.md | 2 +- docs/resources/trigger_actions.md | 6 +-- docs/resources/user_grant.md | 8 +-- docs/resources/verify_email_message_text.md | 4 +- docs/resources/verify_phone_message_text.md | 4 +- examples/provider/data-sources/action.tf | 12 ++--- .../provider/data-sources/application_api.tf | 14 +++--- .../provider/data-sources/application_oidc.tf | 14 +++--- .../data-sources/default_oidc_settings.tf | 6 +-- examples/provider/data-sources/human_user.tf | 12 ++--- .../provider/data-sources/idp_azure_ad.tf | 4 +- examples/provider/data-sources/idp_github.tf | 4 +- .../provider/data-sources/idp_github_es.tf | 4 +- examples/provider/data-sources/idp_gitlab.tf | 4 +- .../data-sources/idp_gitlab_self_hosted.tf | 4 +- examples/provider/data-sources/idp_google.tf | 4 +- examples/provider/data-sources/idp_ldap.tf | 4 +- .../provider/data-sources/machine_user.tf | 12 ++--- examples/provider/data-sources/org.tf | 8 +-- .../provider/data-sources/org_idp_azure_ad.tf | 4 +- .../provider/data-sources/org_idp_github.tf | 4 +- .../data-sources/org_idp_github_es.tf | 4 +- .../provider/data-sources/org_idp_gitlab.tf | 4 +- .../org_idp_gitlab_self_hosted.tf | 4 +- .../provider/data-sources/org_idp_google.tf | 4 +- .../provider/data-sources/org_idp_ldap.tf | 4 +- examples/provider/data-sources/org_jwt_idp.tf | 12 ++--- .../provider/data-sources/org_oidc_idp.tf | 12 ++--- examples/provider/data-sources/project.tf | 12 ++--- .../provider/data-sources/project_role.tf | 12 ++--- .../provider/data-sources/trigger_actions.tf | 10 ++-- examples/provider/resources/action.tf | 4 +- .../provider/resources/application_api.tf | 6 +-- .../provider/resources/application_key.tf | 8 +-- .../provider/resources/application_oidc.tf | 6 +-- .../default_domain_claimed_message_text.tf | 4 +- .../resources/default_domain_policy.tf | 4 +- .../resources/default_init_message_text.tf | 4 +- .../resources/default_label_policy.tf | 4 +- .../resources/default_lockout_policy.tf | 4 +- .../resources/default_login_policy.tf | 2 +- .../provider/resources/default_login_texts.tf | 2 +- .../resources/default_notification_policy.tf | 4 +- .../resources/default_oidc_settings.tf | 8 +-- .../default_password_change_message_text.tf | 2 +- .../default_password_complexity_policy.tf | 4 +- .../default_password_reset_message_text.tf | 4 +- ..._passwordless_registration_message_text.tf | 4 +- .../resources/default_privacy_policy.tf | 2 +- .../default_verify_email_message_text.tf | 4 +- .../default_verify_phone_message_text.tf | 4 +- examples/provider/resources/domain.tf | 8 +-- .../resources/domain_claimed_message_text.tf | 6 +-- examples/provider/resources/domain_policy.tf | 6 +-- .../provider/resources/granted_human_user.tf | 4 +- examples/provider/resources/granted_org.tf | 3 -- examples/provider/resources/human_user.tf | 4 +- examples/provider/resources/idp_azure_ad.tf | 2 +- examples/provider/resources/idp_github.tf | 2 +- examples/provider/resources/idp_github_es.tf | 2 +- examples/provider/resources/idp_gitlab.tf | 2 +- .../resources/idp_gitlab_self_hosted.tf | 2 +- examples/provider/resources/idp_google.tf | 2 +- examples/provider/resources/idp_ldap.tf | 2 +- .../provider/resources/init_message_text.tf | 6 +-- .../provider/resources/instance_member.tf | 6 +-- examples/provider/resources/label_policy.tf | 6 +-- examples/provider/resources/lockout_policy.tf | 6 +-- examples/provider/resources/login_policy.tf | 6 +-- examples/provider/resources/login_texts.tf | 6 +-- examples/provider/resources/machine_key.tf | 6 +-- examples/provider/resources/machine_user.tf | 6 +-- .../provider/resources/notification_policy.tf | 6 +-- examples/provider/resources/org.tf | 4 +- .../provider/resources/org_idp_azure_ad.tf | 4 +- examples/provider/resources/org_idp_github.tf | 4 +- .../provider/resources/org_idp_github_es.tf | 4 +- examples/provider/resources/org_idp_gitlab.tf | 4 +- .../resources/org_idp_gitlab_self_hosted.tf | 4 +- examples/provider/resources/org_idp_google.tf | 4 +- examples/provider/resources/org_idp_jwt.tf | 6 +-- examples/provider/resources/org_idp_ldap.tf | 4 +- examples/provider/resources/org_idp_oidc.tf | 6 +-- examples/provider/resources/org_member.tf | 8 +-- .../resources/password_change_message_text.tf | 4 +- .../resources/password_complexity_policy.tf | 6 +-- .../resources/password_reset_message_text.tf | 6 +-- .../passwordless_registration_message_text.tf | 6 +-- .../resources/personal_access_token.tf | 8 +-- examples/provider/resources/privacy_policy.tf | 4 +- examples/provider/resources/project.tf | 4 +- examples/provider/resources/project_grant.tf | 10 ++-- .../resources/project_grant_member.tf | 12 ++--- examples/provider/resources/project_member.tf | 10 ++-- examples/provider/resources/project_role.tf | 8 +-- .../provider/resources/sms_provider_twilio.tf | 4 +- examples/provider/resources/smtp_config.tf | 2 +- .../provider/resources/trigger_actions.tf | 8 +-- examples/provider/resources/user_grant.tf | 8 +-- .../resources/verify_email_message_text.tf | 6 +-- .../resources/verify_phone_message_text.tf | 6 +-- templates/resources/application_key.md.tmpl | 4 +- zitadel/v2/action/resource_test.go | 20 +++----- zitadel/v2/app_key/resource_test.go | 40 ++++++--------- zitadel/v2/application_api/resource_test.go | 5 +- zitadel/v2/helper/test_utils/base_frame.go | 50 ++++++++++++++++++- zitadel/v2/helper/test_utils/lifecyletest.go | 20 +++----- zitadel/v2/helper/test_utils/org_frame.go | 4 +- 197 files changed, 581 insertions(+), 557 deletions(-) delete mode 100644 examples/provider/resources/granted_org.tf diff --git a/docs/data-sources/action.md b/docs/data-sources/action.md index de656e4b..c88c6521 100644 --- a/docs/data-sources/action.md +++ b/docs/data-sources/action.md @@ -12,13 +12,13 @@ Datasource representing an action belonging to an organization. ## Example Usage ```terraform -data zitadel_action action { - org_id = data.zitadel_org.org.id - action_id = "177073621691269123" +data "zitadel_action" "default" { + org_id = data.zitadel_org.default.id + action_id = "123456789012345678" } -output action { - value = data.zitadel_action.action +output "action" { + value = data.zitadel_action.default } ``` diff --git a/docs/data-sources/application_api.md b/docs/data-sources/application_api.md index 492948be..be1bdcfd 100644 --- a/docs/data-sources/application_api.md +++ b/docs/data-sources/application_api.md @@ -12,14 +12,14 @@ Datasource representing an API application belonging to a project, with all conf ## Example Usage ```terraform -data zitadel_application_api api_application { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - app_id = "177073625566806019" +data "zitadel_application_api" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = "123456789012345678" } -output api_application { - value = data.zitadel_application_api.api_application +output "application_api" { + value = data.zitadel_application_api.default } ``` diff --git a/docs/data-sources/application_oidc.md b/docs/data-sources/application_oidc.md index cd0ccc1f..5eb401cc 100644 --- a/docs/data-sources/application_oidc.md +++ b/docs/data-sources/application_oidc.md @@ -12,14 +12,14 @@ Datasource representing an OIDC application belonging to a project, with all con ## Example Usage ```terraform -data zitadel_application_oidc oidc_application { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - app_id = "177073626925760515" +data "zitadel_application_oidc" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = "123456789012345678" } -output oidc_application { - value = data.zitadel_application_oidc.oidc_application +output "application_oidc" { + value = data.zitadel_application_oidc.default } ``` diff --git a/docs/data-sources/default_oidc_settings.md b/docs/data-sources/default_oidc_settings.md index 85366afa..0189bf60 100644 --- a/docs/data-sources/default_oidc_settings.md +++ b/docs/data-sources/default_oidc_settings.md @@ -12,10 +12,10 @@ Datasource representing the default oidc settings. ## Example Usage ```terraform -data zitadel_default_oidc_settings oidc_settings {} +data "zitadel_default_oidc_settings" "default" {} -output oidc_settings { - value = data.zitadel_default_oidc_settings.oidc_settings +output "oidc_settings" { + value = data.zitadel_default_oidc_settings.default } ``` diff --git a/docs/data-sources/human_user.md b/docs/data-sources/human_user.md index 1a10a0cc..386f0864 100644 --- a/docs/data-sources/human_user.md +++ b/docs/data-sources/human_user.md @@ -12,13 +12,13 @@ Datasource representing a human user situated under an organization, which then ## Example Usage ```terraform -data zitadel_human_user human_user { - org_id = data.zitadel_org.org.id - user_id = "177073614158299139" +data "zitadel_human_user" "default" { + org_id = data.zitadel_org.default.id + user_id = "123456789012345678" } -output human_user { - value = data.zitadel_human_user.human_user +output "human_user" { + value = data.zitadel_human_user.default } ``` diff --git a/docs/data-sources/idp_azure_ad.md b/docs/data-sources/idp_azure_ad.md index 3bc8aab0..946193a4 100644 --- a/docs/data-sources/idp_azure_ad.md +++ b/docs/data-sources/idp_azure_ad.md @@ -12,8 +12,8 @@ Datasource representing an Azure AD IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_azure_ad" "azure_ad" { - id = "177073614158299139" +data "zitadel_idp_azure_ad" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_github.md b/docs/data-sources/idp_github.md index f41459d0..86878522 100644 --- a/docs/data-sources/idp_github.md +++ b/docs/data-sources/idp_github.md @@ -12,8 +12,8 @@ Datasource representing a GitHub IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_github" "github" { - id = "177073614158299139" +data "zitadel_idp_github" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_github_es.md b/docs/data-sources/idp_github_es.md index 9eeea1ce..28ff7f4f 100644 --- a/docs/data-sources/idp_github_es.md +++ b/docs/data-sources/idp_github_es.md @@ -12,8 +12,8 @@ Datasource representing a GitHub Enterprise IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_github_es" "github_es" { - id = "177073614158299139" +data "zitadel_idp_github_es" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_gitlab.md b/docs/data-sources/idp_gitlab.md index eab89775..96551c15 100644 --- a/docs/data-sources/idp_gitlab.md +++ b/docs/data-sources/idp_gitlab.md @@ -12,8 +12,8 @@ Datasource representing a GitLab IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_gitlab" "gitlab" { - id = "177073614158299139" +data "zitadel_idp_gitlab" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_gitlab_self_hosted.md b/docs/data-sources/idp_gitlab_self_hosted.md index 7c981b6d..a1e0c28b 100644 --- a/docs/data-sources/idp_gitlab_self_hosted.md +++ b/docs/data-sources/idp_gitlab_self_hosted.md @@ -12,8 +12,8 @@ Datasource representing a GitLab Self Hosted IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { - id = "177073614158299139" +data "zitadel_idp_gitlab_self_hosted" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_google.md b/docs/data-sources/idp_google.md index ddc9e0f5..b0cf5937 100644 --- a/docs/data-sources/idp_google.md +++ b/docs/data-sources/idp_google.md @@ -12,8 +12,8 @@ Datasource representing a Google IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_google" "google" { - id = "177073614158299139" +data "zitadel_idp_google" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/idp_ldap.md b/docs/data-sources/idp_ldap.md index b69a2ea1..6b3662a7 100644 --- a/docs/data-sources/idp_ldap.md +++ b/docs/data-sources/idp_ldap.md @@ -12,8 +12,8 @@ Datasource representing an LDAP IDP on the instance. ## Example Usage ```terraform -data "zitadel_idp_ldap" "ldap" { - id = "177073614158299139" +data "zitadel_idp_ldap" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md index da5576ef..aee787a8 100644 --- a/docs/data-sources/machine_user.md +++ b/docs/data-sources/machine_user.md @@ -12,13 +12,13 @@ Datasource representing a serviceaccount situated under an organization, which t ## Example Usage ```terraform -data zitadel_machine_user machine_user { - org_id = data.zitadel_org.org.id - user_id = "177073617463410691" +data "zitadel_machine_user" "default" { + org_id = data.zitadel_org.default.id + user_id = "123456789012345678" } -output machine_user { - value = data.zitadel_machine_user.machine_user +output "machine_user" { + value = data.zitadel_machine_user.default } ``` diff --git a/docs/data-sources/org.md b/docs/data-sources/org.md index 1e761573..f0860dca 100644 --- a/docs/data-sources/org.md +++ b/docs/data-sources/org.md @@ -12,12 +12,12 @@ Datasource representing an organization in ZITADEL, which is the highest level a ## Example Usage ```terraform -data zitadel_org org { - org_id = "177073608051458051" +data "zitadel_org" "default" { + org_id = "123456789012345678" } -output org { - value = data.zitadel_org.org +output "org" { + value = data.zitadel_org.default } ``` diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md index 2497903f..86b5154b 100644 --- a/docs/data-sources/org_idp_azure_ad.md +++ b/docs/data-sources/org_idp_azure_ad.md @@ -12,8 +12,8 @@ Datasource representing an Azure AD IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_azure_ad" "azure_ad" { - id = "177073614158299139" +data "zitadel_org_idp_azure_ad" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md index ca13ea79..3ddec252 100644 --- a/docs/data-sources/org_idp_github.md +++ b/docs/data-sources/org_idp_github.md @@ -12,8 +12,8 @@ Datasource representing a GitHub IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_github" "github" { - id = "177073614158299139" +data "zitadel_org_idp_github" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md index 64fb14fd..f4df9e40 100644 --- a/docs/data-sources/org_idp_github_es.md +++ b/docs/data-sources/org_idp_github_es.md @@ -12,8 +12,8 @@ Datasource representing a GitHub Enterprise IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_github_es" "github_es" { - id = "177073614158299139" +data "zitadel_org_idp_github_es" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md index 65e6dfa1..124cb8d5 100644 --- a/docs/data-sources/org_idp_gitlab.md +++ b/docs/data-sources/org_idp_gitlab.md @@ -12,8 +12,8 @@ Datasource representing a GitLab IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_gitlab" "gitlab" { - id = "177073614158299139" +data "zitadel_org_idp_gitlab" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md index 4b391b4d..bb12f2d3 100644 --- a/docs/data-sources/org_idp_gitlab_self_hosted.md +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -12,8 +12,8 @@ Datasource representing a GitLab Self Hosted IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - id = "177073614158299139" +data "zitadel_org_idp_gitlab_self_hosted" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md index 553f3f5f..a71b514a 100644 --- a/docs/data-sources/org_idp_google.md +++ b/docs/data-sources/org_idp_google.md @@ -12,8 +12,8 @@ Datasource representing a Google IdP of the organization. ## Example Usage ```terraform -data "zitadel_org_idp_google" "google" { - id = "177073614158299139" +data "zitadel_org_idp_google" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md index 7e3f28b9..50bd0618 100644 --- a/docs/data-sources/org_idp_ldap.md +++ b/docs/data-sources/org_idp_ldap.md @@ -12,8 +12,8 @@ Datasource representing an LDAP IdP on the organization. ## Example Usage ```terraform -data "zitadel_org_idp_ldap" "ldap" { - id = "177073614158299139" +data "zitadel_org_idp_ldap" "default" { + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md index 8137ebd5..bdfc9095 100644 --- a/docs/data-sources/org_jwt_idp.md +++ b/docs/data-sources/org_jwt_idp.md @@ -12,13 +12,13 @@ Datasource representing a generic JWT IdP on the organization. ## Example Usage ```terraform -data zitadel_org_jwt_idp org_jwt_idp { - org_id = data.zitadel_org.org.id - idp_id = "177073612581240835" +data "zitadel_org_jwt_idp" "default" { + org_id = data.zitadel_org.default.id + idp_id = "123456789012345678" } -output org_jwt_idp { - value = data.zitadel_org_jwt_idp.org_jwt_idp +output "org_idp_org_jwt_idp" { + value = data.zitadel_org_jwt_idp.default } ``` diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md index 4dfef712..5ca8a80e 100644 --- a/docs/data-sources/org_oidc_idp.md +++ b/docs/data-sources/org_oidc_idp.md @@ -12,13 +12,13 @@ Datasource representing a generic OIDC IdP on the organization. ## Example Usage ```terraform -data zitadel_org_oidc_idp org_oidc_idp { - org_id = data.zitadel_org.org.id - idp_id = "177073612581240835" +data "zitadel_org_oidc_idp" "default" { + org_id = data.zitadel_org.default.id + idp_id = "123456789012345678" } -output org_oidc_idp { - value = data.zitadel_org_oidc_idp.org_oidc_idp +output "org_oidc_idp" { + value = data.zitadel_org_oidc_idp.default } ``` diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 741f04b4..8eb10aff 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -12,13 +12,13 @@ Datasource representing the project, which can then be granted to different orga ## Example Usage ```terraform -data zitadel_project project { - org_id = data.zitadel_org.org.id - project_id = "177073620768522243" +data "zitadel_project" "default" { + org_id = data.zitadel_org.default.id + project_id = "123456789012345678" } -output project { - value = data.zitadel_project.project +output "project" { + value = data.zitadel_project.default } ``` diff --git a/docs/data-sources/project_role.md b/docs/data-sources/project_role.md index ccdd19e8..26a8e012 100644 --- a/docs/data-sources/project_role.md +++ b/docs/data-sources/project_role.md @@ -12,14 +12,14 @@ Datasource representing the project roles, which can be given as authorizations ## Example Usage ```terraform -data zitadel_project_role project_role { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id +data "zitadel_project_role" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id role_key = "key" } -output project_role { - value = data.zitadel_project_role.project_role +output "project_role" { + value = data.zitadel_project_role.default } ``` diff --git a/docs/data-sources/trigger_actions.md b/docs/data-sources/trigger_actions.md index 7c56c276..4bd5f57a 100644 --- a/docs/data-sources/trigger_actions.md +++ b/docs/data-sources/trigger_actions.md @@ -12,14 +12,14 @@ Resource representing triggers, when actions get started ## Example Usage ```terraform -data zitadel_trigger_actions trigger_actions { - org_id = data.zitadel_org.org.id +data "zitadel_trigger_actions" "default" { + org_id = data.zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" } -output trigger_actions { - value = data.zitadel_trigger_actions.trigger_actions +output "trigger_actions" { + value = data.zitadel_trigger_actions.default } ``` diff --git a/docs/resources/action.md b/docs/resources/action.md index 3252e976..06430ffa 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -12,8 +12,8 @@ Resource representing an action belonging to an organization. ## Example Usage ```terraform -resource zitadel_action action { - org_id = zitadel_org.org.id +resource "zitadel_action" "default" { + org_id = data.zitadel_org.default.id name = "actionname" script = "testscript" timeout = "10s" diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index b94cbfcf..4e78b623 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -12,9 +12,9 @@ Resource representing an API application belonging to a project, with all config ## Example Usage ```terraform -resource zitadel_application_api application_api { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id +resource "zitadel_application_api" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id name = "applicationapi" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 28189e7a..a876d150 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -12,10 +12,10 @@ Resource representing a app key ## Example Usage ```terraform -resource zitadel_application_key app_key { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - app_id = zitadel_application_api.application_api.id +resource "zitadel_application_key" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = data.zitadel_application_api.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } @@ -35,4 +35,4 @@ resource zitadel_application_key app_key { ### Read-Only - `id` (String) The ID of this resource. -- `key_details` (String, Sensitive) Value of the app key \ No newline at end of file +- `key_details` (String, Sensitive) Value of the app key diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 8a0202fa..d5977e16 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -12,9 +12,9 @@ Resource representing an OIDC application belonging to a project, with all confi ## Example Usage ```terraform -resource zitadel_application_oidc application_oidc { - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id +resource "zitadel_application_oidc" "default" { + project_id = zitadel_project.default.id + org_id = zitadel_org.default.id name = "applicationoidc" redirect_uris = ["https://localhost.com"] diff --git a/docs/resources/default_domain_claimed_message_text.md b/docs/resources/default_domain_claimed_message_text.md index 863b2996..c66437ca 100644 --- a/docs/resources/default_domain_claimed_message_text.md +++ b/docs/resources/default_domain_claimed_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_domain_claimed_message_text domain_claimed_en { +resource "zitadel_default_domain_claimed_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md index 80da8ed6..a9e94e3b 100644 --- a/docs/resources/default_domain_policy.md +++ b/docs/resources/default_domain_policy.md @@ -12,7 +12,7 @@ Resource representing the default domain policy. ## Example Usage ```terraform -resource zitadel_default_domain_policy domain_policy { +resource "zitadel_default_domain_policy" "default" { user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/docs/resources/default_init_message_text.md b/docs/resources/default_init_message_text.md index 54be0f80..679f16ee 100644 --- a/docs/resources/default_init_message_text.md +++ b/docs/resources/default_init_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_init_message_text init_en { +resource "zitadel_default_init_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index b4d737b4..6c7558d1 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -12,7 +12,7 @@ Resource representing the default label policy. ## Example Usage ```terraform -resource zitadel_default_label_policy label_policy { +resource "zitadel_default_label_policy" "default" { primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md index cea2f992..6b8098d6 100644 --- a/docs/resources/default_lockout_policy.md +++ b/docs/resources/default_lockout_policy.md @@ -12,7 +12,7 @@ Resource representing the default lockout policy. ## Example Usage ```terraform -resource zitadel_default_lockout_policy lockout_policy { +resource "zitadel_default_lockout_policy" "default" { max_password_attempts = "5" } ``` diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index ec7aaac5..14fbbd77 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -12,7 +12,7 @@ Resource representing the default login policy. ## Example Usage ```terraform -resource zitadel_default_login_policy login_policy { +resource "zitadel_default_login_policy" "default" { user_login = true allow_register = true allow_external_idp = true diff --git a/docs/resources/default_login_texts.md b/docs/resources/default_login_texts.md index 8fc0784f..d1f9bd7c 100644 --- a/docs/resources/default_login_texts.md +++ b/docs/resources/default_login_texts.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_login_texts login_texts_en { +resource "zitadel_default_login_texts" "default" { language = "en" email_verification_done_text = { diff --git a/docs/resources/default_notification_policy.md b/docs/resources/default_notification_policy.md index a3ff90f0..382efbea 100644 --- a/docs/resources/default_notification_policy.md +++ b/docs/resources/default_notification_policy.md @@ -12,7 +12,7 @@ Resource representing the default notification policy. ## Example Usage ```terraform -resource zitadel_default_notification_policy notification_policy { +resource "zitadel_default_notification_policy" "default" { password_change = false } ``` diff --git a/docs/resources/default_oidc_settings.md b/docs/resources/default_oidc_settings.md index 0251eb3a..e89e27fa 100644 --- a/docs/resources/default_oidc_settings.md +++ b/docs/resources/default_oidc_settings.md @@ -12,10 +12,10 @@ Resource representing the default oidc settings. ## Example Usage ```terraform -resource zitadel_default_oidc_settings oidc_settings { - access_token_lifetime = "12h0m0s" - id_token_lifetime = "12h0m0s" - refresh_token_expiration = "720h0m0s" +resource "zitadel_default_oidc_settings" "default" { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" refresh_token_idle_expiration = "2160h0m0s" } ``` diff --git a/docs/resources/default_password_change_message_text.md b/docs/resources/default_password_change_message_text.md index 50309af5..f3b6270b 100644 --- a/docs/resources/default_password_change_message_text.md +++ b/docs/resources/default_password_change_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_password_change_message_text password_change_en { +resource "zitadel_default_password_change_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_password_complexity_policy.md b/docs/resources/default_password_complexity_policy.md index 4d87410b..e2a03337 100644 --- a/docs/resources/default_password_complexity_policy.md +++ b/docs/resources/default_password_complexity_policy.md @@ -12,7 +12,7 @@ Resource representing the default password complexity policy. ## Example Usage ```terraform -resource zitadel_default_password_complexity_policy password_complexity_policy { +resource "zitadel_default_password_complexity_policy" "default" { min_length = "8" has_uppercase = true has_lowercase = true diff --git a/docs/resources/default_password_reset_message_text.md b/docs/resources/default_password_reset_message_text.md index 82ef6aad..f05746b8 100644 --- a/docs/resources/default_password_reset_message_text.md +++ b/docs/resources/default_password_reset_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_password_reset_message_text password_reset_en { +resource "zitadel_default_password_reset_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_passwordless_registration_message_text.md b/docs/resources/default_passwordless_registration_message_text.md index 5f6a119b..e440b550 100644 --- a/docs/resources/default_passwordless_registration_message_text.md +++ b/docs/resources/default_passwordless_registration_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_default_passwordless_registration_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index 9684a246..67f130e9 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -12,10 +12,11 @@ Resource representing the default privacy policy. ## Example Usage ```terraform -resource zitadel_default_privacy_policy privacy_policy { - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" +resource "zitadel_default_privacy_policy" "default" { + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" } ``` diff --git a/docs/resources/default_verify_email_message_text.md b/docs/resources/default_verify_email_message_text.md index 58a05475..bcb80321 100644 --- a/docs/resources/default_verify_email_message_text.md +++ b/docs/resources/default_verify_email_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_verify_email_message_text verify_email_en { +resource "zitadel_default_verify_email_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/default_verify_phone_message_text.md b/docs/resources/default_verify_phone_message_text.md index 1e19d653..b164d566 100644 --- a/docs/resources/default_verify_phone_message_text.md +++ b/docs/resources/default_verify_phone_message_text.md @@ -12,7 +12,7 @@ description: |- ## Example Usage ```terraform -resource zitadel_default_verify_phone_message_text verify_phone_en { +resource "zitadel_default_verify_phone_message_text" "default" { language = "en" title = "title example" diff --git a/docs/resources/domain.md b/docs/resources/domain.md index f4a971f3..8e112478 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -12,9 +12,9 @@ Resource representing a domain of the organization. ## Example Usage ```terraform -resource zitadel_domain domain { - org_id = zitadel_org.org.id - name = "zitadel.default.127.0.0.1.sslip.io" +resource "zitadel_domain" "default" { + org_id = zitadel_org.default.id + name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } ``` diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md index 0f5dbe02..d1258908 100644 --- a/docs/resources/domain_claimed_message_text.md +++ b/docs/resources/domain_claimed_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_domain_claimed_message_text domain_claimed_en { - org_id = zitadel_org.org.id +resource "zitadel_domain_claimed_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 2a4ae722..0293ea99 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -12,8 +12,8 @@ Resource representing the custom domain policy of an organization. ## Example Usage ```terraform -resource zitadel_domain_policy domain_policy { - org_id = zitadel_org.org.id +resource "zitadel_domain_policy" "default" { + org_id = zitadel_org.default.id user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index fe47c469..28e43f09 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -14,8 +14,8 @@ Resource representing a human user situated under an organization, which then ca ## Example Usage ```terraform -resource zitadel_human_user human_user { - org_id = zitadel_org.org.id +resource "zitadel_human_user" "default" { + org_id = zitadel_org.default.id user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" diff --git a/docs/resources/idp_azure_ad.md b/docs/resources/idp_azure_ad.md index ca0ad907..0a4e477c 100644 --- a/docs/resources/idp_azure_ad.md +++ b/docs/resources/idp_azure_ad.md @@ -12,7 +12,7 @@ Resource representing an Azure AD IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_azure_ad" "azure_ad" { +resource "zitadel_idp_azure_ad" "default" { name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/docs/resources/idp_github.md b/docs/resources/idp_github.md index 74f5b625..c49b4ee7 100644 --- a/docs/resources/idp_github.md +++ b/docs/resources/idp_github.md @@ -12,7 +12,7 @@ Resource representing a GitHub IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_github" "github" { +resource "zitadel_idp_github" "default" { name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/idp_github_es.md b/docs/resources/idp_github_es.md index 250a1867..cc9e406c 100644 --- a/docs/resources/idp_github_es.md +++ b/docs/resources/idp_github_es.md @@ -12,7 +12,7 @@ Resource representing a GitHub Enterprise IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_github_es" "github_es" { +resource "zitadel_idp_github_es" "default" { name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/idp_gitlab.md b/docs/resources/idp_gitlab.md index 1a429094..d5a24ddf 100644 --- a/docs/resources/idp_gitlab.md +++ b/docs/resources/idp_gitlab.md @@ -12,7 +12,7 @@ Resource representing a GitLab IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_gitlab" "gitlab" { +resource "zitadel_idp_gitlab" "default" { name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/idp_gitlab_self_hosted.md b/docs/resources/idp_gitlab_self_hosted.md index 4ce8fefa..54f6d2e0 100644 --- a/docs/resources/idp_gitlab_self_hosted.md +++ b/docs/resources/idp_gitlab_self_hosted.md @@ -12,7 +12,7 @@ Resource representing a GitLab Self Hosted IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { +resource "zitadel_idp_gitlab_self_hosted" "default" { name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/idp_google.md b/docs/resources/idp_google.md index 83905365..51307b9a 100644 --- a/docs/resources/idp_google.md +++ b/docs/resources/idp_google.md @@ -12,7 +12,7 @@ Resource representing a Google IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_google" "google" { +resource "zitadel_idp_google" "default" { name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/docs/resources/idp_ldap.md b/docs/resources/idp_ldap.md index 3fb0e2dd..170e8168 100644 --- a/docs/resources/idp_ldap.md +++ b/docs/resources/idp_ldap.md @@ -12,7 +12,7 @@ Resource representing an LDAP IDP on the instance. ## Example Usage ```terraform -resource "zitadel_idp_ldap" "ldap" { +resource "zitadel_idp_ldap" "default" { name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md index 0fba96e5..0a89f35d 100644 --- a/docs/resources/init_message_text.md +++ b/docs/resources/init_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_init_message_text init_en { - org_id = zitadel_org.org.id +resource "zitadel_init_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 3779fbe3..c5fe3eba 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -12,8 +12,8 @@ Resource representing the membership of a user on an instance, defined with the ## Example Usage ```terraform -resource zitadel_instance_member instance_member { - user_id = zitadel_human_user.human_user.id +resource "zitadel_instance_member" "default" { + user_id = zitadel_human_user.default.id roles = ["IAM_OWNER"] } ``` diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index e5819ea9..4ff38d0f 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -12,8 +12,8 @@ Resource representing the custom label policy of an organization. ## Example Usage ```terraform -resource zitadel_label_policy label_policy { - org_id = zitadel_org.org.id +resource "zitadel_label_policy" "default" { + org_id = zitadel_org.default.id primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index 17113399..72c82f77 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -12,8 +12,8 @@ Resource representing the custom lockout policy of an organization. ## Example Usage ```terraform -resource zitadel_lockout_policy lockout_policy { - org_id = zitadel_org.org.id +resource "zitadel_lockout_policy" "default" { + org_id = zitadel_org.default.id max_password_attempts = "5" } ``` diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 304a7233..d89eaca6 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -12,8 +12,8 @@ Resource representing the custom login policy of an organization. ## Example Usage ```terraform -resource zitadel_login_policy login_policy { - org_id = zitadel_org.org.id +resource "zitadel_login_policy" "default" { + org_id = zitadel_org.default.id user_login = true allow_register = true allow_external_idp = true @@ -29,7 +29,7 @@ resource zitadel_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] + idps = [zitadel_org_idp_oidc.default.id, zitadel_org_idp_jwt.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index be4efd37..52751cba 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_login_texts login_texts_en { - org_id = zitadel_org.org.id +resource "zitadel_login_texts" "default" { + org_id = zitadel_org.default.id language = "en" email_verification_done_text = { diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index d131fad7..213ca985 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -12,9 +12,9 @@ Resource representing a machine key ## Example Usage ```terraform -resource zitadel_machine_key machine_key { - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id +resource "zitadel_machine_key" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_machine_user.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index d6b7ed04..aa411792 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -12,8 +12,8 @@ Resource representing a serviceaccount situated under an organization, which the ## Example Usage ```terraform -resource zitadel_machine_user machine_user { - org_id = zitadel_org.org.id +resource "zitadel_machine_user" "default" { + org_id = zitadel_org.default.id user_name = "machine@localhost.com" name = "name" description = "description" diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index 4c3e0476..c5f6e8c9 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -12,8 +12,8 @@ Resource representing the custom notification policy of an organization. ## Example Usage ```terraform -resource zitadel_notification_policy notification_policy { - org_id = zitadel_org.org.id +resource "zitadel_notification_policy" "default" { + org_id = zitadel_org.default.id password_change = false } ``` diff --git a/docs/resources/org.md b/docs/resources/org.md index 2084130b..8ba2495c 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -12,7 +12,7 @@ Resource representing an organization in ZITADEL, which is the highest level aft ## Example Usage ```terraform -resource zitadel_org org { +resource "zitadel_org" "default" { name = "terraform-test" } ``` diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md index d382b38b..ae4b1de8 100644 --- a/docs/resources/org_idp_azure_ad.md +++ b/docs/resources/org_idp_azure_ad.md @@ -12,8 +12,8 @@ Resource representing an Azure AD IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_azure_ad" "azure_ad" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_azure_ad" "default" { + org_id = zitadel_org.default.id name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md index 303cbd56..d0aa7ab2 100644 --- a/docs/resources/org_idp_github.md +++ b/docs/resources/org_idp_github.md @@ -12,8 +12,8 @@ Resource representing a GitHub IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_github" "github" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_github" "default" { + org_id = zitadel_org.default.id name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md index c89c32fc..19e04fdd 100644 --- a/docs/resources/org_idp_github_es.md +++ b/docs/resources/org_idp_github_es.md @@ -12,8 +12,8 @@ Resource representing a GitHub Enterprise IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_github_es" "github_es" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_github_es" "default" { + org_id = zitadel_org.default.id name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md index 6de386f2..a9017ad0 100644 --- a/docs/resources/org_idp_gitlab.md +++ b/docs/resources/org_idp_gitlab.md @@ -12,8 +12,8 @@ Resource representing a GitLab IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_gitlab" "gitlab" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_gitlab" "default" { + org_id = zitadel_org.default.id name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md index 82b4f640..0aa396ef 100644 --- a/docs/resources/org_idp_gitlab_self_hosted.md +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -12,8 +12,8 @@ Resource representing a GitLab Self Hosted IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_gitlab_self_hosted" "default" { + org_id = zitadel_org.default.id name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md index d4a7be21..6dccd31b 100644 --- a/docs/resources/org_idp_google.md +++ b/docs/resources/org_idp_google.md @@ -12,8 +12,8 @@ Resource representing a Google IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_google" "google" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_google" "default" { + org_id = zitadel_org.default.id name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 0c355353..e12e1e65 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -12,8 +12,8 @@ Resource representing a generic JWT IdP of the organization. ## Example Usage ```terraform -resource zitadel_org_idp_jwt jwt_idp { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_jwt" "default" { + org_id = zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" jwt_endpoint = "https://jwtendpoint.com" diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md index b5f17c7f..03aa6318 100644 --- a/docs/resources/org_idp_ldap.md +++ b/docs/resources/org_idp_ldap.md @@ -12,8 +12,8 @@ Resource representing an LDAP IdP on the organization. ## Example Usage ```terraform -resource "zitadel_org_idp_ldap" "ldap" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_ldap" "default" { + org_id = zitadel_org.default.id name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index 7d217b59..ca798487 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -12,8 +12,8 @@ Resource representing a generic OIDC IdP on the organization. ## Example Usage ```terraform -resource zitadel_org_idp_oidc oidc_idp { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_oidc" "default" { + org_id = zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" client_id = "google" diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 858846e7..73d13512 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -12,9 +12,9 @@ Resource representing the membership of a user on an organization, defined with ## Example Usage ```terraform -resource zitadel_org_member org_member { - org_id = zitadel_org.org.id - user_id = zitadel_human_user.human_user.id +resource "zitadel_org_member" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_human_user.default.id roles = ["ORG_OWNER"] } ``` diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index 40dbcf1f..165b228c 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_password_change_message_text password_change_en { - org_id = zitadel_org.org.id +resource "zitadel_password_change_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index e47ae90b..fd7bb888 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -12,8 +12,8 @@ Resource representing the custom password complexity policy of an organization. ## Example Usage ```terraform -resource zitadel_password_complexity_policy password_complexity_policy { - org_id = zitadel_org.org.id +resource "zitadel_password_complexity_policy" "default" { + org_id = zitadel_org.default.id min_length = "8" has_uppercase = true has_lowercase = true diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md index 2c0c6a40..07836566 100644 --- a/docs/resources/password_reset_message_text.md +++ b/docs/resources/password_reset_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_password_reset_message_text password_reset_en { - org_id = zitadel_org.org.id +resource "zitadel_password_reset_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md index 4526496e..09a412b2 100644 --- a/docs/resources/passwordless_registration_message_text.md +++ b/docs/resources/passwordless_registration_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_passwordless_registration_message_text passwordless_registration_en { - org_id = zitadel_org.org.id +resource "zitadel_passwordless_registration_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 09c87b0d..6cb786c3 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -12,9 +12,9 @@ Resource representing a personal access token of a user ## Example Usage ```terraform -resource zitadel_personal_access_token pat { - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id +resource "zitadel_personal_access_token" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_machine_user.default.id expiration_date = "2519-04-01T08:45:00Z" } ``` diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 374a573b..13c1bd43 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -12,11 +12,12 @@ Resource representing the custom privacy policy of an organization. ## Example Usage ```terraform -resource zitadel_privacy_policy privacy_policy { - org_id = zitadel_org.org.id - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" +resource "zitadel_privacy_policy" "default" { + org_id = zitadel_org.default.id + tos_link = "https://google.com" + privacy_link = "https://google.com" + help_link = "https://google.com" + support_email = "support@email.com" } ``` diff --git a/docs/resources/project.md b/docs/resources/project.md index 88612eea..2f5eba6d 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -12,9 +12,9 @@ Resource representing the project, which can then be granted to different organi ## Example Usage ```terraform -resource zitadel_project project { +resource "zitadel_project" "default" { name = "projectname" - org_id = zitadel_org.org.id + org_id = zitadel_org.default.id project_role_assertion = true project_role_check = true has_project_check = true diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 6f3fc0d1..3190e76e 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -12,11 +12,11 @@ Resource representing the grant of a project to a different organization, also c ## Example Usage ```terraform -resource zitadel_project_grant project_grant { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - granted_org_id = zitadel_org.grantedorg.id - role_keys = [zitadel_project_role.project_role.role_key] +resource "zitadel_project_grant" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + granted_org_id = zitadel_org.default.id + role_keys = [zitadel_project_role.default.role_key] } ``` diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 3a2587d2..8542aec0 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -12,11 +12,11 @@ Resource representing the membership of a user on an granted project, defined wi ## Example Usage ```terraform -resource zitadel_project_grant_member project_grant_member { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - grant_id = zitadel_project_grant.project_grant.id - user_id = zitadel_human_user.granted_human_user.id +resource "zitadel_project_grant_member" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + grant_id = zitadel_project_grant.default.id + user_id = zitadel_human_user.default.id roles = ["PROJECT_GRANT_OWNER"] } ``` diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index 14286715..6f73edcd 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -12,10 +12,10 @@ Resource representing the membership of a user on an project, defined with the g ## Example Usage ```terraform -resource zitadel_project_member project_member { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - user_id = zitadel_human_user.human_user.id +resource "zitadel_project_member" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + user_id = zitadel_human_user.default.id roles = ["PROJECT_OWNER"] } ``` diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index 1624787c..31f6678a 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -12,9 +12,9 @@ Resource representing the project roles, which can be given as authorizations to ## Example Usage ```terraform -resource zitadel_project_role project_role { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id +resource "zitadel_project_role" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id role_key = "key" display_name = "display_name2" group = "role_group" diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index 1c30dcc9..d00784dc 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -12,7 +12,7 @@ Resource representing the SMS provider Twilio configuration of an instance. ## Example Usage ```terraform -resource zitadel_sms_provider_twilio twilio { +resource "zitadel_sms_provider_twilio" "default" { sid = "sid" sender_number = "019920892" token = "token" diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index 6ca2635a..ae3b031d 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -12,7 +12,7 @@ Resource representing the SMTP configuration of an instance. ## Example Usage ```terraform -resource zitadel_smtp_config smtp { +resource "zitadel_smtp_config" "default" { sender_address = "address" sender_name = "no-reply" tls = true diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index c2ca5fa0..a1028ae2 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -12,11 +12,11 @@ Resource representing triggers, when actions get started ## Example Usage ```terraform -resource zitadel_trigger_actions trigger_actions { - org_id = zitadel_org.org.id +resource "zitadel_trigger_actions" "default" { + org_id = zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" - action_ids = [zitadel_action.action.id] + action_ids = [zitadel_action.default.id] } ``` diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 78114dcc..a19779a3 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -12,11 +12,11 @@ Resource representing the authorization given to a user directly, including the ## Example Usage ```terraform -resource zitadel_user_grant user_grant { - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id +resource "zitadel_user_grant" "default" { + project_id = zitadel_project.default.id + org_id = zitadel_org.default.id role_keys = ["key"] - user_id = zitadel_human_user.granted_human_user.id + user_id = zitadel_human_user.default.id } ``` diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md index 00886751..834a187a 100644 --- a/docs/resources/verify_email_message_text.md +++ b/docs/resources/verify_email_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_email_message_text verify_email_en { - org_id = zitadel_org.org.id +resource "zitadel_verify_email_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md index 3d00af67..daf58888 100644 --- a/docs/resources/verify_phone_message_text.md +++ b/docs/resources/verify_phone_message_text.md @@ -12,8 +12,8 @@ description: |- ## Example Usage ```terraform -resource zitadel_verify_phone_message_text verify_phone_en { - org_id = zitadel_org.org.id +resource "zitadel_verify_phone_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/data-sources/action.tf b/examples/provider/data-sources/action.tf index b9fcb04f..e5d2e4cb 100644 --- a/examples/provider/data-sources/action.tf +++ b/examples/provider/data-sources/action.tf @@ -1,8 +1,8 @@ -data zitadel_action action { - org_id = data.zitadel_org.org.id - action_id = "177073621691269123" +data "zitadel_action" "default" { + org_id = data.zitadel_org.default.id + action_id = "123456789012345678" } -output action { - value = data.zitadel_action.action -} \ No newline at end of file +output "action" { + value = data.zitadel_action.default +} diff --git a/examples/provider/data-sources/application_api.tf b/examples/provider/data-sources/application_api.tf index a0f30f72..fc5f7d18 100644 --- a/examples/provider/data-sources/application_api.tf +++ b/examples/provider/data-sources/application_api.tf @@ -1,9 +1,9 @@ -data zitadel_application_api api_application { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - app_id = "177073625566806019" +data "zitadel_application_api" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = "123456789012345678" } -output api_application { - value = data.zitadel_application_api.api_application -} \ No newline at end of file +output "application_api" { + value = data.zitadel_application_api.default +} diff --git a/examples/provider/data-sources/application_oidc.tf b/examples/provider/data-sources/application_oidc.tf index d70d1bcc..3b821841 100644 --- a/examples/provider/data-sources/application_oidc.tf +++ b/examples/provider/data-sources/application_oidc.tf @@ -1,9 +1,9 @@ -data zitadel_application_oidc oidc_application { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - app_id = "177073626925760515" +data "zitadel_application_oidc" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = "123456789012345678" } -output oidc_application { - value = data.zitadel_application_oidc.oidc_application -} \ No newline at end of file +output "application_oidc" { + value = data.zitadel_application_oidc.default +} diff --git a/examples/provider/data-sources/default_oidc_settings.tf b/examples/provider/data-sources/default_oidc_settings.tf index 6ff3b5ba..efcd8c99 100644 --- a/examples/provider/data-sources/default_oidc_settings.tf +++ b/examples/provider/data-sources/default_oidc_settings.tf @@ -1,5 +1,5 @@ -data zitadel_default_oidc_settings oidc_settings {} +data "zitadel_default_oidc_settings" "default" {} -output oidc_settings { - value = data.zitadel_default_oidc_settings.oidc_settings +output "oidc_settings" { + value = data.zitadel_default_oidc_settings.default } diff --git a/examples/provider/data-sources/human_user.tf b/examples/provider/data-sources/human_user.tf index 7570eaeb..34c22e2c 100644 --- a/examples/provider/data-sources/human_user.tf +++ b/examples/provider/data-sources/human_user.tf @@ -1,8 +1,8 @@ -data zitadel_human_user human_user { - org_id = data.zitadel_org.org.id - user_id = "177073614158299139" +data "zitadel_human_user" "default" { + org_id = data.zitadel_org.default.id + user_id = "123456789012345678" } -output human_user { - value = data.zitadel_human_user.human_user -} \ No newline at end of file +output "human_user" { + value = data.zitadel_human_user.default +} diff --git a/examples/provider/data-sources/idp_azure_ad.tf b/examples/provider/data-sources/idp_azure_ad.tf index 6f64350e..8bb667ed 100644 --- a/examples/provider/data-sources/idp_azure_ad.tf +++ b/examples/provider/data-sources/idp_azure_ad.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_azure_ad" "azure_ad" { - id = "177073614158299139" +data "zitadel_idp_azure_ad" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_github.tf b/examples/provider/data-sources/idp_github.tf index 800aba13..7d755045 100644 --- a/examples/provider/data-sources/idp_github.tf +++ b/examples/provider/data-sources/idp_github.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_github" "github" { - id = "177073614158299139" +data "zitadel_idp_github" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_github_es.tf b/examples/provider/data-sources/idp_github_es.tf index 6ffc7102..9f94c463 100644 --- a/examples/provider/data-sources/idp_github_es.tf +++ b/examples/provider/data-sources/idp_github_es.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_github_es" "github_es" { - id = "177073614158299139" +data "zitadel_idp_github_es" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_gitlab.tf b/examples/provider/data-sources/idp_gitlab.tf index 71f2c1f2..8933c0c7 100644 --- a/examples/provider/data-sources/idp_gitlab.tf +++ b/examples/provider/data-sources/idp_gitlab.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_gitlab" "gitlab" { - id = "177073614158299139" +data "zitadel_idp_gitlab" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_gitlab_self_hosted.tf b/examples/provider/data-sources/idp_gitlab_self_hosted.tf index 22e3e773..df488d8e 100644 --- a/examples/provider/data-sources/idp_gitlab_self_hosted.tf +++ b/examples/provider/data-sources/idp_gitlab_self_hosted.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { - id = "177073614158299139" +data "zitadel_idp_gitlab_self_hosted" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_google.tf b/examples/provider/data-sources/idp_google.tf index ba498b8e..70f84587 100644 --- a/examples/provider/data-sources/idp_google.tf +++ b/examples/provider/data-sources/idp_google.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_google" "google" { - id = "177073614158299139" +data "zitadel_idp_google" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/idp_ldap.tf b/examples/provider/data-sources/idp_ldap.tf index 42caf7a7..2ae61a04 100644 --- a/examples/provider/data-sources/idp_ldap.tf +++ b/examples/provider/data-sources/idp_ldap.tf @@ -1,3 +1,3 @@ -data "zitadel_idp_ldap" "ldap" { - id = "177073614158299139" +data "zitadel_idp_ldap" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/machine_user.tf b/examples/provider/data-sources/machine_user.tf index 10badde8..c3b529f6 100644 --- a/examples/provider/data-sources/machine_user.tf +++ b/examples/provider/data-sources/machine_user.tf @@ -1,8 +1,8 @@ -data zitadel_machine_user machine_user { - org_id = data.zitadel_org.org.id - user_id = "177073617463410691" +data "zitadel_machine_user" "default" { + org_id = data.zitadel_org.default.id + user_id = "123456789012345678" } -output machine_user { - value = data.zitadel_machine_user.machine_user -} \ No newline at end of file +output "machine_user" { + value = data.zitadel_machine_user.default +} diff --git a/examples/provider/data-sources/org.tf b/examples/provider/data-sources/org.tf index 21b23ca7..2e31aa61 100644 --- a/examples/provider/data-sources/org.tf +++ b/examples/provider/data-sources/org.tf @@ -1,7 +1,7 @@ -data zitadel_org org { - org_id = "177073608051458051" +data "zitadel_org" "default" { + org_id = "123456789012345678" } -output org { - value = data.zitadel_org.org +output "org" { + value = data.zitadel_org.default } diff --git a/examples/provider/data-sources/org_idp_azure_ad.tf b/examples/provider/data-sources/org_idp_azure_ad.tf index 2bea7d3c..93b5bcbe 100644 --- a/examples/provider/data-sources/org_idp_azure_ad.tf +++ b/examples/provider/data-sources/org_idp_azure_ad.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_azure_ad" "azure_ad" { - id = "177073614158299139" +data "zitadel_org_idp_azure_ad" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_github.tf b/examples/provider/data-sources/org_idp_github.tf index f504ceb9..e094c8f2 100644 --- a/examples/provider/data-sources/org_idp_github.tf +++ b/examples/provider/data-sources/org_idp_github.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_github" "github" { - id = "177073614158299139" +data "zitadel_org_idp_github" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_github_es.tf b/examples/provider/data-sources/org_idp_github_es.tf index a460b39c..020e1edc 100644 --- a/examples/provider/data-sources/org_idp_github_es.tf +++ b/examples/provider/data-sources/org_idp_github_es.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_github_es" "github_es" { - id = "177073614158299139" +data "zitadel_org_idp_github_es" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_gitlab.tf b/examples/provider/data-sources/org_idp_gitlab.tf index 94120b75..502fc9f0 100644 --- a/examples/provider/data-sources/org_idp_gitlab.tf +++ b/examples/provider/data-sources/org_idp_gitlab.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_gitlab" "gitlab" { - id = "177073614158299139" +data "zitadel_org_idp_gitlab" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf index 21707e8d..be7551e1 100644 --- a/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf +++ b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - id = "177073614158299139" +data "zitadel_org_idp_gitlab_self_hosted" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_google.tf b/examples/provider/data-sources/org_idp_google.tf index c5e1333d..ffbda608 100644 --- a/examples/provider/data-sources/org_idp_google.tf +++ b/examples/provider/data-sources/org_idp_google.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_google" "google" { - id = "177073614158299139" +data "zitadel_org_idp_google" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_ldap.tf b/examples/provider/data-sources/org_idp_ldap.tf index 03421a07..6bfa868a 100644 --- a/examples/provider/data-sources/org_idp_ldap.tf +++ b/examples/provider/data-sources/org_idp_ldap.tf @@ -1,3 +1,3 @@ -data "zitadel_org_idp_ldap" "ldap" { - id = "177073614158299139" +data "zitadel_org_idp_ldap" "default" { + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_jwt_idp.tf b/examples/provider/data-sources/org_jwt_idp.tf index 08d47849..caa4e726 100644 --- a/examples/provider/data-sources/org_jwt_idp.tf +++ b/examples/provider/data-sources/org_jwt_idp.tf @@ -1,8 +1,8 @@ -data zitadel_org_jwt_idp org_jwt_idp { - org_id = data.zitadel_org.org.id - idp_id = "177073612581240835" +data "zitadel_org_jwt_idp" "default" { + org_id = data.zitadel_org.default.id + idp_id = "123456789012345678" } -output org_jwt_idp { - value = data.zitadel_org_jwt_idp.org_jwt_idp -} \ No newline at end of file +output "org_idp_org_jwt_idp" { + value = data.zitadel_org_jwt_idp.default +} diff --git a/examples/provider/data-sources/org_oidc_idp.tf b/examples/provider/data-sources/org_oidc_idp.tf index 4d9e4c9e..4924d0ac 100644 --- a/examples/provider/data-sources/org_oidc_idp.tf +++ b/examples/provider/data-sources/org_oidc_idp.tf @@ -1,8 +1,8 @@ -data zitadel_org_oidc_idp org_oidc_idp { - org_id = data.zitadel_org.org.id - idp_id = "177073612581240835" +data "zitadel_org_oidc_idp" "default" { + org_id = data.zitadel_org.default.id + idp_id = "123456789012345678" } -output org_oidc_idp { - value = data.zitadel_org_oidc_idp.org_oidc_idp -} \ No newline at end of file +output "org_oidc_idp" { + value = data.zitadel_org_oidc_idp.default +} diff --git a/examples/provider/data-sources/project.tf b/examples/provider/data-sources/project.tf index c252507d..4650cd8a 100644 --- a/examples/provider/data-sources/project.tf +++ b/examples/provider/data-sources/project.tf @@ -1,8 +1,8 @@ -data zitadel_project project { - org_id = data.zitadel_org.org.id - project_id = "177073620768522243" +data "zitadel_project" "default" { + org_id = data.zitadel_org.default.id + project_id = "123456789012345678" } -output project { - value = data.zitadel_project.project -} \ No newline at end of file +output "project" { + value = data.zitadel_project.default +} diff --git a/examples/provider/data-sources/project_role.tf b/examples/provider/data-sources/project_role.tf index c4c00b91..6669b021 100644 --- a/examples/provider/data-sources/project_role.tf +++ b/examples/provider/data-sources/project_role.tf @@ -1,9 +1,9 @@ -data zitadel_project_role project_role { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id +data "zitadel_project_role" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id role_key = "key" } -output project_role { - value = data.zitadel_project_role.project_role -} \ No newline at end of file +output "project_role" { + value = data.zitadel_project_role.default +} diff --git a/examples/provider/data-sources/trigger_actions.tf b/examples/provider/data-sources/trigger_actions.tf index f82a6594..806a1333 100644 --- a/examples/provider/data-sources/trigger_actions.tf +++ b/examples/provider/data-sources/trigger_actions.tf @@ -1,9 +1,9 @@ -data zitadel_trigger_actions trigger_actions { - org_id = data.zitadel_org.org.id +data "zitadel_trigger_actions" "default" { + org_id = data.zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" } -output trigger_actions { - value = data.zitadel_trigger_actions.trigger_actions -} \ No newline at end of file +output "trigger_actions" { + value = data.zitadel_trigger_actions.default +} diff --git a/examples/provider/resources/action.tf b/examples/provider/resources/action.tf index 807228de..15a11924 100644 --- a/examples/provider/resources/action.tf +++ b/examples/provider/resources/action.tf @@ -1,5 +1,5 @@ -resource "zitadel_action" "action" { - org_id = data.zitadel_org.org.id +resource "zitadel_action" "default" { + org_id = data.zitadel_org.default.id name = "actionname" script = "testscript" timeout = "10s" diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index 57e96ab3..33b66a57 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -1,6 +1,6 @@ -resource zitadel_application_api application_api { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id +resource "zitadel_application_api" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id name = "applicationapi" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" } diff --git a/examples/provider/resources/application_key.tf b/examples/provider/resources/application_key.tf index 286d9497..a00da4f8 100644 --- a/examples/provider/resources/application_key.tf +++ b/examples/provider/resources/application_key.tf @@ -1,7 +1,7 @@ -resource "zitadel_application_key" "app_key" { - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id - app_id = data.zitadel_application_api.application_api.id +resource "zitadel_application_key" "default" { + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + app_id = data.zitadel_application_api.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index df1daa12..359aed07 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,6 +1,6 @@ -resource zitadel_application_oidc application_oidc { - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id +resource "zitadel_application_oidc" "default" { + project_id = zitadel_project.default.id + org_id = zitadel_org.default.id name = "applicationoidc" redirect_uris = ["https://localhost.com"] diff --git a/examples/provider/resources/default_domain_claimed_message_text.tf b/examples/provider/resources/default_domain_claimed_message_text.tf index ee5f7957..c0032b97 100644 --- a/examples/provider/resources/default_domain_claimed_message_text.tf +++ b/examples/provider/resources/default_domain_claimed_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_domain_claimed_message_text domain_claimed_en { +resource "zitadel_default_domain_claimed_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_domain_claimed_message_text domain_claimed_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_domain_policy.tf b/examples/provider/resources/default_domain_policy.tf index e0a64eaa..60ac9558 100644 --- a/examples/provider/resources/default_domain_policy.tf +++ b/examples/provider/resources/default_domain_policy.tf @@ -1,5 +1,5 @@ -resource zitadel_default_domain_policy domain_policy { +resource "zitadel_default_domain_policy" "default" { user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_init_message_text.tf b/examples/provider/resources/default_init_message_text.tf index 1738cedc..e9b9fc83 100644 --- a/examples/provider/resources/default_init_message_text.tf +++ b/examples/provider/resources/default_init_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_init_message_text init_en { +resource "zitadel_default_init_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_init_message_text init_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_label_policy.tf b/examples/provider/resources/default_label_policy.tf index 082a48e8..73544b6d 100644 --- a/examples/provider/resources/default_label_policy.tf +++ b/examples/provider/resources/default_label_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_label_policy label_policy { +resource "zitadel_default_label_policy" "default" { primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" @@ -20,4 +20,4 @@ resource zitadel_default_label_policy label_policy { icon_dark_path = "/path/to/icon_dark.jpg" font_hash = filemd5("/path/to/font.tff") font_path = "/path/to/font.tff" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_lockout_policy.tf b/examples/provider/resources/default_lockout_policy.tf index 4a64e7e4..e65c5b33 100644 --- a/examples/provider/resources/default_lockout_policy.tf +++ b/examples/provider/resources/default_lockout_policy.tf @@ -1,3 +1,3 @@ -resource zitadel_default_lockout_policy lockout_policy { +resource "zitadel_default_lockout_policy" "default" { max_password_attempts = "5" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index 43796d7c..69029699 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_login_policy login_policy { +resource "zitadel_default_login_policy" "default" { user_login = true allow_register = true allow_external_idp = true diff --git a/examples/provider/resources/default_login_texts.tf b/examples/provider/resources/default_login_texts.tf index e0b9ff47..9cee3674 100644 --- a/examples/provider/resources/default_login_texts.tf +++ b/examples/provider/resources/default_login_texts.tf @@ -1,4 +1,4 @@ -resource zitadel_default_login_texts login_texts_en { +resource "zitadel_default_login_texts" "default" { language = "en" email_verification_done_text = { diff --git a/examples/provider/resources/default_notification_policy.tf b/examples/provider/resources/default_notification_policy.tf index 8d86b5ea..9d1970de 100644 --- a/examples/provider/resources/default_notification_policy.tf +++ b/examples/provider/resources/default_notification_policy.tf @@ -1,3 +1,3 @@ -resource zitadel_default_notification_policy notification_policy { +resource "zitadel_default_notification_policy" "default" { password_change = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_oidc_settings.tf b/examples/provider/resources/default_oidc_settings.tf index d81ecb04..8f17d20d 100644 --- a/examples/provider/resources/default_oidc_settings.tf +++ b/examples/provider/resources/default_oidc_settings.tf @@ -1,6 +1,6 @@ -resource zitadel_default_oidc_settings oidc_settings { - access_token_lifetime = "12h0m0s" - id_token_lifetime = "12h0m0s" - refresh_token_expiration = "720h0m0s" +resource "zitadel_default_oidc_settings" "default" { + access_token_lifetime = "12h0m0s" + id_token_lifetime = "12h0m0s" + refresh_token_expiration = "720h0m0s" refresh_token_idle_expiration = "2160h0m0s" } diff --git a/examples/provider/resources/default_password_change_message_text.tf b/examples/provider/resources/default_password_change_message_text.tf index e54125a8..dcbe3362 100644 --- a/examples/provider/resources/default_password_change_message_text.tf +++ b/examples/provider/resources/default_password_change_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_password_change_message_text password_change_en { +resource "zitadel_default_password_change_message_text" "default" { language = "en" title = "title example" diff --git a/examples/provider/resources/default_password_complexity_policy.tf b/examples/provider/resources/default_password_complexity_policy.tf index ec4970b9..9ac21fcb 100644 --- a/examples/provider/resources/default_password_complexity_policy.tf +++ b/examples/provider/resources/default_password_complexity_policy.tf @@ -1,7 +1,7 @@ -resource zitadel_default_password_complexity_policy password_complexity_policy { +resource "zitadel_default_password_complexity_policy" "default" { min_length = "8" has_uppercase = true has_lowercase = true has_number = true has_symbol = true -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_password_reset_message_text.tf b/examples/provider/resources/default_password_reset_message_text.tf index b12a8b3f..63127b1e 100644 --- a/examples/provider/resources/default_password_reset_message_text.tf +++ b/examples/provider/resources/default_password_reset_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_password_reset_message_text password_reset_en { +resource "zitadel_default_password_reset_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_password_reset_message_text password_reset_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_passwordless_registration_message_text.tf b/examples/provider/resources/default_passwordless_registration_message_text.tf index a3c0fbd9..7c01e91f 100644 --- a/examples/provider/resources/default_passwordless_registration_message_text.tf +++ b/examples/provider/resources/default_passwordless_registration_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_passwordless_registration_message_text passwordless_registration_en { +resource "zitadel_default_passwordless_registration_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_passwordless_registration_message_text passwordless_reg text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf index b0b20d09..8b3c1002 100644 --- a/examples/provider/resources/default_privacy_policy.tf +++ b/examples/provider/resources/default_privacy_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_default_privacy_policy privacy_policy { +resource "zitadel_default_privacy_policy" "default" { tos_link = "https://google.com" privacy_link = "https://google.com" help_link = "https://google.com" diff --git a/examples/provider/resources/default_verify_email_message_text.tf b/examples/provider/resources/default_verify_email_message_text.tf index 693de48f..d5b05e1e 100644 --- a/examples/provider/resources/default_verify_email_message_text.tf +++ b/examples/provider/resources/default_verify_email_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_verify_email_message_text verify_email_en { +resource "zitadel_default_verify_email_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_verify_email_message_text verify_email_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/default_verify_phone_message_text.tf b/examples/provider/resources/default_verify_phone_message_text.tf index f58c46c0..d2de41d5 100644 --- a/examples/provider/resources/default_verify_phone_message_text.tf +++ b/examples/provider/resources/default_verify_phone_message_text.tf @@ -1,4 +1,4 @@ -resource zitadel_default_verify_phone_message_text verify_phone_en { +resource "zitadel_default_verify_phone_message_text" "default" { language = "en" title = "title example" @@ -8,4 +8,4 @@ resource zitadel_default_verify_phone_message_text verify_phone_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index 9ace3bb3..eed8c9db 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,5 +1,5 @@ -resource zitadel_domain domain { - org_id = zitadel_org.org.id - name = "zitadel.default.127.0.0.1.sslip.io" +resource "zitadel_domain" "default" { + org_id = zitadel_org.default.id + name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true -} \ No newline at end of file +} diff --git a/examples/provider/resources/domain_claimed_message_text.tf b/examples/provider/resources/domain_claimed_message_text.tf index e3f2c191..0f15b3e5 100644 --- a/examples/provider/resources/domain_claimed_message_text.tf +++ b/examples/provider/resources/domain_claimed_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_domain_claimed_message_text domain_claimed_en { - org_id = zitadel_org.org.id +resource "zitadel_domain_claimed_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_domain_claimed_message_text domain_claimed_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index 70c02620..a5f45519 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,6 +1,6 @@ -resource zitadel_domain_policy domain_policy { - org_id = zitadel_org.org.id +resource "zitadel_domain_policy" "default" { + org_id = zitadel_org.default.id user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf index 42d32965..caa2e1f9 100644 --- a/examples/provider/resources/granted_human_user.tf +++ b/examples/provider/resources/granted_human_user.tf @@ -1,5 +1,5 @@ -resource zitadel_human_user granted_human_user { - org_id = zitadel_org.grantedorg.id +resource "zitadel_human_user" "default" { + org_id = zitadel_org.default.id user_name = "human@localhost" first_name = "firstname" last_name = "lastname" diff --git a/examples/provider/resources/granted_org.tf b/examples/provider/resources/granted_org.tf deleted file mode 100644 index 73f0cb78..00000000 --- a/examples/provider/resources/granted_org.tf +++ /dev/null @@ -1,3 +0,0 @@ -resource zitadel_org grantedorg { - name = "terraform-test-granted" -} diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index 5370b14e..b4b16173 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,5 +1,5 @@ -resource zitadel_human_user human_user { - org_id = zitadel_org.org.id +resource "zitadel_human_user" "default" { + org_id = zitadel_org.default.id user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" diff --git a/examples/provider/resources/idp_azure_ad.tf b/examples/provider/resources/idp_azure_ad.tf index 19f0a6fe..b6f87a57 100644 --- a/examples/provider/resources/idp_azure_ad.tf +++ b/examples/provider/resources/idp_azure_ad.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_azure_ad" "azure_ad" { +resource "zitadel_idp_azure_ad" "default" { name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/examples/provider/resources/idp_github.tf b/examples/provider/resources/idp_github.tf index 3760e21b..bbe729f9 100644 --- a/examples/provider/resources/idp_github.tf +++ b/examples/provider/resources/idp_github.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_github" "github" { +resource "zitadel_idp_github" "default" { name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/idp_github_es.tf b/examples/provider/resources/idp_github_es.tf index 290aeed3..f7f985cf 100644 --- a/examples/provider/resources/idp_github_es.tf +++ b/examples/provider/resources/idp_github_es.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_github_es" "github_es" { +resource "zitadel_idp_github_es" "default" { name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/idp_gitlab.tf b/examples/provider/resources/idp_gitlab.tf index 1dd0bc60..1440fe71 100644 --- a/examples/provider/resources/idp_gitlab.tf +++ b/examples/provider/resources/idp_gitlab.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_gitlab" "gitlab" { +resource "zitadel_idp_gitlab" "default" { name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/idp_gitlab_self_hosted.tf b/examples/provider/resources/idp_gitlab_self_hosted.tf index c41343b8..3914506c 100644 --- a/examples/provider/resources/idp_gitlab_self_hosted.tf +++ b/examples/provider/resources/idp_gitlab_self_hosted.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_gitlab_self_hosted" "gitlab_self_hosted" { +resource "zitadel_idp_gitlab_self_hosted" "default" { name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/idp_google.tf b/examples/provider/resources/idp_google.tf index a15e7e39..2f009cec 100644 --- a/examples/provider/resources/idp_google.tf +++ b/examples/provider/resources/idp_google.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_google" "google" { +resource "zitadel_idp_google" "default" { name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/examples/provider/resources/idp_ldap.tf b/examples/provider/resources/idp_ldap.tf index 580f5d29..ce3156f5 100644 --- a/examples/provider/resources/idp_ldap.tf +++ b/examples/provider/resources/idp_ldap.tf @@ -1,4 +1,4 @@ -resource "zitadel_idp_ldap" "ldap" { +resource "zitadel_idp_ldap" "default" { name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/examples/provider/resources/init_message_text.tf b/examples/provider/resources/init_message_text.tf index e648014a..811b442b 100644 --- a/examples/provider/resources/init_message_text.tf +++ b/examples/provider/resources/init_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_init_message_text init_en { - org_id = zitadel_org.org.id +resource "zitadel_init_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_init_message_text init_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/instance_member.tf b/examples/provider/resources/instance_member.tf index ddac2c4f..a80d1d30 100644 --- a/examples/provider/resources/instance_member.tf +++ b/examples/provider/resources/instance_member.tf @@ -1,4 +1,4 @@ -resource zitadel_instance_member instance_member { - user_id = zitadel_human_user.human_user.id +resource "zitadel_instance_member" "default" { + user_id = zitadel_human_user.default.id roles = ["IAM_OWNER"] -} \ No newline at end of file +} diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index 7aaa6d23..e614a0b2 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -1,5 +1,5 @@ -resource zitadel_label_policy label_policy { - org_id = zitadel_org.org.id +resource "zitadel_label_policy" "default" { + org_id = zitadel_org.default.id primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" @@ -21,4 +21,4 @@ resource zitadel_label_policy label_policy { icon_dark_path = "/path/to/icon_dark.jpg" font_hash = filemd5("/path/to/font.tff") font_path = "/path/to/font.tff" -} \ No newline at end of file +} diff --git a/examples/provider/resources/lockout_policy.tf b/examples/provider/resources/lockout_policy.tf index 4d8a6a05..8adfd6ea 100644 --- a/examples/provider/resources/lockout_policy.tf +++ b/examples/provider/resources/lockout_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_lockout_policy lockout_policy { - org_id = zitadel_org.org.id +resource "zitadel_lockout_policy" "default" { + org_id = zitadel_org.default.id max_password_attempts = "5" -} \ No newline at end of file +} diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index f2470880..c2df3765 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -1,5 +1,5 @@ -resource zitadel_login_policy login_policy { - org_id = zitadel_org.org.id +resource "zitadel_login_policy" "default" { + org_id = zitadel_org.default.id user_login = true allow_register = true allow_external_idp = true @@ -15,7 +15,7 @@ resource zitadel_login_policy login_policy { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_idp_oidc.oidc_idp.id, zitadel_org_idp_jwt.jwt_idp.id] + idps = [zitadel_org_idp_oidc.default.id, zitadel_org_idp_jwt.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/examples/provider/resources/login_texts.tf b/examples/provider/resources/login_texts.tf index ea13f4c6..04cce210 100644 --- a/examples/provider/resources/login_texts.tf +++ b/examples/provider/resources/login_texts.tf @@ -1,5 +1,5 @@ -resource zitadel_login_texts login_texts_en { - org_id = zitadel_org.org.id +resource "zitadel_login_texts" "default" { + org_id = zitadel_org.default.id language = "en" email_verification_done_text = { @@ -288,4 +288,4 @@ resource zitadel_login_texts login_texts_en { title = "example" validate_token_text = "example" } -} \ No newline at end of file +} diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 3516c458..1da5e560 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,6 +1,6 @@ -resource zitadel_machine_key machine_key { - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id +resource "zitadel_machine_key" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_machine_user.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } diff --git a/examples/provider/resources/machine_user.tf b/examples/provider/resources/machine_user.tf index ae091cf6..5edbe8f1 100644 --- a/examples/provider/resources/machine_user.tf +++ b/examples/provider/resources/machine_user.tf @@ -1,6 +1,6 @@ -resource zitadel_machine_user machine_user { - org_id = zitadel_org.org.id +resource "zitadel_machine_user" "default" { + org_id = zitadel_org.default.id user_name = "machine@localhost.com" name = "name" description = "description" -} \ No newline at end of file +} diff --git a/examples/provider/resources/notification_policy.tf b/examples/provider/resources/notification_policy.tf index a10f774c..14278754 100644 --- a/examples/provider/resources/notification_policy.tf +++ b/examples/provider/resources/notification_policy.tf @@ -1,4 +1,4 @@ -resource zitadel_notification_policy notification_policy { - org_id = zitadel_org.org.id +resource "zitadel_notification_policy" "default" { + org_id = zitadel_org.default.id password_change = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/org.tf b/examples/provider/resources/org.tf index 8dbaa015..78acd03c 100644 --- a/examples/provider/resources/org.tf +++ b/examples/provider/resources/org.tf @@ -1,3 +1,3 @@ -resource zitadel_org org { +resource "zitadel_org" "default" { name = "terraform-test" -} \ No newline at end of file +} diff --git a/examples/provider/resources/org_idp_azure_ad.tf b/examples/provider/resources/org_idp_azure_ad.tf index ddfa162e..9abcb69b 100644 --- a/examples/provider/resources/org_idp_azure_ad.tf +++ b/examples/provider/resources/org_idp_azure_ad.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_azure_ad" "azure_ad" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_azure_ad" "default" { + org_id = zitadel_org.default.id name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/examples/provider/resources/org_idp_github.tf b/examples/provider/resources/org_idp_github.tf index 0a4ae584..698adb85 100644 --- a/examples/provider/resources/org_idp_github.tf +++ b/examples/provider/resources/org_idp_github.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_github" "github" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_github" "default" { + org_id = zitadel_org.default.id name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/org_idp_github_es.tf b/examples/provider/resources/org_idp_github_es.tf index e0898653..ed2ffd1f 100644 --- a/examples/provider/resources/org_idp_github_es.tf +++ b/examples/provider/resources/org_idp_github_es.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_github_es" "github_es" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_github_es" "default" { + org_id = zitadel_org.default.id name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/org_idp_gitlab.tf b/examples/provider/resources/org_idp_gitlab.tf index 7dd6174e..dcc1aa87 100644 --- a/examples/provider/resources/org_idp_gitlab.tf +++ b/examples/provider/resources/org_idp_gitlab.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_gitlab" "gitlab" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_gitlab" "default" { + org_id = zitadel_org.default.id name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/org_idp_gitlab_self_hosted.tf b/examples/provider/resources/org_idp_gitlab_self_hosted.tf index 59ddcf9c..68c2a4e7 100644 --- a/examples/provider/resources/org_idp_gitlab_self_hosted.tf +++ b/examples/provider/resources/org_idp_gitlab_self_hosted.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_gitlab_self_hosted" "gitlab_self_hosted" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_gitlab_self_hosted" "default" { + org_id = zitadel_org.default.id name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/org_idp_google.tf b/examples/provider/resources/org_idp_google.tf index c53a7df7..e3d8352c 100644 --- a/examples/provider/resources/org_idp_google.tf +++ b/examples/provider/resources/org_idp_google.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_google" "google" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_google" "default" { + org_id = zitadel_org.default.id name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/examples/provider/resources/org_idp_jwt.tf b/examples/provider/resources/org_idp_jwt.tf index 6f316a25..ba9c7acf 100644 --- a/examples/provider/resources/org_idp_jwt.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -1,5 +1,5 @@ -resource zitadel_org_idp_jwt jwt_idp { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_jwt" "default" { + org_id = zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" jwt_endpoint = "https://jwtendpoint.com" @@ -7,4 +7,4 @@ resource zitadel_org_idp_jwt jwt_idp { keys_endpoint = "https://jwtendpoint.com/keys" header_name = "x-auth-token" auto_register = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/org_idp_ldap.tf b/examples/provider/resources/org_idp_ldap.tf index dfc647b4..aa65b544 100644 --- a/examples/provider/resources/org_idp_ldap.tf +++ b/examples/provider/resources/org_idp_ldap.tf @@ -1,5 +1,5 @@ -resource "zitadel_org_idp_ldap" "ldap" { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_ldap" "default" { + org_id = zitadel_org.default.id name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index ce1606d3..6db2e95d 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,5 +1,5 @@ -resource zitadel_org_idp_oidc oidc_idp { - org_id = zitadel_org.org.id +resource "zitadel_org_idp_oidc" "default" { + org_id = zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" client_id = "google" @@ -9,4 +9,4 @@ resource zitadel_org_idp_oidc oidc_idp { display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" auto_register = false -} \ No newline at end of file +} diff --git a/examples/provider/resources/org_member.tf b/examples/provider/resources/org_member.tf index 56bb57dc..653a1963 100644 --- a/examples/provider/resources/org_member.tf +++ b/examples/provider/resources/org_member.tf @@ -1,5 +1,5 @@ -resource zitadel_org_member org_member { - org_id = zitadel_org.org.id - user_id = zitadel_human_user.human_user.id +resource "zitadel_org_member" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_human_user.default.id roles = ["ORG_OWNER"] -} \ No newline at end of file +} diff --git a/examples/provider/resources/password_change_message_text.tf b/examples/provider/resources/password_change_message_text.tf index abfbb1f0..eff3fc5f 100644 --- a/examples/provider/resources/password_change_message_text.tf +++ b/examples/provider/resources/password_change_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_password_change_message_text password_change_en { - org_id = zitadel_org.org.id +resource "zitadel_password_change_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf index 08534b5e..4661de1e 100644 --- a/examples/provider/resources/password_complexity_policy.tf +++ b/examples/provider/resources/password_complexity_policy.tf @@ -1,8 +1,8 @@ -resource zitadel_password_complexity_policy password_complexity_policy { - org_id = zitadel_org.org.id +resource "zitadel_password_complexity_policy" "default" { + org_id = zitadel_org.default.id min_length = "8" has_uppercase = true has_lowercase = true has_number = true has_symbol = true -} \ No newline at end of file +} diff --git a/examples/provider/resources/password_reset_message_text.tf b/examples/provider/resources/password_reset_message_text.tf index 807e8bb5..871352ec 100644 --- a/examples/provider/resources/password_reset_message_text.tf +++ b/examples/provider/resources/password_reset_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_password_reset_message_text password_reset_en { - org_id = zitadel_org.org.id +resource "zitadel_password_reset_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_password_reset_message_text password_reset_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/passwordless_registration_message_text.tf b/examples/provider/resources/passwordless_registration_message_text.tf index d43a8a0a..d51af5df 100644 --- a/examples/provider/resources/passwordless_registration_message_text.tf +++ b/examples/provider/resources/passwordless_registration_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_passwordless_registration_message_text passwordless_registration_en { - org_id = zitadel_org.org.id +resource "zitadel_passwordless_registration_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_passwordless_registration_message_text passwordless_registratio text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/personal_access_token.tf b/examples/provider/resources/personal_access_token.tf index 7596eb8b..a0fede92 100644 --- a/examples/provider/resources/personal_access_token.tf +++ b/examples/provider/resources/personal_access_token.tf @@ -1,5 +1,5 @@ -resource zitadel_personal_access_token pat { - org_id = zitadel_org.org.id - user_id = zitadel_machine_user.machine_user.id +resource "zitadel_personal_access_token" "default" { + org_id = zitadel_org.default.id + user_id = zitadel_machine_user.default.id expiration_date = "2519-04-01T08:45:00Z" -} \ No newline at end of file +} diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index 5dc3491a..ccc61f9b 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,5 +1,5 @@ -resource zitadel_privacy_policy privacy_policy { - org_id = zitadel_org.org.id +resource "zitadel_privacy_policy" "default" { + org_id = zitadel_org.default.id tos_link = "https://google.com" privacy_link = "https://google.com" help_link = "https://google.com" diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 3c445ddc..77a0bc5c 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,6 +1,6 @@ -resource zitadel_project project { +resource "zitadel_project" "default" { name = "projectname" - org_id = zitadel_org.org.id + org_id = zitadel_org.default.id project_role_assertion = true project_role_check = true has_project_check = true diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 9c5c0178..1bd0123e 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,6 +1,6 @@ -resource zitadel_project_grant project_grant { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - granted_org_id = zitadel_org.grantedorg.id - role_keys = [zitadel_project_role.project_role.role_key] +resource "zitadel_project_grant" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + granted_org_id = zitadel_org.default.id + role_keys = [zitadel_project_role.default.role_key] } diff --git a/examples/provider/resources/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf index 27875252..09dd4e35 100644 --- a/examples/provider/resources/project_grant_member.tf +++ b/examples/provider/resources/project_grant_member.tf @@ -1,7 +1,7 @@ -resource zitadel_project_grant_member project_grant_member { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - grant_id = zitadel_project_grant.project_grant.id - user_id = zitadel_human_user.granted_human_user.id +resource "zitadel_project_grant_member" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + grant_id = zitadel_project_grant.default.id + user_id = zitadel_human_user.default.id roles = ["PROJECT_GRANT_OWNER"] -} \ No newline at end of file +} diff --git a/examples/provider/resources/project_member.tf b/examples/provider/resources/project_member.tf index d31aebca..8d647293 100644 --- a/examples/provider/resources/project_member.tf +++ b/examples/provider/resources/project_member.tf @@ -1,6 +1,6 @@ -resource zitadel_project_member project_member { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id - user_id = zitadel_human_user.human_user.id +resource "zitadel_project_member" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id + user_id = zitadel_human_user.default.id roles = ["PROJECT_OWNER"] -} \ No newline at end of file +} diff --git a/examples/provider/resources/project_role.tf b/examples/provider/resources/project_role.tf index 1b56ff5a..61081cd6 100644 --- a/examples/provider/resources/project_role.tf +++ b/examples/provider/resources/project_role.tf @@ -1,7 +1,7 @@ -resource zitadel_project_role project_role { - org_id = zitadel_org.org.id - project_id = zitadel_project.project.id +resource "zitadel_project_role" "default" { + org_id = zitadel_org.default.id + project_id = zitadel_project.default.id role_key = "key" display_name = "display_name2" group = "role_group" -} \ No newline at end of file +} diff --git a/examples/provider/resources/sms_provider_twilio.tf b/examples/provider/resources/sms_provider_twilio.tf index 0a4334fc..60b99bea 100644 --- a/examples/provider/resources/sms_provider_twilio.tf +++ b/examples/provider/resources/sms_provider_twilio.tf @@ -1,5 +1,5 @@ -resource zitadel_sms_provider_twilio twilio { +resource "zitadel_sms_provider_twilio" "default" { sid = "sid" sender_number = "019920892" token = "token" -} \ No newline at end of file +} diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf index 7f81a237..1b3add51 100644 --- a/examples/provider/resources/smtp_config.tf +++ b/examples/provider/resources/smtp_config.tf @@ -1,4 +1,4 @@ -resource zitadel_smtp_config smtp { +resource "zitadel_smtp_config" "default" { sender_address = "address" sender_name = "no-reply" tls = true diff --git a/examples/provider/resources/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf index 4bf115de..27647eae 100644 --- a/examples/provider/resources/trigger_actions.tf +++ b/examples/provider/resources/trigger_actions.tf @@ -1,6 +1,6 @@ -resource zitadel_trigger_actions trigger_actions { - org_id = zitadel_org.org.id +resource "zitadel_trigger_actions" "default" { + org_id = zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" - action_ids = [zitadel_action.action.id] -} \ No newline at end of file + action_ids = [zitadel_action.default.id] +} diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 77a1cb65..7a82ec32 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,6 +1,6 @@ -resource zitadel_user_grant user_grant { - project_id = zitadel_project.project.id - org_id = zitadel_org.org.id +resource "zitadel_user_grant" "default" { + project_id = zitadel_project.default.id + org_id = zitadel_org.default.id role_keys = ["key"] - user_id = zitadel_human_user.granted_human_user.id + user_id = zitadel_human_user.default.id } diff --git a/examples/provider/resources/verify_email_message_text.tf b/examples/provider/resources/verify_email_message_text.tf index e0648cc6..957aa901 100644 --- a/examples/provider/resources/verify_email_message_text.tf +++ b/examples/provider/resources/verify_email_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_verify_email_message_text verify_email_en { - org_id = zitadel_org.org.id +resource "zitadel_verify_email_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_verify_email_message_text verify_email_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/examples/provider/resources/verify_phone_message_text.tf b/examples/provider/resources/verify_phone_message_text.tf index 4a57d174..8216cc9a 100644 --- a/examples/provider/resources/verify_phone_message_text.tf +++ b/examples/provider/resources/verify_phone_message_text.tf @@ -1,5 +1,5 @@ -resource zitadel_verify_phone_message_text verify_phone_en { - org_id = zitadel_org.org.id +resource "zitadel_verify_phone_message_text" "default" { + org_id = zitadel_org.default.id language = "en" title = "title example" @@ -9,4 +9,4 @@ resource zitadel_verify_phone_message_text verify_phone_en { text = "text example" button_text = "button_text example" footer_text = "footer_text example" -} \ No newline at end of file +} diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index 473267f3..26b4ce7e 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -11,6 +11,6 @@ description: |- ## Example Usage -{{ tffile "examples/provider/resources/app_key.tf" }} +{{ tffile "examples/provider/resources/application_key.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index b852b5a7..6ae4c9c5 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -2,6 +2,7 @@ package action_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -13,27 +14,22 @@ import ( func TestAccAction(t *testing.T) { resourceName := "zitadel_action" - initialProperty := "initialproperty" - updatedProperty := "updatedproperty" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } + resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + nameAttribute := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() + resourceExample = strings.Replace(resourceExample, nameAttribute, frame.UniqueResourcesID, 1) + exampleProperty := test_utils.AttributeValue(t, "script", exampleAttributes).AsString() + updatedProperty := "updatedproperty" test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - frame.OrgExampleDatasource, func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "testaction" - script = "%s" - timeout = "10s" - allowed_to_fail = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) + return fmt.Sprintf("%s\n%s", frame.OrgExampleDatasource, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", true, checkRemoteProperty(frame), diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 1a19cab3..c66456d6 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -2,6 +2,7 @@ package app_key_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -14,8 +15,6 @@ import ( func TestAccAppKey(t *testing.T) { resourceName := "zitadel_application_key" - initialProperty := "2500-01-01T08:45:00Z" - updatedProperty := "2501-01-01T08:45:00Z" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) @@ -26,41 +25,30 @@ func TestAccAppKey(t *testing.T) { if err != nil { t.Fatalf("failed to create project: %v", err) } - app, err := frame.AddOIDCApp(frame, &management.AddOIDCAppRequest{ + apiApp, err := frame.AddAPIApp(frame, &management.AddAPIAppRequest{ ProjectId: project.GetId(), Name: frame.UniqueResourcesID, - AuthMethodType: app.OIDCAuthMethodType_OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, + AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, }) + resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") + projectDatasourceExample = strings.Replace(projectDatasourceExample, "123456789012345678", project.GetId(), 1) + appDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "application_api") + appDatasourceExample = strings.Replace(appDatasourceExample, "123456789012345678", apiApp.GetAppId(), 1) + exampleProperty := test_utils.AttributeValue(t, "expiration_date", exampleAttributes).AsString() + updatedProperty := "2501-01-01T08:45:00Z" test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - fmt.Sprintf(`%s -data "zitadel_project" "project" { - id = "%s" - org_id = data.zitadel_org.org.id -} -data "zitadel_application_api" "application_api" { - id = "%s" - org_id = data.zitadel_org.org.id - project_id = data.zitadel_project.project.id -} -`, frame.OrgExampleDatasource, project.GetId(), app.GetAppId()), func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - app_id = "%s" - key_type = "KEY_TYPE_JSON" - expiration_date = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), app.GetAppId(), configProperty) + return fmt.Sprintf("%s\n%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, appDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", false, - checkRemoteProperty(frame, project.GetId(), app.GetAppId()), + checkRemoteProperty(frame, project.GetId(), apiApp.GetAppId()), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), app.GetAppId()), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), apiApp.GetAppId()), updatedProperty), nil, nil, "", "", ) } diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 99e82082..47c3a6f4 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -28,14 +28,15 @@ func TestAccAppAPI(t *testing.T) { test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, + frame.OrgExampleDatasource, func(configProperty, _ string) string { return fmt.Sprintf(` -resource "%s" "%s" { +resource "%s" "my_%s" { org_id = "%s" project_id = "%s" name = "%s" auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), configProperty) +}`, resourceName, resourceName, frame.OrgID, project.GetId(), configProperty) }, initialProperty, updatedProperty, "", "", diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 77d77799..91dfc73d 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -3,12 +3,19 @@ package test_utils import ( "context" "fmt" + "os" + "path" + "strings" + "testing" + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclparse" "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zclconf/go-cty/cty" "github.com/zitadel/terraform-provider-zitadel/zitadel" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -52,7 +59,7 @@ KEY `, domain, insecure, port, string(jwtProfileJson)) clientInfo := zitadelProvider.Meta().(*helper.ClientInfo) uniqueID := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha) - terraformName := fmt.Sprintf("%s.%s", resourceType, uniqueID) + terraformName := fmt.Sprintf("%s.default", resourceType) frame := &BaseTestFrame{ Context: ctx, ProviderSnippet: providerSnippet, @@ -77,3 +84,44 @@ KEY func (b *BaseTestFrame) State(state *terraform.State) *terraform.InstanceState { return state.RootModule().Resources[b.TerraformName].Primary } + +type examplesFolder string + +const ( + Datasources examplesFolder = "data-sources" + Resources examplesFolder = "resources" +) + +func (b *BaseTestFrame) ReadExample(t *testing.T, folder examplesFolder, exampleType string) (string, hcl.Attributes) { + fileName := strings.Replace(exampleType, "zitadel_", "", 1) + ".tf" + filePath := path.Join("..", "..", "..", "examples", "provider", string(folder), fileName) + content, err := os.ReadFile(filePath) + if err != nil { + t.Fatalf("error reading example file: %v", err) + } + hclFile, diags := hclparse.NewParser().ParseHCL(content, filePath) + if diags.HasErrors() { + t.Fatalf("error parsing example file: %s", diags.Error()) + } + blocks := hclFile.BlocksAtPos(hcl.Pos{ + Line: 1, + Column: 1, + Byte: 1, + }) + if len(blocks) != 1 { + t.Fatalf("error parsing example file: %s", "unexpected number of blocks") + } + attr, diag := blocks[0].Body.JustAttributes() + if diag.HasErrors() { + t.Fatalf("error parsing example file: %s", diag.Error()) + } + return string(content), attr +} + +func AttributeValue(t *testing.T, key string, attributes hcl.Attributes) cty.Value { + val, diag := attributes[key].Expr.Value(&hcl.EvalContext{}) + if diag.HasErrors() { + t.Fatalf("error parsing example file: %s", diag.Error()) + } + return val +} diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 32196c8e..ce27fbc8 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -2,8 +2,6 @@ package test_utils import ( "fmt" - "os" - "path" "regexp" "strings" "testing" @@ -14,10 +12,9 @@ import ( func RunLifecyleTest[P comparable]( t *testing.T, frame BaseTestFrame, - addedExampleConfig string, - resourceFunc func(initialProperty P, initialSecret string) string, - initialProperty, updatedProperty P, - initialSecret, updatedSecret string, + resourceFunc func(property P, secret string) string, + exampleProperty, updatedProperty P, + exampleSecret, updatedSecret string, allowNonEmptyPlan bool, checkRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, @@ -27,14 +24,9 @@ func RunLifecyleTest[P comparable]( secretAttribute string, ) { var importStateVerifyIgnore []string + exampleConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(exampleProperty, exampleSecret)) + updatedPropertyConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, exampleSecret)) updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) - updatedPropertyConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, initialSecret)) - examplePath := path.Join("..", "..", "..", "examples", "provider", "resources", strings.Replace(frame.ResourceType, "zitadel_", "", 1)+".tf") - rawExampleConfig, err := os.ReadFile(examplePath) - if err != nil { - t.Fatalf("error reading example file: %v", err) - } - exampleConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, addedExampleConfig, string(rawExampleConfig)) steps := []resource.TestStep{ { // Check first plan has a diff Config: exampleConfig, @@ -44,7 +36,7 @@ func RunLifecyleTest[P comparable]( }, { // Check resource is created Config: exampleConfig, Check: resource.ComposeAggregateTestCheckFunc( - CheckAMinute(checkRemoteProperty(initialProperty)), + CheckAMinute(checkRemoteProperty(exampleProperty)), CheckStateHasIDSet(frame, idPattern), ), }, { // Check updating name has a diff diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index 0a33b249..d76a1a07 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -46,8 +46,8 @@ func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { org, err := orgFrame.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: "zitadel." + cfg.Domain}) orgFrame.OrgID = org.GetOrg().GetId() orgFrame.OrgExampleDatasource = fmt.Sprintf(` -data "zitadel_org" "org" { - id = "%s" +data "zitadel_org" "default" { + org_id = "%s" } `, orgFrame.OrgID) return orgFrame, err From ee11f6138c51ebbda450512fc48c5c3c23f68b39 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 11:02:48 +0200 Subject: [PATCH 228/260] use id from org datasource --- zitadel/v2/helper/test_utils/org_frame.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index d76a1a07..380e7613 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -47,7 +47,7 @@ func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { orgFrame.OrgID = org.GetOrg().GetId() orgFrame.OrgExampleDatasource = fmt.Sprintf(` data "zitadel_org" "default" { - org_id = "%s" + id = "%s" } `, orgFrame.OrgID) return orgFrame, err From ee2e7220354522a5ef638ea088a25deba368a32e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 11:05:15 +0200 Subject: [PATCH 229/260] remove import_id.go for now --- zitadel/v2/helper/test_utils/import_id.go | 54 ----------------------- 1 file changed, 54 deletions(-) delete mode 100644 zitadel/v2/helper/test_utils/import_id.go diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/v2/helper/test_utils/import_id.go deleted file mode 100644 index 348c35d8..00000000 --- a/zitadel/v2/helper/test_utils/import_id.go +++ /dev/null @@ -1,54 +0,0 @@ -package test_utils - -import ( - "fmt" - "strings" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -var _ resource.ImportStateIdFunc = ImportNothing - -func ImportResourceId(frame BaseTestFrame) resource.ImportStateIdFunc { - return func(state *terraform.State) (string, error) { - return frame.State(state).ID, nil - } -} - -func ImportOrgId(frame *OrgTestFrame) resource.ImportStateIdFunc { - return func(state *terraform.State) (string, error) { - return frame.OrgID, nil - } -} - -func ImportStateAttribute(frame BaseTestFrame, attr string) resource.ImportStateIdFunc { - return func(state *terraform.State) (string, error) { - primary := frame.State(state) - val, ok := primary.Attributes[attr] - if !ok { - return "", fmt.Errorf("attribute %s not found in attributes %+v", attr, primary.Attributes) - } - return quoteString(val), nil - } -} - -func ImportNothing(_ *terraform.State) (string, error) { return "", nil } - -func ConcatImportStateIdFuncs(funcs ...resource.ImportStateIdFunc) resource.ImportStateIdFunc { - return func(state *terraform.State) (string, error) { - parts := make([]string, len(funcs)) - for i, f := range funcs { - part, err := f(state) - if err != nil { - return "", err - } - parts[i] = part - } - return strings.Join(parts, ":"), nil - } -} - -func quoteString(s string) string { - return fmt.Sprintf(`"%s"`, s) -} From d08bcc18f51248748088bdb5c6cfb53ff4adaa57 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 11:28:27 +0200 Subject: [PATCH 230/260] reference datasources --- docs/resources/application_oidc.md | 4 ++-- docs/resources/domain.md | 2 +- docs/resources/domain_claimed_message_text.md | 2 +- docs/resources/domain_policy.md | 2 +- docs/resources/human_user.md | 2 +- docs/resources/init_message_text.md | 2 +- docs/resources/instance_member.md | 2 +- docs/resources/label_policy.md | 2 +- docs/resources/lockout_policy.md | 2 +- docs/resources/login_policy.md | 2 +- docs/resources/login_texts.md | 2 +- docs/resources/machine_key.md | 4 ++-- docs/resources/machine_user.md | 2 +- docs/resources/notification_policy.md | 2 +- docs/resources/org_idp_azure_ad.md | 2 +- docs/resources/org_idp_github.md | 2 +- docs/resources/org_idp_github_es.md | 2 +- docs/resources/org_idp_gitlab.md | 2 +- docs/resources/org_idp_gitlab_self_hosted.md | 2 +- docs/resources/org_idp_google.md | 2 +- docs/resources/org_idp_jwt.md | 2 +- docs/resources/org_idp_ldap.md | 2 +- docs/resources/org_idp_oidc.md | 2 +- docs/resources/org_member.md | 4 ++-- docs/resources/password_change_message_text.md | 2 +- docs/resources/password_complexity_policy.md | 2 +- docs/resources/password_reset_message_text.md | 2 +- docs/resources/passwordless_registration_message_text.md | 2 +- docs/resources/personal_access_token.md | 4 ++-- docs/resources/privacy_policy.md | 2 +- docs/resources/project.md | 2 +- docs/resources/project_grant.md | 8 ++++---- docs/resources/project_grant_member.md | 8 ++++---- docs/resources/project_member.md | 6 +++--- docs/resources/project_role.md | 4 ++-- docs/resources/trigger_actions.md | 4 ++-- docs/resources/user_grant.md | 6 +++--- docs/resources/verify_email_message_text.md | 2 +- docs/resources/verify_phone_message_text.md | 2 +- examples/provider/resources/application_oidc.tf | 4 ++-- examples/provider/resources/domain.tf | 2 +- .../provider/resources/domain_claimed_message_text.tf | 2 +- examples/provider/resources/domain_policy.tf | 2 +- examples/provider/resources/granted_human_user.tf | 2 +- examples/provider/resources/human_user.tf | 2 +- examples/provider/resources/init_message_text.tf | 2 +- examples/provider/resources/instance_member.tf | 2 +- examples/provider/resources/label_policy.tf | 2 +- examples/provider/resources/lockout_policy.tf | 2 +- examples/provider/resources/login_policy.tf | 2 +- examples/provider/resources/login_texts.tf | 2 +- examples/provider/resources/machine_key.tf | 4 ++-- examples/provider/resources/machine_user.tf | 2 +- examples/provider/resources/notification_policy.tf | 2 +- examples/provider/resources/org_idp_azure_ad.tf | 2 +- examples/provider/resources/org_idp_github.tf | 2 +- examples/provider/resources/org_idp_github_es.tf | 2 +- examples/provider/resources/org_idp_gitlab.tf | 2 +- examples/provider/resources/org_idp_gitlab_self_hosted.tf | 2 +- examples/provider/resources/org_idp_google.tf | 2 +- examples/provider/resources/org_idp_jwt.tf | 2 +- examples/provider/resources/org_idp_ldap.tf | 2 +- examples/provider/resources/org_idp_oidc.tf | 2 +- examples/provider/resources/org_member.tf | 4 ++-- .../provider/resources/password_change_message_text.tf | 2 +- examples/provider/resources/password_complexity_policy.tf | 2 +- .../provider/resources/password_reset_message_text.tf | 2 +- .../resources/passwordless_registration_message_text.tf | 2 +- examples/provider/resources/personal_access_token.tf | 4 ++-- examples/provider/resources/privacy_policy.tf | 2 +- examples/provider/resources/project.tf | 2 +- examples/provider/resources/project_grant.tf | 8 ++++---- examples/provider/resources/project_grant_member.tf | 8 ++++---- examples/provider/resources/project_member.tf | 6 +++--- examples/provider/resources/project_role.tf | 4 ++-- examples/provider/resources/trigger_actions.tf | 4 ++-- examples/provider/resources/user_grant.tf | 6 +++--- examples/provider/resources/verify_email_message_text.tf | 2 +- examples/provider/resources/verify_phone_message_text.tf | 2 +- 79 files changed, 111 insertions(+), 111 deletions(-) diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index d5977e16..d449c4f8 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -13,8 +13,8 @@ Resource representing an OIDC application belonging to a project, with all confi ```terraform resource "zitadel_application_oidc" "default" { - project_id = zitadel_project.default.id - org_id = zitadel_org.default.id + project_id = data.zitadel_project.default.id + org_id = data.zitadel_org.default.id name = "applicationoidc" redirect_uris = ["https://localhost.com"] diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 8e112478..7cf0e1f0 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -13,7 +13,7 @@ Resource representing a domain of the organization. ```terraform resource "zitadel_domain" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } diff --git a/docs/resources/domain_claimed_message_text.md b/docs/resources/domain_claimed_message_text.md index d1258908..9b1fe46e 100644 --- a/docs/resources/domain_claimed_message_text.md +++ b/docs/resources/domain_claimed_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_domain_claimed_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 0293ea99..10496dd6 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -13,7 +13,7 @@ Resource representing the custom domain policy of an organization. ```terraform resource "zitadel_domain_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 28e43f09..ebe55b0e 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -15,7 +15,7 @@ Resource representing a human user situated under an organization, which then ca ```terraform resource "zitadel_human_user" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" diff --git a/docs/resources/init_message_text.md b/docs/resources/init_message_text.md index 0a89f35d..b59ec152 100644 --- a/docs/resources/init_message_text.md +++ b/docs/resources/init_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_init_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index c5fe3eba..8aa957bb 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -13,7 +13,7 @@ Resource representing the membership of a user on an instance, defined with the ```terraform resource "zitadel_instance_member" "default" { - user_id = zitadel_human_user.default.id + user_id = data.zitadel_human_user.default.id roles = ["IAM_OWNER"] } ``` diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index 4ff38d0f..b34a37f5 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -13,7 +13,7 @@ Resource representing the custom label policy of an organization. ```terraform resource "zitadel_label_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index 72c82f77..f79e74cb 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -13,7 +13,7 @@ Resource representing the custom lockout policy of an organization. ```terraform resource "zitadel_lockout_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id max_password_attempts = "5" } ``` diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index d89eaca6..2d233887 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -13,7 +13,7 @@ Resource representing the custom login policy of an organization. ```terraform resource "zitadel_login_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_login = true allow_register = true allow_external_idp = true diff --git a/docs/resources/login_texts.md b/docs/resources/login_texts.md index 52751cba..2cc7f35e 100644 --- a/docs/resources/login_texts.md +++ b/docs/resources/login_texts.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_login_texts" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" email_verification_done_text = { diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index 213ca985..e60ca1e1 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -13,8 +13,8 @@ Resource representing a machine key ```terraform resource "zitadel_machine_key" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_machine_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_machine_user.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index aa411792..ddc6993c 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -13,7 +13,7 @@ Resource representing a serviceaccount situated under an organization, which the ```terraform resource "zitadel_machine_user" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_name = "machine@localhost.com" name = "name" description = "description" diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index c5f6e8c9..085329cc 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -13,7 +13,7 @@ Resource representing the custom notification policy of an organization. ```terraform resource "zitadel_notification_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id password_change = false } ``` diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md index ae4b1de8..c119daef 100644 --- a/docs/resources/org_idp_azure_ad.md +++ b/docs/resources/org_idp_azure_ad.md @@ -13,7 +13,7 @@ Resource representing an Azure AD IdP on the organization. ```terraform resource "zitadel_org_idp_azure_ad" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md index d0aa7ab2..2e6e30a1 100644 --- a/docs/resources/org_idp_github.md +++ b/docs/resources/org_idp_github.md @@ -13,7 +13,7 @@ Resource representing a GitHub IdP on the organization. ```terraform resource "zitadel_org_idp_github" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md index 19e04fdd..3efb5c26 100644 --- a/docs/resources/org_idp_github_es.md +++ b/docs/resources/org_idp_github_es.md @@ -13,7 +13,7 @@ Resource representing a GitHub Enterprise IdP on the organization. ```terraform resource "zitadel_org_idp_github_es" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md index a9017ad0..31da7587 100644 --- a/docs/resources/org_idp_gitlab.md +++ b/docs/resources/org_idp_gitlab.md @@ -13,7 +13,7 @@ Resource representing a GitLab IdP on the organization. ```terraform resource "zitadel_org_idp_gitlab" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md index 0aa396ef..e737bc7f 100644 --- a/docs/resources/org_idp_gitlab_self_hosted.md +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -13,7 +13,7 @@ Resource representing a GitLab Self Hosted IdP on the organization. ```terraform resource "zitadel_org_idp_gitlab_self_hosted" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md index 6dccd31b..14bd6f2b 100644 --- a/docs/resources/org_idp_google.md +++ b/docs/resources/org_idp_google.md @@ -13,7 +13,7 @@ Resource representing a Google IdP on the organization. ```terraform resource "zitadel_org_idp_google" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index e12e1e65..9ff04706 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -13,7 +13,7 @@ Resource representing a generic JWT IdP of the organization. ```terraform resource "zitadel_org_idp_jwt" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" jwt_endpoint = "https://jwtendpoint.com" diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md index 03aa6318..2f3d3271 100644 --- a/docs/resources/org_idp_ldap.md +++ b/docs/resources/org_idp_ldap.md @@ -13,7 +13,7 @@ Resource representing an LDAP IdP on the organization. ```terraform resource "zitadel_org_idp_ldap" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index ca798487..d1cb2371 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -13,7 +13,7 @@ Resource representing a generic OIDC IdP on the organization. ```terraform resource "zitadel_org_idp_oidc" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" client_id = "google" diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 73d13512..ddf2d973 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -13,8 +13,8 @@ Resource representing the membership of a user on an organization, defined with ```terraform resource "zitadel_org_member" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_human_user.default.id roles = ["ORG_OWNER"] } ``` diff --git a/docs/resources/password_change_message_text.md b/docs/resources/password_change_message_text.md index 165b228c..2e0fb514 100644 --- a/docs/resources/password_change_message_text.md +++ b/docs/resources/password_change_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_password_change_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index fd7bb888..d6a2ad12 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -13,7 +13,7 @@ Resource representing the custom password complexity policy of an organization. ```terraform resource "zitadel_password_complexity_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id min_length = "8" has_uppercase = true has_lowercase = true diff --git a/docs/resources/password_reset_message_text.md b/docs/resources/password_reset_message_text.md index 07836566..b5557b39 100644 --- a/docs/resources/password_reset_message_text.md +++ b/docs/resources/password_reset_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_password_reset_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/passwordless_registration_message_text.md b/docs/resources/passwordless_registration_message_text.md index 09a412b2..bad567d5 100644 --- a/docs/resources/passwordless_registration_message_text.md +++ b/docs/resources/passwordless_registration_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_passwordless_registration_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 6cb786c3..1222e72f 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -13,8 +13,8 @@ Resource representing a personal access token of a user ```terraform resource "zitadel_personal_access_token" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_machine_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_machine_user.default.id expiration_date = "2519-04-01T08:45:00Z" } ``` diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 13c1bd43..b3a109a8 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -13,7 +13,7 @@ Resource representing the custom privacy policy of an organization. ```terraform resource "zitadel_privacy_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id tos_link = "https://google.com" privacy_link = "https://google.com" help_link = "https://google.com" diff --git a/docs/resources/project.md b/docs/resources/project.md index 2f5eba6d..756fe601 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -14,7 +14,7 @@ Resource representing the project, which can then be granted to different organi ```terraform resource "zitadel_project" "default" { name = "projectname" - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id project_role_assertion = true project_role_check = true has_project_check = true diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 3190e76e..19abdba5 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -13,10 +13,10 @@ Resource representing the grant of a project to a different organization, also c ```terraform resource "zitadel_project_grant" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - granted_org_id = zitadel_org.default.id - role_keys = [zitadel_project_role.default.role_key] + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + granted_org_id = data.zitadel_org.default.id + role_keys = [data.zitadel_project_role.default.role_key] } ``` diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 8542aec0..fcad58da 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -13,10 +13,10 @@ Resource representing the membership of a user on an granted project, defined wi ```terraform resource "zitadel_project_grant_member" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - grant_id = zitadel_project_grant.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + grant_id = data.zitadel_project_grant.default.id + user_id = data.zitadel_human_user.default.id roles = ["PROJECT_GRANT_OWNER"] } ``` diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index 6f73edcd..3d89d863 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -13,9 +13,9 @@ Resource representing the membership of a user on an project, defined with the g ```terraform resource "zitadel_project_member" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + user_id = data.zitadel_human_user.default.id roles = ["PROJECT_OWNER"] } ``` diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index 31f6678a..eacae021 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -13,8 +13,8 @@ Resource representing the project roles, which can be given as authorizations to ```terraform resource "zitadel_project_role" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id role_key = "key" display_name = "display_name2" group = "role_group" diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index a1028ae2..c78a5765 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -13,10 +13,10 @@ Resource representing triggers, when actions get started ```terraform resource "zitadel_trigger_actions" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" - action_ids = [zitadel_action.default.id] + action_ids = [data.zitadel_action.default.id] } ``` diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index a19779a3..914cb2e8 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -13,10 +13,10 @@ Resource representing the authorization given to a user directly, including the ```terraform resource "zitadel_user_grant" "default" { - project_id = zitadel_project.default.id - org_id = zitadel_org.default.id + project_id = data.zitadel_project.default.id + org_id = data.zitadel_org.default.id role_keys = ["key"] - user_id = zitadel_human_user.default.id + user_id = data.zitadel_human_user.default.id } ``` diff --git a/docs/resources/verify_email_message_text.md b/docs/resources/verify_email_message_text.md index 834a187a..e5339d62 100644 --- a/docs/resources/verify_email_message_text.md +++ b/docs/resources/verify_email_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_verify_email_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/docs/resources/verify_phone_message_text.md b/docs/resources/verify_phone_message_text.md index daf58888..f5a3224e 100644 --- a/docs/resources/verify_phone_message_text.md +++ b/docs/resources/verify_phone_message_text.md @@ -13,7 +13,7 @@ description: |- ```terraform resource "zitadel_verify_phone_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/application_oidc.tf b/examples/provider/resources/application_oidc.tf index 359aed07..462aa5cf 100644 --- a/examples/provider/resources/application_oidc.tf +++ b/examples/provider/resources/application_oidc.tf @@ -1,6 +1,6 @@ resource "zitadel_application_oidc" "default" { - project_id = zitadel_project.default.id - org_id = zitadel_org.default.id + project_id = data.zitadel_project.default.id + org_id = data.zitadel_org.default.id name = "applicationoidc" redirect_uris = ["https://localhost.com"] diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index eed8c9db..c5a35c1d 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,5 +1,5 @@ resource "zitadel_domain" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "zitadel.default.127.0.0.1.sslip.io" is_primary = true } diff --git a/examples/provider/resources/domain_claimed_message_text.tf b/examples/provider/resources/domain_claimed_message_text.tf index 0f15b3e5..8d6c2dfc 100644 --- a/examples/provider/resources/domain_claimed_message_text.tf +++ b/examples/provider/resources/domain_claimed_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_domain_claimed_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index a5f45519..b92c7405 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_domain_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_login_must_be_domain = false validate_org_domains = false smtp_sender_address_matches_instance_domain = false diff --git a/examples/provider/resources/granted_human_user.tf b/examples/provider/resources/granted_human_user.tf index caa2e1f9..ed05633c 100644 --- a/examples/provider/resources/granted_human_user.tf +++ b/examples/provider/resources/granted_human_user.tf @@ -1,5 +1,5 @@ resource "zitadel_human_user" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_name = "human@localhost" first_name = "firstname" last_name = "lastname" diff --git a/examples/provider/resources/human_user.tf b/examples/provider/resources/human_user.tf index b4b16173..ee14509f 100644 --- a/examples/provider/resources/human_user.tf +++ b/examples/provider/resources/human_user.tf @@ -1,5 +1,5 @@ resource "zitadel_human_user" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_name = "humanfull@localhost.com" first_name = "firstname" last_name = "lastname" diff --git a/examples/provider/resources/init_message_text.tf b/examples/provider/resources/init_message_text.tf index 811b442b..56d0ace4 100644 --- a/examples/provider/resources/init_message_text.tf +++ b/examples/provider/resources/init_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_init_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/instance_member.tf b/examples/provider/resources/instance_member.tf index a80d1d30..feddb5dc 100644 --- a/examples/provider/resources/instance_member.tf +++ b/examples/provider/resources/instance_member.tf @@ -1,4 +1,4 @@ resource "zitadel_instance_member" "default" { - user_id = zitadel_human_user.default.id + user_id = data.zitadel_human_user.default.id roles = ["IAM_OWNER"] } diff --git a/examples/provider/resources/label_policy.tf b/examples/provider/resources/label_policy.tf index e614a0b2..345c754d 100644 --- a/examples/provider/resources/label_policy.tf +++ b/examples/provider/resources/label_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_label_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id primary_color = "#5469d4" hide_login_name_suffix = true warn_color = "#cd3d56" diff --git a/examples/provider/resources/lockout_policy.tf b/examples/provider/resources/lockout_policy.tf index 8adfd6ea..3ae8b798 100644 --- a/examples/provider/resources/lockout_policy.tf +++ b/examples/provider/resources/lockout_policy.tf @@ -1,4 +1,4 @@ resource "zitadel_lockout_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id max_password_attempts = "5" } diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index c2df3765..d8b6d42b 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_login_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_login = true allow_register = true allow_external_idp = true diff --git a/examples/provider/resources/login_texts.tf b/examples/provider/resources/login_texts.tf index 04cce210..2e4abecc 100644 --- a/examples/provider/resources/login_texts.tf +++ b/examples/provider/resources/login_texts.tf @@ -1,5 +1,5 @@ resource "zitadel_login_texts" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" email_verification_done_text = { diff --git a/examples/provider/resources/machine_key.tf b/examples/provider/resources/machine_key.tf index 1da5e560..3a229b3e 100644 --- a/examples/provider/resources/machine_key.tf +++ b/examples/provider/resources/machine_key.tf @@ -1,6 +1,6 @@ resource "zitadel_machine_key" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_machine_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_machine_user.default.id key_type = "KEY_TYPE_JSON" expiration_date = "2519-04-01T08:45:00Z" } diff --git a/examples/provider/resources/machine_user.tf b/examples/provider/resources/machine_user.tf index 5edbe8f1..164c9974 100644 --- a/examples/provider/resources/machine_user.tf +++ b/examples/provider/resources/machine_user.tf @@ -1,5 +1,5 @@ resource "zitadel_machine_user" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id user_name = "machine@localhost.com" name = "name" description = "description" diff --git a/examples/provider/resources/notification_policy.tf b/examples/provider/resources/notification_policy.tf index 14278754..5bee21d9 100644 --- a/examples/provider/resources/notification_policy.tf +++ b/examples/provider/resources/notification_policy.tf @@ -1,4 +1,4 @@ resource "zitadel_notification_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id password_change = false } diff --git a/examples/provider/resources/org_idp_azure_ad.tf b/examples/provider/resources/org_idp_azure_ad.tf index 9abcb69b..f6666dbc 100644 --- a/examples/provider/resources/org_idp_azure_ad.tf +++ b/examples/provider/resources/org_idp_azure_ad.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_azure_ad" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "Azure AD" client_id = "9065bfc8-a08a..." client_secret = "H2n***" diff --git a/examples/provider/resources/org_idp_github.tf b/examples/provider/resources/org_idp_github.tf index 698adb85..1261247f 100644 --- a/examples/provider/resources/org_idp_github.tf +++ b/examples/provider/resources/org_idp_github.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_github" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitHub" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/org_idp_github_es.tf b/examples/provider/resources/org_idp_github_es.tf index ed2ffd1f..2243681d 100644 --- a/examples/provider/resources/org_idp_github_es.tf +++ b/examples/provider/resources/org_idp_github_es.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_github_es" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitHub Enterprise Server" client_id = "86a165..." client_secret = "*****afdbac18" diff --git a/examples/provider/resources/org_idp_gitlab.tf b/examples/provider/resources/org_idp_gitlab.tf index dcc1aa87..4f4dcfa8 100644 --- a/examples/provider/resources/org_idp_gitlab.tf +++ b/examples/provider/resources/org_idp_gitlab.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_gitlab" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitLab" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/org_idp_gitlab_self_hosted.tf b/examples/provider/resources/org_idp_gitlab_self_hosted.tf index 68c2a4e7..fc64307e 100644 --- a/examples/provider/resources/org_idp_gitlab_self_hosted.tf +++ b/examples/provider/resources/org_idp_gitlab_self_hosted.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_gitlab_self_hosted" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "GitLab Self Hosted" client_id = "15765e..." client_secret = "*****abcxyz" diff --git a/examples/provider/resources/org_idp_google.tf b/examples/provider/resources/org_idp_google.tf index e3d8352c..1d01eec1 100644 --- a/examples/provider/resources/org_idp_google.tf +++ b/examples/provider/resources/org_idp_google.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_google" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "Google" client_id = "182902..." client_secret = "GOCSPX-*****" diff --git a/examples/provider/resources/org_idp_jwt.tf b/examples/provider/resources/org_idp_jwt.tf index ba9c7acf..1a943779 100644 --- a/examples/provider/resources/org_idp_jwt.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_jwt" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" jwt_endpoint = "https://jwtendpoint.com" diff --git a/examples/provider/resources/org_idp_ldap.tf b/examples/provider/resources/org_idp_ldap.tf index aa65b544..b9bc16c9 100644 --- a/examples/provider/resources/org_idp_ldap.tf +++ b/examples/provider/resources/org_idp_ldap.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_ldap" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "LDAP" servers = ["ldaps://my.primary.server:389", "ldaps://my.secondary.server:389"] start_tls = false diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index 6db2e95d..24c531ea 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,5 +1,5 @@ resource "zitadel_org_idp_oidc" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" client_id = "google" diff --git a/examples/provider/resources/org_member.tf b/examples/provider/resources/org_member.tf index 653a1963..a182fba0 100644 --- a/examples/provider/resources/org_member.tf +++ b/examples/provider/resources/org_member.tf @@ -1,5 +1,5 @@ resource "zitadel_org_member" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_human_user.default.id roles = ["ORG_OWNER"] } diff --git a/examples/provider/resources/password_change_message_text.tf b/examples/provider/resources/password_change_message_text.tf index eff3fc5f..df5dff82 100644 --- a/examples/provider/resources/password_change_message_text.tf +++ b/examples/provider/resources/password_change_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_password_change_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/password_complexity_policy.tf b/examples/provider/resources/password_complexity_policy.tf index 4661de1e..338421a0 100644 --- a/examples/provider/resources/password_complexity_policy.tf +++ b/examples/provider/resources/password_complexity_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_password_complexity_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id min_length = "8" has_uppercase = true has_lowercase = true diff --git a/examples/provider/resources/password_reset_message_text.tf b/examples/provider/resources/password_reset_message_text.tf index 871352ec..07fc2cc8 100644 --- a/examples/provider/resources/password_reset_message_text.tf +++ b/examples/provider/resources/password_reset_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_password_reset_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/passwordless_registration_message_text.tf b/examples/provider/resources/passwordless_registration_message_text.tf index d51af5df..ae83714b 100644 --- a/examples/provider/resources/passwordless_registration_message_text.tf +++ b/examples/provider/resources/passwordless_registration_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_passwordless_registration_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/personal_access_token.tf b/examples/provider/resources/personal_access_token.tf index a0fede92..9ad2cc65 100644 --- a/examples/provider/resources/personal_access_token.tf +++ b/examples/provider/resources/personal_access_token.tf @@ -1,5 +1,5 @@ resource "zitadel_personal_access_token" "default" { - org_id = zitadel_org.default.id - user_id = zitadel_machine_user.default.id + org_id = data.zitadel_org.default.id + user_id = data.zitadel_machine_user.default.id expiration_date = "2519-04-01T08:45:00Z" } diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index ccc61f9b..c83dbf92 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_privacy_policy" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id tos_link = "https://google.com" privacy_link = "https://google.com" help_link = "https://google.com" diff --git a/examples/provider/resources/project.tf b/examples/provider/resources/project.tf index 77a0bc5c..b3a1eb46 100644 --- a/examples/provider/resources/project.tf +++ b/examples/provider/resources/project.tf @@ -1,6 +1,6 @@ resource "zitadel_project" "default" { name = "projectname" - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id project_role_assertion = true project_role_check = true has_project_check = true diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 1bd0123e..6ef73acd 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,6 +1,6 @@ resource "zitadel_project_grant" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - granted_org_id = zitadel_org.default.id - role_keys = [zitadel_project_role.default.role_key] + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + granted_org_id = data.zitadel_org.default.id + role_keys = [data.zitadel_project_role.default.role_key] } diff --git a/examples/provider/resources/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf index 09dd4e35..de5d4b35 100644 --- a/examples/provider/resources/project_grant_member.tf +++ b/examples/provider/resources/project_grant_member.tf @@ -1,7 +1,7 @@ resource "zitadel_project_grant_member" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - grant_id = zitadel_project_grant.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + grant_id = data.zitadel_project_grant.default.id + user_id = data.zitadel_human_user.default.id roles = ["PROJECT_GRANT_OWNER"] } diff --git a/examples/provider/resources/project_member.tf b/examples/provider/resources/project_member.tf index 8d647293..61436cc6 100644 --- a/examples/provider/resources/project_member.tf +++ b/examples/provider/resources/project_member.tf @@ -1,6 +1,6 @@ resource "zitadel_project_member" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id - user_id = zitadel_human_user.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id + user_id = data.zitadel_human_user.default.id roles = ["PROJECT_OWNER"] } diff --git a/examples/provider/resources/project_role.tf b/examples/provider/resources/project_role.tf index 61081cd6..1e21104e 100644 --- a/examples/provider/resources/project_role.tf +++ b/examples/provider/resources/project_role.tf @@ -1,6 +1,6 @@ resource "zitadel_project_role" "default" { - org_id = zitadel_org.default.id - project_id = zitadel_project.default.id + org_id = data.zitadel_org.default.id + project_id = data.zitadel_project.default.id role_key = "key" display_name = "display_name2" group = "role_group" diff --git a/examples/provider/resources/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf index 27647eae..85120e41 100644 --- a/examples/provider/resources/trigger_actions.tf +++ b/examples/provider/resources/trigger_actions.tf @@ -1,6 +1,6 @@ resource "zitadel_trigger_actions" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" - action_ids = [zitadel_action.default.id] + action_ids = [data.zitadel_action.default.id] } diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 7a82ec32..380175ad 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,6 +1,6 @@ resource "zitadel_user_grant" "default" { - project_id = zitadel_project.default.id - org_id = zitadel_org.default.id + project_id = data.zitadel_project.default.id + org_id = data.zitadel_org.default.id role_keys = ["key"] - user_id = zitadel_human_user.default.id + user_id = data.zitadel_human_user.default.id } diff --git a/examples/provider/resources/verify_email_message_text.tf b/examples/provider/resources/verify_email_message_text.tf index 957aa901..b85837a3 100644 --- a/examples/provider/resources/verify_email_message_text.tf +++ b/examples/provider/resources/verify_email_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_verify_email_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" diff --git a/examples/provider/resources/verify_phone_message_text.tf b/examples/provider/resources/verify_phone_message_text.tf index 8216cc9a..379d8ed4 100644 --- a/examples/provider/resources/verify_phone_message_text.tf +++ b/examples/provider/resources/verify_phone_message_text.tf @@ -1,5 +1,5 @@ resource "zitadel_verify_phone_message_text" "default" { - org_id = zitadel_org.default.id + org_id = data.zitadel_org.default.id language = "en" title = "title example" From b905c48376f0d9b4ed6610b22455b8758fae5bc1 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 11:34:56 +0200 Subject: [PATCH 231/260] use const example resource id --- zitadel/v2/action/resource_test.go | 1 + zitadel/v2/app_key/resource_test.go | 8 ++--- zitadel/v2/application_api/resource_test.go | 19 +++++------- zitadel/v2/application_oidc/resource_test.go | 31 +++++-------------- .../resource_test.go | 21 ++++--------- zitadel/v2/helper/test_utils/base_frame.go | 5 +-- 6 files changed, 30 insertions(+), 55 deletions(-) diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 6ae4c9c5..be6ab397 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -19,6 +19,7 @@ func TestAccAction(t *testing.T) { t.Fatalf("setting up test context failed: %v", err) } resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + // name must be unique nameAttribute := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() resourceExample = strings.Replace(resourceExample, nameAttribute, frame.UniqueResourcesID, 1) exampleProperty := test_utils.AttributeValue(t, "script", exampleAttributes).AsString() diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index c66456d6..8aa5f657 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -31,12 +31,12 @@ func TestAccAppKey(t *testing.T) { AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, }) resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) - projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, "123456789012345678", project.GetId(), 1) - appDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "application_api") - appDatasourceExample = strings.Replace(appDatasourceExample, "123456789012345678", apiApp.GetAppId(), 1) exampleProperty := test_utils.AttributeValue(t, "expiration_date", exampleAttributes).AsString() updatedProperty := "2501-01-01T08:45:00Z" + projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) + appDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "application_api") + appDatasourceExample = strings.Replace(appDatasourceExample, test_utils.ResourceID, apiApp.GetAppId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 47c3a6f4..fb6990b3 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -2,6 +2,7 @@ package application_api_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -13,8 +14,6 @@ import ( func TestAccAppAPI(t *testing.T) { resourceName := "zitadel_application_api" - initialProperty := "initialname" - updatedProperty := "updatedname" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) @@ -25,20 +24,18 @@ func TestAccAppAPI(t *testing.T) { if err != nil { t.Fatalf("failed to create project: %v", err) } + resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() + updatedProperty := "updatedproperty" + projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, - frame.OrgExampleDatasource, func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "my_%s" { - org_id = "%s" - project_id = "%s" - name = "%s" - auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" -}`, resourceName, resourceName, frame.OrgID, project.GetId(), configProperty) + return fmt.Sprintf("%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(frame, project.GetId()), diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index d8cc32f0..56dad70d 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -2,6 +2,7 @@ package application_oidc_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -13,8 +14,6 @@ import ( func TestAccAppOIDC(t *testing.T) { resourceName := "zitadel_application_oidc" - initialProperty := "initialname" - updatedProperty := "updatedname" frame, err := test_utils.NewOrgTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) @@ -25,32 +24,18 @@ func TestAccAppOIDC(t *testing.T) { if err != nil { t.Fatalf("failed to create project: %v", err) } + resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() + updatedProperty := "updatedproperty" + projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - name = "%s" - redirect_uris = ["https://localhost.com"] - response_types = ["OIDC_RESPONSE_TYPE_CODE"] - grant_types = ["OIDC_GRANT_TYPE_AUTHORIZATION_CODE"] - post_logout_redirect_uris = ["https://localhost.com"] - app_type = "OIDC_APP_TYPE_WEB" - auth_method_type = "OIDC_AUTH_METHOD_TYPE_BASIC" - version = "OIDC_VERSION_1_0" - clock_skew = "0s" - dev_mode = true - access_token_type = "OIDC_TOKEN_TYPE_BEARER" - access_token_role_assertion = false - id_token_role_assertion = false - id_token_userinfo_assertion = false - additional_origins = [] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, project.GetId(), configProperty) + return fmt.Sprintf("%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(frame, project.GetId()), diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index 78f797bb..edbefbeb 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -3,6 +3,7 @@ package default_domain_claimed_message_text_test import ( "fmt" "regexp" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -14,31 +15,21 @@ import ( func TestAccDefaultDomainClaimedMessageText(t *testing.T) { resourceName := "zitadel_default_domain_claimed_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" language := "en" frame, err := test_utils.NewInstanceTestFrame(resourceName) if err != nil { t.Fatalf("setting up test context failed: %v", err) } + resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + updatedProperty := "updatedtitle" test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) + return strings.Replace(resourceExample, exampleProperty, configProperty, 1) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", true, checkRemoteProperty(frame, language), diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 5546007e..166d1561 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -22,8 +22,9 @@ import ( ) const ( - insecure = true - port = "8080" + insecure = true + port = "8080" + ResourceID = "123456789012345678" ) type BaseTestFrame struct { From b0edbbe62d2c3c69c8ac78118392d661ba26bb6f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 11:35:30 +0200 Subject: [PATCH 232/260] use const example resource id --- zitadel/v2/app_key/resource_test.go | 4 ++-- zitadel/v2/application_api/resource_test.go | 2 +- zitadel/v2/application_oidc/resource_test.go | 2 +- zitadel/v2/helper/test_utils/base_frame.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 8aa5f657..836c1603 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -34,9 +34,9 @@ func TestAccAppKey(t *testing.T) { exampleProperty := test_utils.AttributeValue(t, "expiration_date", exampleAttributes).AsString() updatedProperty := "2501-01-01T08:45:00Z" projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) appDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "application_api") - appDatasourceExample = strings.Replace(appDatasourceExample, test_utils.ResourceID, apiApp.GetAppId(), 1) + appDatasourceExample = strings.Replace(appDatasourceExample, test_utils.ExamplesResourceID, apiApp.GetAppId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index fb6990b3..77c514bf 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -28,7 +28,7 @@ func TestAccAppAPI(t *testing.T) { exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() updatedProperty := "updatedproperty" projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 56dad70d..45415ef5 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -28,7 +28,7 @@ func TestAccAppOIDC(t *testing.T) { exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() updatedProperty := "updatedproperty" projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ResourceID, project.GetId(), 1) + projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) test_utils.RunLifecyleTest[string]( t, frame.BaseTestFrame, diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 166d1561..8c280099 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -22,9 +22,9 @@ import ( ) const ( - insecure = true - port = "8080" - ResourceID = "123456789012345678" + insecure = true + port = "8080" + ExamplesResourceID = "123456789012345678" ) type BaseTestFrame struct { From cf3b209e8ba340613abacb863ae76026ffe7b952 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Fri, 18 Aug 2023 15:24:52 +0200 Subject: [PATCH 233/260] fix: new zitadel-go version and boolean for forced MFA local only --- docs/resources/default_login_policy.md | 2 + docs/resources/login_policy.md | 2 + .../resources/default_login_policy.tf | 1 + examples/provider/resources/login_policy.tf | 1 + go.mod | 26 +++++---- go.sum | 58 ++++++++++--------- zitadel/v2/login_policy/funcs.go | 4 +- 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index ec7aaac5..578b60c3 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -17,6 +17,7 @@ resource zitadel_default_login_policy login_policy { allow_register = true allow_external_idp = true force_mfa = false + force_mfa_local_only = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" @@ -44,6 +45,7 @@ resource zitadel_default_login_policy login_policy { - `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in +- `force_mfa_local_only` (Boolean) if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login. - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 304a7233..1959d149 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -18,6 +18,7 @@ resource zitadel_login_policy login_policy { allow_register = true allow_external_idp = true force_mfa = false + force_mfa_local_only = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" @@ -46,6 +47,7 @@ resource zitadel_login_policy login_policy { - `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in +- `force_mfa_local_only` (Boolean) if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login. - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index 43796d7c..9b38264f 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -3,6 +3,7 @@ resource zitadel_default_login_policy login_policy { allow_register = true allow_external_idp = true force_mfa = false + force_mfa_local_only = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index f2470880..c809d9e0 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -4,6 +4,7 @@ resource zitadel_login_policy login_policy { allow_register = true allow_external_idp = true force_mfa = false + force_mfa_local_only = false passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" hide_password_reset = "false" password_check_lifetime = "240h0m0s" diff --git a/go.mod b/go.mod index da35549e..db1ebddf 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/zitadel/terraform-provider-zitadel go 1.19 require ( - github.com/envoyproxy/protoc-gen-validate v1.0.1 + github.com/envoyproxy/protoc-gen-validate v1.0.2 github.com/gabriel-vasile/mimetype v1.4.1 github.com/gogo/protobuf v1.3.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-framework v0.15.0 @@ -15,10 +15,10 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 github.com/zitadel/oidc v1.13.4 - github.com/zitadel/zitadel-go/v2 v2.0.14 - golang.org/x/oauth2 v0.8.0 - google.golang.org/grpc v1.53.0 - google.golang.org/protobuf v1.30.0 + github.com/zitadel/zitadel-go/v2 v2.0.15 + golang.org/x/oauth2 v0.10.0 + google.golang.org/grpc v1.57.0-dev + google.golang.org/protobuf v1.31.0 ) require ( @@ -71,12 +71,14 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.13.1 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/crypto v0.11.0 // indirect + golang.org/x/mod v0.11.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect + google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index ace72bfb..f76773ee 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,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/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/protoc-gen-validate v1.0.1 h1:kt9FtLiooDc0vbwTLhdg3dyNX1K9Qwa1EK9LcD4jVUQ= -github.com/envoyproxy/protoc-gen-validate v1.0.1/go.mod h1:0vj8bNkYbSTNS2PIyH87KZaeN4x9zpL9Qt8fQC7d+vs= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -54,7 +54,7 @@ github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -75,8 +75,8 @@ github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -147,7 +147,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -229,8 +229,8 @@ github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zitadel/oidc v1.13.4 h1:+k2GKqP9Ld9S2MSFlj+KaNsoZ3J9oy+Ezw51EzSFuC8= github.com/zitadel/oidc v1.13.4/go.mod h1:3h2DhUcP02YV6q/CA/BG4yla0o6rXjK+DkJGK/dwJfw= -github.com/zitadel/zitadel-go/v2 v2.0.14 h1:+Gp+cb1Qrp752oQnnoetPeTciK0gnEuoygK+S7sRuUM= -github.com/zitadel/zitadel-go/v2 v2.0.14/go.mod h1:apPFRGKTMDAtB2qdC9ELXco/HwyvfS87vD29lfhMRF0= +github.com/zitadel/zitadel-go/v2 v2.0.15 h1:dL2VROG7w32xtdl2DlPqpef6+s7PEP70KEa3SEjGsuI= +github.com/zitadel/zitadel-go/v2 v2.0.15/go.mod h1:2xpHigKocm9hVdNuAHo9eway/jGSo6XhyunbfGr7924= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -241,14 +241,14 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/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-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -265,11 +265,11 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -297,19 +297,19 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.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/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.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.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -324,14 +324,18 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 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-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= -google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e h1:Ao9GzfUMPH3zjVfzXG5rlWlk+Q8MXWKwWpwVQE1MXfw= +google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529 h1:DEH99RbiLZhMxrpEJCZ0A+wdTe0EOgou/poSLx9vWf4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/grpc v1.57.0-dev h1:XCvzqke2TBzQUs3a1MO1VsqVkWeAdJ/KmxHCAVtPpe8= +google.golang.org/grpc v1.57.0-dev/go.mod h1:ZPf89/axrdgRDfHqb7fa0GF5t4VUER0vWnqnPNuRP7k= 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 26def736..b4ac7097 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -106,7 +106,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), - ForceMFALocalOnly: d.Get(forceMFALocalOnlyVar).(bool), + ForceMfaLocalOnly: d.Get(forceMFALocalOnlyVar).(bool), }) if err != nil { return diag.Errorf("failed to update login policy: %v", err) @@ -242,7 +242,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia AllowDomainDiscovery: d.Get(allowDomainDiscovery).(bool), DisableLoginWithEmail: d.Get(disableLoginWithEmail).(bool), DisableLoginWithPhone: d.Get(disableLoginWithPhone).(bool), - ForceMFALocalOnly: d.Get(forceMFALocalOnlyVar).(bool), + ForceMfaLocalOnly: d.Get(forceMFALocalOnlyVar).(bool), }) if err != nil { return diag.Errorf("failed to create login policy: %v", err) From b168c14c824e487463bbac43edf14c8182cbced2 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Fri, 18 Aug 2023 15:26:34 +0200 Subject: [PATCH 234/260] use mux provider with upgraded v5 --- zitadel/v2/helper/test_utils/base_frame.go | 32 ++++++++++++------- .../v2/helper/test_utils/datasourcetest.go | 1 - zitadel/v2/helper/test_utils/lifecyletest.go | 8 ++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 8c280099..1faf96cc 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -13,6 +13,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zclconf/go-cty/cty" @@ -34,7 +36,6 @@ type BaseTestFrame struct { ResourceType string TerraformName string v6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error) - v5ProviderFactories map[string]func() (tfprotov5.ProviderServer, error) } func NewBaseTestFrame(ctx context.Context, resourceType, domain string, jwtProfileJson []byte) (*BaseTestFrame, error) { @@ -69,16 +70,25 @@ KEY TerraformName: terraformName, ResourceType: resourceType, } - _, v5Resource := zitadelProvider.ResourcesMap[resourceType] - _, v5Datasource := zitadelProvider.DataSourcesMap[resourceType] - if v5Resource || v5Datasource { - frame.v5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){"zitadel": func() (tfprotov5.ProviderServer, error) { - return zitadelProvider.GRPCProvider(), nil - }} - } else { - frame.v6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){"zitadel": func() (tfprotov6.ProviderServer, error) { - return providerserver.NewProtocol6(zitadel.NewProviderPV6())(), nil - }} + frame.v6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ + "zitadel": func() (tfprotov6.ProviderServer, error) { + muxServer, err := tf6muxserver.NewMuxServer(frame, + providerserver.NewProtocol6(zitadel.NewProviderPV6()), + func() tfprotov6.ProviderServer { + upgraded, err := tf5to6server.UpgradeServer(frame, func() tfprotov5.ProviderServer { + return zitadelProvider.GRPCProvider() + }) + if err != nil { + return nil + } + return upgraded + }, + ) + if err != nil { + return nil, err + } + return muxServer.ProviderServer(), nil + }, } return frame, nil } diff --git a/zitadel/v2/helper/test_utils/datasourcetest.go b/zitadel/v2/helper/test_utils/datasourcetest.go index 961c322c..be356fc0 100644 --- a/zitadel/v2/helper/test_utils/datasourcetest.go +++ b/zitadel/v2/helper/test_utils/datasourcetest.go @@ -27,6 +27,5 @@ func RunDatasourceTest( Check: resource.ComposeAggregateTestCheckFunc(checks...), }}, ProtoV6ProviderFactories: frame.v6ProviderFactories, - ProtoV5ProviderFactories: frame.v5ProviderFactories, }) } diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index ce27fbc8..4d0b41da 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -12,6 +12,7 @@ import ( func RunLifecyleTest[P comparable]( t *testing.T, frame BaseTestFrame, + datasources []string, resourceFunc func(property P, secret string) string, exampleProperty, updatedProperty P, exampleSecret, updatedSecret string, @@ -24,9 +25,9 @@ func RunLifecyleTest[P comparable]( secretAttribute string, ) { var importStateVerifyIgnore []string - exampleConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(exampleProperty, exampleSecret)) - updatedPropertyConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, exampleSecret)) - updatedSecretConfig := fmt.Sprintf("%s\n%s", frame.ProviderSnippet, resourceFunc(updatedProperty, updatedSecret)) + exampleConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(exampleProperty, exampleSecret)) + updatedPropertyConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(updatedProperty, exampleSecret)) + updatedSecretConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(updatedProperty, updatedSecret)) steps := []resource.TestStep{ { // Check first plan has a diff Config: exampleConfig, @@ -89,6 +90,5 @@ func RunLifecyleTest[P comparable]( return err }, ProtoV6ProviderFactories: frame.v6ProviderFactories, - ProtoV5ProviderFactories: frame.v5ProviderFactories, }) } From c942bac2796b8a8d67ad407f4271895899a5ec09 Mon Sep 17 00:00:00 2001 From: Stefan Benz <46600784+stebenz@users.noreply.github.com> Date: Mon, 21 Aug 2023 14:29:42 +0200 Subject: [PATCH 235/260] fix: update zitadel/v2/default_login_policy/resource.go Co-authored-by: Elio Bischof --- zitadel/v2/default_login_policy/resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 1d1faed7..b500835c 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -31,7 +31,7 @@ func GetResource() *schema.Resource { forceMFALocalOnlyVar: { Type: schema.TypeBool, Required: true, - Description: "if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login.", + Description: "if activated, ZITADEL only enforces MFA on local authentications. On authentications through MFA, ZITADEL won't prompt for MFA.", }, passwordlessTypeVar: { Type: schema.TypeString, From 6086e7346334f1b5d6d980726397f7e213f9902e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 21 Aug 2023 16:42:56 +0200 Subject: [PATCH 236/260] test examples --- examples/provider/data-sources/org.tf | 2 +- examples/provider/data-sources/orgs.tf | 18 + .../resources/default_domain_policy.tf | 4 +- .../resources/default_login_policy.tf | 1 + .../resources/default_privacy_policy.tf | 8 +- examples/provider/resources/domain.tf | 2 +- examples/provider/resources/domain_policy.tf | 4 +- examples/provider/resources/login_policy.tf | 2 +- examples/provider/resources/machine_user.tf | 4 +- examples/provider/resources/org_idp_jwt.tf | 2 +- examples/provider/resources/privacy_policy.tf | 8 +- examples/provider/resources/project_grant.tf | 4 +- .../resources/project_grant_member.tf | 2 +- examples/provider/resources/project_role.tf | 2 +- .../provider/resources/sms_provider_twilio.tf | 2 +- examples/provider/resources/smtp_config.tf | 4 +- .../provider/resources/trigger_actions.tf | 4 +- examples/provider/resources/user_grant.tf | 2 +- .../v2/action/action_test_dep/dependency.go | 24 ++ zitadel/v2/action/const.go | 6 +- zitadel/v2/action/datasource.go | 6 +- zitadel/v2/action/funcs.go | 14 +- zitadel/v2/action/resource.go | 4 +- zitadel/v2/action/resource_test.go | 25 +- zitadel/v2/app_key/const.go | 2 +- zitadel/v2/app_key/funcs.go | 4 +- zitadel/v2/app_key/resource.go | 2 +- zitadel/v2/app_key/resource_test.go | 43 +-- .../application_api_test_dep/dependency.go | 22 ++ zitadel/v2/application_api/const.go | 4 +- zitadel/v2/application_api/datasource.go | 4 +- zitadel/v2/application_api/funcs.go | 10 +- zitadel/v2/application_api/resource.go | 2 +- zitadel/v2/application_api/resource_test.go | 36 +- zitadel/v2/application_oidc/const.go | 2 +- zitadel/v2/application_oidc/datasource.go | 2 +- zitadel/v2/application_oidc/funcs.go | 8 +- zitadel/v2/application_oidc/resource.go | 2 +- zitadel/v2/application_oidc/resource_test.go | 36 +- .../resource.go | 8 +- .../resource_test.go | 28 +- zitadel/v2/default_domain_policy/const.go | 2 +- zitadel/v2/default_domain_policy/funcs.go | 6 +- zitadel/v2/default_domain_policy/resource.go | 2 +- .../v2/default_domain_policy/resource_test.go | 28 +- .../v2/default_init_message_text/resource.go | 8 +- .../resource_test.go | 35 +- zitadel/v2/default_label_policy/const.go | 2 +- zitadel/v2/default_label_policy/funcs.go | 8 +- zitadel/v2/default_label_policy/resource.go | 2 +- .../v2/default_label_policy/resource_test.go | 75 ++-- zitadel/v2/default_lockout_policy/const.go | 2 +- zitadel/v2/default_lockout_policy/funcs.go | 6 +- zitadel/v2/default_lockout_policy/resource.go | 2 +- .../default_lockout_policy/resource_test.go | 23 +- zitadel/v2/default_login_policy/const.go | 2 +- zitadel/v2/default_login_policy/funcs.go | 6 +- zitadel/v2/default_login_policy/resource.go | 2 +- .../v2/default_login_policy/resource_test.go | 52 +-- zitadel/v2/default_login_texts/resource.go | 8 +- .../v2/default_login_texts/resource_test.go | 318 +---------------- .../resource_test.go | 18 +- zitadel/v2/default_oidc_settings/const.go | 2 +- .../v2/default_oidc_settings/datasource.go | 2 +- zitadel/v2/default_oidc_settings/funcs.go | 4 +- zitadel/v2/default_oidc_settings/resource.go | 2 +- .../v2/default_oidc_settings/resource_test.go | 28 +- .../resource.go | 8 +- .../resource_test.go | 39 +-- .../const.go | 2 +- .../funcs.go | 6 +- .../resource.go | 2 +- .../resource_test.go | 35 +- .../resource.go | 8 +- .../resource_test.go | 39 +-- .../resource.go | 8 +- .../resource_test.go | 39 +-- zitadel/v2/default_privacy_policy/const.go | 2 +- zitadel/v2/default_privacy_policy/funcs.go | 6 +- zitadel/v2/default_privacy_policy/resource.go | 2 +- .../default_privacy_policy/resource_test.go | 26 +- .../resource.go | 8 +- .../resource_test.go | 39 +-- .../resource.go | 8 +- .../resource_test.go | 39 +-- zitadel/v2/domain/const.go | 2 +- zitadel/v2/domain/funcs.go | 6 +- zitadel/v2/domain/resource.go | 2 +- zitadel/v2/domain/resource_test.go | 26 +- .../domain_claimed_message_text/resource.go | 10 +- .../resource_test.go | 42 +-- zitadel/v2/domain_policy/const.go | 2 +- zitadel/v2/domain_policy/funcs.go | 6 +- zitadel/v2/domain_policy/resource.go | 2 +- zitadel/v2/domain_policy/resource_test.go | 36 +- zitadel/v2/helper/test_utils/base_frame.go | 50 +-- zitadel/v2/helper/test_utils/dependency.go | 15 + zitadel/v2/helper/test_utils/example.go | 64 ++++ .../v2/helper/test_utils/instance_frame.go | 9 +- zitadel/v2/helper/test_utils/org_frame.go | 31 +- zitadel/v2/human_user/const.go | 6 +- zitadel/v2/human_user/datasource.go | 6 +- zitadel/v2/human_user/funcs.go | 20 +- .../human_user_test_dep/dependency.go | 27 ++ zitadel/v2/human_user/resource.go | 8 +- zitadel/v2/human_user/resource_test.go | 41 +-- .../idp_azure_ad_test_dep/dependency.go | 27 ++ zitadel/v2/idp_azure_ad/resource_test.go | 23 +- zitadel/v2/idp_github/resource_test.go | 21 +- zitadel/v2/idp_github_es/resource_test.go | 24 +- zitadel/v2/idp_gitlab/resource_test.go | 21 +- .../idp_gitlab_self_hosted/resource_test.go | 22 +- .../idp_google_test_dep/dependency.go | 21 ++ zitadel/v2/idp_google/resource_test.go | 21 +- zitadel/v2/idp_ldap/resource_test.go | 30 +- zitadel/v2/idp_utils/idp_test_utils/checks.go | 12 +- .../idp_utils/idp_test_utils/lifecyletest.go | 29 +- zitadel/v2/init_message_text/resource.go | 10 +- zitadel/v2/init_message_text/resource_test.go | 40 +-- zitadel/v2/instance_member/const.go | 2 +- zitadel/v2/instance_member/funcs.go | 6 +- zitadel/v2/instance_member/resource.go | 2 +- zitadel/v2/instance_member/resource_test.go | 42 +-- zitadel/v2/label_policy/resource_test.go | 77 +++-- zitadel/v2/lockout_policy/resource_test.go | 25 +- zitadel/v2/login_policy/const.go | 2 +- zitadel/v2/login_policy/funcs.go | 8 +- zitadel/v2/login_policy/resource.go | 2 +- zitadel/v2/login_policy/resource_test.go | 55 +-- zitadel/v2/login_texts/resource.go | 10 +- zitadel/v2/login_texts/resource_test.go | 319 +----------------- zitadel/v2/machine_key/const.go | 2 +- zitadel/v2/machine_key/funcs.go | 4 +- zitadel/v2/machine_key/resource.go | 2 +- zitadel/v2/machine_key/resource_test.go | 36 +- zitadel/v2/machine_user/const.go | 11 +- zitadel/v2/machine_user/datasource.go | 6 +- zitadel/v2/machine_user/funcs.go | 18 +- .../machine_user_test_dep/dependency.go | 21 ++ zitadel/v2/machine_user/resource.go | 4 +- zitadel/v2/machine_user/resource_test.go | 33 +- .../v2/notification_policy/resource_test.go | 19 +- zitadel/v2/org/const.go | 6 +- zitadel/v2/org/datasource.go | 8 +- zitadel/v2/org/datasource_test.go | 80 ++--- zitadel/v2/org/funcs.go | 12 +- zitadel/v2/org/org_test_dep/dependency.go | 18 + zitadel/v2/org/remote_test.go | 4 +- zitadel/v2/org/resource.go | 2 +- zitadel/v2/org/resource_test.go | 32 +- zitadel/v2/org_idp_azure_ad/resource_test.go | 24 +- zitadel/v2/org_idp_github/resource_test.go | 22 +- zitadel/v2/org_idp_github_es/resource_test.go | 25 +- zitadel/v2/org_idp_gitlab/resource_test.go | 22 +- .../resource_test.go | 23 +- .../org_idp_google_test_dep/dependency.go | 20 ++ zitadel/v2/org_idp_google/resource_test.go | 22 +- zitadel/v2/org_idp_jwt/const.go | 2 +- zitadel/v2/org_idp_jwt/datasource.go | 2 +- zitadel/v2/org_idp_jwt/funcs.go | 8 +- zitadel/v2/org_idp_jwt/resource.go | 2 +- zitadel/v2/org_idp_jwt/resource_test.go | 48 ++- zitadel/v2/org_idp_ldap/resource_test.go | 32 +- zitadel/v2/org_idp_oidc/const.go | 2 +- zitadel/v2/org_idp_oidc/datasource.go | 2 +- zitadel/v2/org_idp_oidc/funcs.go | 8 +- zitadel/v2/org_idp_oidc/resource.go | 2 +- zitadel/v2/org_idp_oidc/resource_test.go | 66 ++-- .../org_idp_test_utils/checks.go | 12 +- .../org_idp_test_utils/lifecyletest.go | 29 +- zitadel/v2/org_member/const.go | 2 +- zitadel/v2/org_member/funcs.go | 6 +- zitadel/v2/org_member/resource.go | 2 +- zitadel/v2/org_member/resource_test.go | 41 +-- .../password_change_message_text/resource.go | 10 +- .../resource_test.go | 39 +-- .../resource_test.go | 38 +-- .../password_reset_message_text/resource.go | 10 +- .../resource_test.go | 39 +-- .../resource.go | 10 +- .../resource_test.go | 39 +-- zitadel/v2/pat/const.go | 2 +- zitadel/v2/pat/funcs.go | 4 +- zitadel/v2/pat/resource.go | 2 +- zitadel/v2/pat/resource_test.go | 34 +- zitadel/v2/privacy_policy/const.go | 2 +- zitadel/v2/privacy_policy/funcs.go | 6 +- zitadel/v2/privacy_policy/resource.go | 2 +- zitadel/v2/privacy_policy/resource_test.go | 27 +- zitadel/v2/project/const.go | 4 +- zitadel/v2/project/datasource.go | 4 +- zitadel/v2/project/funcs.go | 8 +- .../v2/project/project_test_dep/dependency.go | 17 + zitadel/v2/project/resource.go | 2 +- zitadel/v2/project/resource_test.go | 27 +- zitadel/v2/project_grant/const.go | 2 +- zitadel/v2/project_grant/funcs.go | 6 +- .../project_grant_test_dep/dependency.go | 20 ++ zitadel/v2/project_grant/resource.go | 2 +- zitadel/v2/project_grant/resource_test.go | 57 +--- zitadel/v2/project_grant_member/const.go | 4 +- zitadel/v2/project_grant_member/funcs.go | 16 +- zitadel/v2/project_grant_member/resource.go | 4 +- .../v2/project_grant_member/resource_test.go | 78 ++--- zitadel/v2/project_member/resource_test.go | 52 +-- zitadel/v2/project_role/const.go | 2 +- zitadel/v2/project_role/datasource.go | 2 +- zitadel/v2/project_role/funcs.go | 10 +- .../project_role_test_dep/dependency.go | 27 ++ zitadel/v2/project_role/resource.go | 2 +- zitadel/v2/project_role/resource_test.go | 36 +- zitadel/v2/sms_provider_twilio/const.go | 2 +- zitadel/v2/sms_provider_twilio/funcs.go | 8 +- zitadel/v2/sms_provider_twilio/resource.go | 2 +- .../v2/sms_provider_twilio/resource_test.go | 29 +- zitadel/v2/smtp_config/const.go | 4 +- zitadel/v2/smtp_config/funcs.go | 14 +- zitadel/v2/smtp_config/resource.go | 4 +- zitadel/v2/smtp_config/resource_test.go | 39 +-- zitadel/v2/trigger_actions/const.go | 4 +- zitadel/v2/trigger_actions/datasource.go | 4 +- zitadel/v2/trigger_actions/funcs.go | 16 +- zitadel/v2/trigger_actions/resource.go | 8 +- zitadel/v2/trigger_actions/resource_test.go | 43 +-- zitadel/v2/user_grant/const.go | 2 +- zitadel/v2/user_grant/funcs.go | 6 +- zitadel/v2/user_grant/resource.go | 2 +- zitadel/v2/user_grant/resource_test.go | 63 +--- .../v2/verify_email_message_text/resource.go | 10 +- .../resource_test.go | 39 +-- .../v2/verify_phone_message_text/resource.go | 10 +- .../resource_test.go | 40 +-- 232 files changed, 1569 insertions(+), 2760 deletions(-) create mode 100644 examples/provider/data-sources/orgs.tf create mode 100644 zitadel/v2/action/action_test_dep/dependency.go create mode 100644 zitadel/v2/application_api/application_api_test_dep/dependency.go create mode 100644 zitadel/v2/helper/test_utils/dependency.go create mode 100644 zitadel/v2/helper/test_utils/example.go create mode 100644 zitadel/v2/human_user/human_user_test_dep/dependency.go create mode 100644 zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go create mode 100644 zitadel/v2/idp_google/idp_google_test_dep/dependency.go create mode 100644 zitadel/v2/machine_user/machine_user_test_dep/dependency.go create mode 100644 zitadel/v2/org/org_test_dep/dependency.go create mode 100644 zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go create mode 100644 zitadel/v2/project/project_test_dep/dependency.go create mode 100644 zitadel/v2/project_grant/project_grant_test_dep/dependency.go create mode 100644 zitadel/v2/project_role/project_role_test_dep/dependency.go diff --git a/examples/provider/data-sources/org.tf b/examples/provider/data-sources/org.tf index 2e31aa61..d61f0ff9 100644 --- a/examples/provider/data-sources/org.tf +++ b/examples/provider/data-sources/org.tf @@ -1,5 +1,5 @@ data "zitadel_org" "default" { - org_id = "123456789012345678" + id = "123456789012345678" } output "org" { diff --git a/examples/provider/data-sources/orgs.tf b/examples/provider/data-sources/orgs.tf new file mode 100644 index 00000000..939cb042 --- /dev/null +++ b/examples/provider/data-sources/orgs.tf @@ -0,0 +1,18 @@ +data "zitadel_orgs" "default" { + name = "example-name" + name_method = "TEXT_QUERY_METHOD_CONTAINS_IGNORE_CASE" + domain = "example.com" + domain_method = "TEXT_QUERY_METHOD_CONTAINS_IGNORE_CASE" + state = "ORG_STATE_ACTIVE" +} + +data "zitadel_org" "default" { + for_each = toset(data.zitadel_orgs.default.ids) + id = each.value +} + +output "org_names" { + value = toset([ + for org in data.zitadel_org.default : org.name + ]) +} diff --git a/examples/provider/resources/default_domain_policy.tf b/examples/provider/resources/default_domain_policy.tf index 60ac9558..ac158007 100644 --- a/examples/provider/resources/default_domain_policy.tf +++ b/examples/provider/resources/default_domain_policy.tf @@ -1,5 +1,5 @@ resource "zitadel_default_domain_policy" "default" { user_login_must_be_domain = false - validate_org_domains = false - smtp_sender_address_matches_instance_domain = false + validate_org_domains = true + smtp_sender_address_matches_instance_domain = true } diff --git a/examples/provider/resources/default_login_policy.tf b/examples/provider/resources/default_login_policy.tf index 69029699..fc3ddcab 100644 --- a/examples/provider/resources/default_login_policy.tf +++ b/examples/provider/resources/default_login_policy.tf @@ -14,6 +14,7 @@ resource "zitadel_default_login_policy" "default" { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] + idps = [data.zitadel_idp_google.default.id, data.zitadel_idp_azure_ad.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/examples/provider/resources/default_privacy_policy.tf b/examples/provider/resources/default_privacy_policy.tf index 8b3c1002..3daacf21 100644 --- a/examples/provider/resources/default_privacy_policy.tf +++ b/examples/provider/resources/default_privacy_policy.tf @@ -1,6 +1,6 @@ resource "zitadel_default_privacy_policy" "default" { - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" - support_email = "support@email.com" + tos_link = "https://example.com/tos" + privacy_link = "https://example.com/privacy" + help_link = "https://example.com/help" + support_email = "support@example.com" } diff --git a/examples/provider/resources/domain.tf b/examples/provider/resources/domain.tf index c5a35c1d..babc7dfb 100644 --- a/examples/provider/resources/domain.tf +++ b/examples/provider/resources/domain.tf @@ -1,5 +1,5 @@ resource "zitadel_domain" "default" { org_id = data.zitadel_org.default.id name = "zitadel.default.127.0.0.1.sslip.io" - is_primary = true + is_primary = false } diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index b92c7405..1ce6bbe8 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,6 +1,6 @@ resource "zitadel_domain_policy" "default" { org_id = data.zitadel_org.default.id - user_login_must_be_domain = false + user_login_must_be_domain = true validate_org_domains = false - smtp_sender_address_matches_instance_domain = false + smtp_sender_address_matches_instance_domain = true } diff --git a/examples/provider/resources/login_policy.tf b/examples/provider/resources/login_policy.tf index d8b6d42b..4b45792c 100644 --- a/examples/provider/resources/login_policy.tf +++ b/examples/provider/resources/login_policy.tf @@ -15,7 +15,7 @@ resource "zitadel_login_policy" "default" { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_idp_oidc.default.id, zitadel_org_idp_jwt.default.id] + idps = [data.zitadel_idp_google.default.id, data.zitadel_idp_azure_ad.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/examples/provider/resources/machine_user.tf b/examples/provider/resources/machine_user.tf index 164c9974..358ec2e9 100644 --- a/examples/provider/resources/machine_user.tf +++ b/examples/provider/resources/machine_user.tf @@ -1,6 +1,6 @@ resource "zitadel_machine_user" "default" { org_id = data.zitadel_org.default.id - user_name = "machine@localhost.com" + user_name = "machine@example.com" name = "name" - description = "description" + description = "a machine user" } diff --git a/examples/provider/resources/org_idp_jwt.tf b/examples/provider/resources/org_idp_jwt.tf index 1a943779..39de56ed 100644 --- a/examples/provider/resources/org_idp_jwt.tf +++ b/examples/provider/resources/org_idp_jwt.tf @@ -2,7 +2,7 @@ resource "zitadel_org_idp_jwt" "default" { org_id = data.zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" - jwt_endpoint = "https://jwtendpoint.com" + jwt_endpoint = "https://jwtendpoint.com/jwt" issuer = "https://google.com" keys_endpoint = "https://jwtendpoint.com/keys" header_name = "x-auth-token" diff --git a/examples/provider/resources/privacy_policy.tf b/examples/provider/resources/privacy_policy.tf index c83dbf92..ebc62b54 100644 --- a/examples/provider/resources/privacy_policy.tf +++ b/examples/provider/resources/privacy_policy.tf @@ -1,7 +1,7 @@ resource "zitadel_privacy_policy" "default" { org_id = data.zitadel_org.default.id - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" - support_email = "support@email.com" + tos_link = "https://example.com/tos" + privacy_link = "https://example.com/privacy" + help_link = "https://example.com/help" + support_email = "support@example.com" } diff --git a/examples/provider/resources/project_grant.tf b/examples/provider/resources/project_grant.tf index 6ef73acd..c146a2f2 100644 --- a/examples/provider/resources/project_grant.tf +++ b/examples/provider/resources/project_grant.tf @@ -1,6 +1,6 @@ resource "zitadel_project_grant" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - granted_org_id = data.zitadel_org.default.id - role_keys = [data.zitadel_project_role.default.role_key] + granted_org_id = data.zitadel_org.granted_org.id + role_keys = ["super-user"] } diff --git a/examples/provider/resources/project_grant_member.tf b/examples/provider/resources/project_grant_member.tf index de5d4b35..e27f15f5 100644 --- a/examples/provider/resources/project_grant_member.tf +++ b/examples/provider/resources/project_grant_member.tf @@ -1,7 +1,7 @@ resource "zitadel_project_grant_member" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - grant_id = data.zitadel_project_grant.default.id user_id = data.zitadel_human_user.default.id + grant_id = "123456789012345678" roles = ["PROJECT_GRANT_OWNER"] } diff --git a/examples/provider/resources/project_role.tf b/examples/provider/resources/project_role.tf index 1e21104e..6347929f 100644 --- a/examples/provider/resources/project_role.tf +++ b/examples/provider/resources/project_role.tf @@ -1,7 +1,7 @@ resource "zitadel_project_role" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - role_key = "key" + role_key = "super-user" display_name = "display_name2" group = "role_group" } diff --git a/examples/provider/resources/sms_provider_twilio.tf b/examples/provider/resources/sms_provider_twilio.tf index 60b99bea..4c64e0a4 100644 --- a/examples/provider/resources/sms_provider_twilio.tf +++ b/examples/provider/resources/sms_provider_twilio.tf @@ -1,5 +1,5 @@ resource "zitadel_sms_provider_twilio" "default" { sid = "sid" sender_number = "019920892" - token = "token" + token = "twilio_token" } diff --git a/examples/provider/resources/smtp_config.tf b/examples/provider/resources/smtp_config.tf index 1b3add51..51cfe619 100644 --- a/examples/provider/resources/smtp_config.tf +++ b/examples/provider/resources/smtp_config.tf @@ -1,8 +1,8 @@ resource "zitadel_smtp_config" "default" { - sender_address = "address" + sender_address = "sender@example.com" sender_name = "no-reply" tls = true host = "localhost:25" user = "user" - password = "password" + password = "secret_password" } diff --git a/examples/provider/resources/trigger_actions.tf b/examples/provider/resources/trigger_actions.tf index 85120e41..6f324ad3 100644 --- a/examples/provider/resources/trigger_actions.tf +++ b/examples/provider/resources/trigger_actions.tf @@ -1,6 +1,6 @@ resource "zitadel_trigger_actions" "default" { org_id = data.zitadel_org.default.id - flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" - trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" + flow_type = "FLOW_TYPE_CUSTOMISE_TOKEN" + trigger_type = "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION" action_ids = [data.zitadel_action.default.id] } diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 380175ad..68024bad 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,6 +1,6 @@ resource "zitadel_user_grant" "default" { project_id = data.zitadel_project.default.id org_id = data.zitadel_org.default.id - role_keys = ["key"] + role_keys = ["some_role_key"] user_id = data.zitadel_human_user.default.id } diff --git a/zitadel/v2/action/action_test_dep/dependency.go b/zitadel/v2/action/action_test_dep/dependency.go new file mode 100644 index 00000000..f48aba18 --- /dev/null +++ b/zitadel/v2/action/action_test_dep/dependency.go @@ -0,0 +1,24 @@ +package action_test_dep + +import ( + "testing" + "time" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "google.golang.org/protobuf/types/known/durationpb" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_action", action.ActionIDVar, func() (string, error) { + a, err := frame.CreateAction(frame, &management.CreateActionRequest{ + Name: frame.UniqueResourcesID, + Script: "not a script", + Timeout: durationpb.New(10 * time.Second), + AllowedToFail: true, + }) + return a.GetId(), err + }) +} diff --git a/zitadel/v2/action/const.go b/zitadel/v2/action/const.go index f1f878af..bbeefaac 100644 --- a/zitadel/v2/action/const.go +++ b/zitadel/v2/action/const.go @@ -1,11 +1,11 @@ package action const ( - actionIDVar = "action_id" + ActionIDVar = "action_id" orgIDVar = "org_id" stateVar = "state" - nameVar = "name" - scriptVar = "script" + NameVar = "name" + ScriptVar = "script" timeoutVar = "timeout" allowedToFailVar = "allowed_to_fail" ) diff --git a/zitadel/v2/action/datasource.go b/zitadel/v2/action/datasource.go index 7a2057f6..3feaaf1b 100644 --- a/zitadel/v2/action/datasource.go +++ b/zitadel/v2/action/datasource.go @@ -6,7 +6,7 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an action belonging to an organization.", Schema: map[string]*schema.Schema{ - actionIDVar: { + ActionIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", @@ -22,12 +22,12 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "the state of the action", }, - nameVar: { + NameVar: { Type: schema.TypeString, Computed: true, Description: "", }, - scriptVar: { + ScriptVar: { Type: schema.TypeString, Computed: true, Description: "", diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go index ae03f64b..69255140 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/v2/action/funcs.go @@ -34,8 +34,8 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateAction(ctx, &management.UpdateActionRequest{ Id: d.Id(), - Name: d.Get(nameVar).(string), - Script: d.Get(scriptVar).(string), + Name: d.Get(NameVar).(string), + Script: d.Get(ScriptVar).(string), Timeout: durationpb.New(timeout), AllowedToFail: d.Get(allowedToFailVar).(bool), }) @@ -86,8 +86,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.CreateAction(ctx, &management.CreateActionRequest{ - Name: d.Get(nameVar).(string), - Script: d.Get(scriptVar).(string), + Name: d.Get(NameVar).(string), + Script: d.Get(ScriptVar).(string), Timeout: durationpb.New(timeout), AllowedToFail: d.Get(allowedToFailVar).(bool), }) @@ -115,7 +115,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn Queries: []*management.ActionQuery{ {Query: &management.ActionQuery_ActionIdQuery{ ActionIdQuery: &action.ActionIDQuery{ - Id: helper.GetID(d, actionIDVar), + Id: helper.GetID(d, ActionIDVar), }, }}, }, @@ -132,9 +132,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn action := resp.Result[0] set := map[string]interface{}{ orgIDVar: action.GetDetails().GetResourceOwner(), - nameVar: action.GetName(), + NameVar: action.GetName(), stateVar: action.GetState(), - scriptVar: action.GetScript(), + ScriptVar: action.GetScript(), timeoutVar: action.GetTimeout().AsDuration().String(), allowedToFailVar: action.GetAllowedToFail(), } diff --git a/zitadel/v2/action/resource.go b/zitadel/v2/action/resource.go index 04440608..431af64d 100644 --- a/zitadel/v2/action/resource.go +++ b/zitadel/v2/action/resource.go @@ -23,12 +23,12 @@ func GetResource() *schema.Resource { return EnumValueValidation(actionState, value, action.ActionState_value) },*/ }, - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "", }, - scriptVar: { + ScriptVar: { Type: schema.TypeString, Required: true, Description: "", diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index be6ab397..63e74a73 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -9,33 +9,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccAction(t *testing.T) { - resourceName := "zitadel_action" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + frame := test_utils.NewOrgTestFrame(t, "zitadel_action") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) // name must be unique - nameAttribute := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() + nameAttribute := test_utils.AttributeValue(t, action.NameVar, exampleAttributes).AsString() resourceExample = strings.Replace(resourceExample, nameAttribute, frame.UniqueResourcesID, 1) - exampleProperty := test_utils.AttributeValue(t, "script", exampleAttributes).AsString() - updatedProperty := "updatedproperty" - test_utils.RunLifecyleTest[string]( + exampleProperty := test_utils.AttributeValue(t, action.ScriptVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf("%s\n%s", frame.OrgExampleDatasource, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) - }, - exampleProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedproperty", "", "", true, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), nil, nil, "", "", ) } diff --git a/zitadel/v2/app_key/const.go b/zitadel/v2/app_key/const.go index 1d150e7f..94b82711 100644 --- a/zitadel/v2/app_key/const.go +++ b/zitadel/v2/app_key/const.go @@ -6,5 +6,5 @@ const ( appIDVar = "app_id" keyTypeVar = "key_type" keyDetailsVar = "key_details" - expirationDateVar = "expiration_date" + ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/app_key/funcs.go index 830acff7..24999fd6 100644 --- a/zitadel/v2/app_key/funcs.go +++ b/zitadel/v2/app_key/funcs.go @@ -59,7 +59,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Type: authn.KeyType(authn.KeyType_value[keyType]), } - if expiration, ok := d.GetOk(expirationDateVar); ok { + if expiration, ok := d.GetOk(ExpirationDateVar); ok { t, err := time.Parse(time.RFC3339, expiration.(string)) if err != nil { return diag.Errorf("failed to parse time: %v", err) @@ -108,7 +108,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(resp.GetKey().GetId()) set := map[string]interface{}{ - expirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), + ExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), projectIDVar: projectID, appIDVar: appID, orgIDVar: orgID, diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index bfcf7f2d..33ce156d 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -40,7 +40,7 @@ func GetResource() *schema.Resource { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) }, }, - expirationDateVar: { + ExpirationDateVar: { Type: schema.TypeString, Required: true, Description: "Expiration date of the app key in the RFC3339 format", diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 836c1603..3f6ddc31 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -2,53 +2,36 @@ package app_key_test import ( "fmt" - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api/application_api_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) func TestAccAppKey(t *testing.T) { - resourceName := "zitadel_application_key" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - apiApp, err := frame.AddAPIApp(frame, &management.AddAPIAppRequest{ - ProjectId: project.GetId(), - Name: frame.UniqueResourcesID, - AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, - }) - resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) - exampleProperty := test_utils.AttributeValue(t, "expiration_date", exampleAttributes).AsString() + frame := test_utils.NewOrgTestFrame(t, "zitadel_application_key") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, app_key.ExpirationDateVar, exampleAttributes).AsString() updatedProperty := "2501-01-01T08:45:00Z" - projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) - appDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "application_api") - appDatasourceExample = strings.Replace(appDatasourceExample, test_utils.ExamplesResourceID, apiApp.GetAppId(), 1) - test_utils.RunLifecyleTest[string]( + projectDep, projectID := project_test_dep.Create(t, frame) + appDep, appID := application_api_test_dep.Create(t, frame, projectID) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf("%s\n%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, appDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) - }, + []string{frame.AsOrgDefaultDependency, projectDep, appDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, "", "", false, - checkRemoteProperty(frame, project.GetId(), apiApp.GetAppId()), + checkRemoteProperty(frame, projectID, appID), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId(), apiApp.GetAppId()), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID, appID), updatedProperty), nil, nil, "", "", ) } diff --git a/zitadel/v2/application_api/application_api_test_dep/dependency.go b/zitadel/v2/application_api/application_api_test_dep/dependency.go new file mode 100644 index 00000000..954030ff --- /dev/null +++ b/zitadel/v2/application_api/application_api_test_dep/dependency.go @@ -0,0 +1,22 @@ +package application_api_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID string) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_application_api", application_api.AppIDVar, func() (string, error) { + apiApp, err := frame.AddAPIApp(frame, &management.AddAPIAppRequest{ + ProjectId: projectID, + Name: frame.UniqueResourcesID, + AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT, + }) + return apiApp.GetAppId(), err + }) +} diff --git a/zitadel/v2/application_api/const.go b/zitadel/v2/application_api/const.go index 80f99aff..7cee2013 100644 --- a/zitadel/v2/application_api/const.go +++ b/zitadel/v2/application_api/const.go @@ -1,10 +1,10 @@ package application_api const ( - appIDVar = "app_id" + AppIDVar = "app_id" orgIDVar = "org_id" projectIDVar = "project_id" - nameVar = "name" + NameVar = "name" authMethodTypeVar = "auth_method_type" clientID = "client_id" clientSecret = "client_secret" diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/v2/application_api/datasource.go index dec165c1..cde2ab93 100644 --- a/zitadel/v2/application_api/datasource.go +++ b/zitadel/v2/application_api/datasource.go @@ -8,7 +8,7 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an API application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ - appIDVar: { + AppIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", @@ -23,7 +23,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "ID of the project", }, - nameVar: { + NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the application", diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index b6fb8269..89fcd894 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -49,11 +49,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } projectID := d.Get(projectIDVar).(string) - if d.HasChange(nameVar) { + if d.HasChange(NameVar) { _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ ProjectId: projectID, AppId: d.Id(), - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), }) if err != nil { return diag.Errorf("failed to update application: %v", err) @@ -88,7 +88,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddAPIApp(ctx, &management.AddAPIAppRequest{ ProjectId: d.Get(projectIDVar).(string), - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[(d.Get(authMethodTypeVar).(string))]), }) @@ -121,7 +121,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, appIDVar)}) + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, AppIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -134,7 +134,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn api := app.GetApiConfig() set := map[string]interface{}{ orgIDVar: app.GetDetails().GetResourceOwner(), - nameVar: app.GetName(), + NameVar: app.GetName(), authMethodTypeVar: api.GetAuthMethodType().String(), } for k, v := range set { diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index 2cb75947..6bc84a0c 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -25,7 +25,7 @@ func GetResource() *schema.Resource { Description: "ID of the project", ForceNew: true, }, - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the application", diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index 77c514bf..cf5059f0 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -2,45 +2,33 @@ package application_api_test import ( "fmt" - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) func TestAccAppAPI(t *testing.T) { - resourceName := "zitadel_application_api" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) - exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() - updatedProperty := "updatedproperty" - projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_application_api") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, application_api.NameVar, exampleAttributes).AsString() + projectDep, projectID := project_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf("%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) - }, - exampleProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedproperty", "", "", false, - checkRemoteProperty(frame, project.GetId()), + checkRemoteProperty(frame, projectID), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID), ""), nil, nil, "", "", ) } diff --git a/zitadel/v2/application_oidc/const.go b/zitadel/v2/application_oidc/const.go index aa160871..a5ac079e 100644 --- a/zitadel/v2/application_oidc/const.go +++ b/zitadel/v2/application_oidc/const.go @@ -4,7 +4,7 @@ const ( appIDVar = "app_id" orgIDVar = "org_id" projectIDVar = "project_id" - nameVar = "name" + NameVar = "name" redirectURIsVar = "redirect_uris" responseTypesVar = "response_types" grantTypesVar = "grant_types" diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/v2/application_oidc/datasource.go index fda887ad..b02a89c8 100644 --- a/zitadel/v2/application_oidc/datasource.go +++ b/zitadel/v2/application_oidc/datasource.go @@ -23,7 +23,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "ID of the project", }, - nameVar: { + NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the application", diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index b684e53f..06a2045f 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -52,11 +52,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia projectID := d.Get(projectIDVar).(string) - if d.HasChange(nameVar) { + if d.HasChange(NameVar) { _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ ProjectId: projectID, AppId: d.Id(), - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), }) if err != nil { return diag.Errorf("failed to update application: %v", err) @@ -144,7 +144,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddOIDCApp(ctx, &management.AddOIDCAppRequest{ ProjectId: d.Get(projectIDVar).(string), - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), RedirectUris: interfaceToStringSlice(d.Get(redirectURIsVar)), ResponseTypes: respTypes, GrantTypes: grantTypes, @@ -217,7 +217,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ orgIDVar: oidcApp.GetDetails().GetResourceOwner(), - nameVar: oidcApp.GetName(), + NameVar: oidcApp.GetName(), redirectURIsVar: oidc.GetRedirectUris(), responseTypesVar: responseTypes, grantTypesVar: grantTypes, diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index ac468459..58a82fe0 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -25,7 +25,7 @@ func GetResource() *schema.Resource { Description: "ID of the project", ForceNew: true, }, - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the application", diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index 45415ef5..e8952a2b 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -2,45 +2,33 @@ package application_oidc_test import ( "fmt" - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) func TestAccAppOIDC(t *testing.T) { - resourceName := "zitadel_application_oidc" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) - exampleProperty := test_utils.AttributeValue(t, "name", exampleAttributes).AsString() - updatedProperty := "updatedproperty" - projectDatasourceExample, _ := frame.ReadExample(t, test_utils.Datasources, "project") - projectDatasourceExample = strings.Replace(projectDatasourceExample, test_utils.ExamplesResourceID, project.GetId(), 1) - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_application_oidc") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, application_oidc.NameVar, exampleAttributes).AsString() + projectDep, projectID := project_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf("%s\n%s\n%s", frame.OrgExampleDatasource, projectDatasourceExample, strings.Replace(resourceExample, exampleProperty, configProperty, 1)) - }, - exampleProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedproperty", "", "", false, - checkRemoteProperty(frame, project.GetId()), + checkRemoteProperty(frame, projectID), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, project.GetId()), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID), ""), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource.go b/zitadel/v2/default_domain_claimed_message_text/resource.go index 58a77060..34294858 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultDomainClaimedMessageTextResource) Delete(ctx context.Context, re func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index edbefbeb..f69363dc 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -3,39 +3,33 @@ package default_domain_claimed_message_text_test import ( "fmt" "regexp" - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultDomainClaimedMessageText(t *testing.T) { - resourceName := "zitadel_default_domain_claimed_message_text" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - resourceExample, exampleAttributes := frame.ReadExample(t, test_utils.Resources, frame.ResourceType) + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_domain_claimed_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() - updatedProperty := "updatedtitle" - test_utils.RunLifecyleTest[string]( + exampleLanguage := test_utils.AttributeValue(t, default_domain_claimed_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return strings.Replace(resourceExample, exampleProperty, configProperty, 1) - }, - exampleProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Domain has been claimed"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Domain has been claimed"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_domain_policy/const.go b/zitadel/v2/default_domain_policy/const.go index fb90b2c9..03a31e7f 100644 --- a/zitadel/v2/default_domain_policy/const.go +++ b/zitadel/v2/default_domain_policy/const.go @@ -1,7 +1,7 @@ package default_domain_policy const ( - userLoginMustBeDomainVar = "user_login_must_be_domain" + UserLoginMustBeDomainVar = "user_login_must_be_domain" validateOrgDomainVar = "validate_org_domains" smtpSenderVar = "smtp_sender_address_matches_instance_domain" ) diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/v2/default_domain_policy/funcs.go index c2d3a0d6..a27ad7a6 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/v2/default_domain_policy/funcs.go @@ -30,9 +30,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } id := "" - if d.HasChanges(userLoginMustBeDomainVar, validateOrgDomainVar, smtpSenderVar) { + if d.HasChanges(UserLoginMustBeDomainVar, validateOrgDomainVar, smtpSenderVar) { resp, err := client.UpdateDomainPolicy(ctx, &admin.UpdateDomainPolicyRequest{ - UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + UserLoginMustBeDomain: d.Get(UserLoginMustBeDomainVar).(bool), ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), }) @@ -77,7 +77,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } policy := resp.Policy set := map[string]interface{}{ - userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), + UserLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), validateOrgDomainVar: policy.GetValidateOrgDomains(), smtpSenderVar: policy.GetSmtpSenderAddressMatchesInstanceDomain(), } diff --git a/zitadel/v2/default_domain_policy/resource.go b/zitadel/v2/default_domain_policy/resource.go index 700a927e..63fc5cf8 100644 --- a/zitadel/v2/default_domain_policy/resource.go +++ b/zitadel/v2/default_domain_policy/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the default domain policy.", Schema: map[string]*schema.Schema{ - userLoginMustBeDomainVar: { + UserLoginMustBeDomainVar: { Type: schema.TypeBool, Required: true, Description: "User login must be domain", diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index d9580500..3fa577b5 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -2,35 +2,31 @@ package default_domain_policy_test import ( "fmt" + "strconv" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultDomainPolicy(t *testing.T) { - resourceName := "zitadel_default_domain_policy" - initialProperty := true - updatedProperty := false - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_domain_policy") + resourceExample, resourceAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, default_domain_policy.UserLoginMustBeDomainVar, resourceAttributes).True() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - user_login_must_be_domain = %t - validate_org_domains = false - smtp_sender_address_matches_instance_domain = false -}`, resourceName, frame.UniqueResourcesID, configProperty) + nil, + func(property bool, secret string) string { + // only replace first bool for the smtp_sender_address_matches_instance_domain property + return strings.Replace(resourceExample, strconv.FormatBool(exampleProperty), strconv.FormatBool(property), 1) }, - initialProperty, updatedProperty, + exampleProperty, !exampleProperty, "", "", false, checkRemoteProperty(*frame), diff --git a/zitadel/v2/default_init_message_text/resource.go b/zitadel/v2/default_init_message_text/resource.go index 180c5cb0..c8cdb1c8 100644 --- a/zitadel/v2/default_init_message_text/resource.go +++ b/zitadel/v2/default_init_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultInitMessageTextResource) Delete(ctx context.Context, req resourc func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index c63c1964..4caf3d2c 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -9,40 +9,25 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_init_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultInitMessageText(t *testing.T) { - resourceName := "zitadel_default_init_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_init_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + language := test_utils.AttributeValue(t, default_init_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + regexp.MustCompile(fmt.Sprintf(`^%s$`, language)), // When deleted, the default should be returned checkRemoteProperty(frame, language)("ZITADEL - Initialize User"), nil, nil, "", "", diff --git a/zitadel/v2/default_label_policy/const.go b/zitadel/v2/default_label_policy/const.go index 6dc1f9d1..c070ae67 100644 --- a/zitadel/v2/default_label_policy/const.go +++ b/zitadel/v2/default_label_policy/const.go @@ -1,7 +1,7 @@ package default_label_policy const ( - primaryColorVar = "primary_color" + PrimaryColorVar = "primary_color" hideLoginNameSuffixVar = "hide_login_name_suffix" warnColorVar = "warn_color" backgroundColorVar = "background_color" diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index caa20521..83920419 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -31,7 +31,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia id := "" if d.HasChanges( - primaryColorVar, + PrimaryColorVar, hideLoginNameSuffixVar, warnColorVar, backgroundColorVar, @@ -43,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia disableWatermarkVar, ) { resp, err := client.UpdateLabelPolicy(ctx, &admin.UpdateLabelPolicyRequest{ - PrimaryColor: d.Get(primaryColorVar).(string), + PrimaryColor: d.Get(PrimaryColorVar).(string), HideLoginNameSuffix: d.Get(hideLoginNameSuffixVar).(bool), WarnColor: d.Get(warnColorVar).(string), BackgroundColor: d.Get(backgroundColorVar).(string), @@ -97,7 +97,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } if d.HasChanges( - primaryColorVar, + PrimaryColorVar, hideLoginNameSuffixVar, warnColorVar, backgroundColorVar, @@ -146,7 +146,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn policy := resp.Policy set := map[string]interface{}{ - primaryColorVar: policy.GetPrimaryColor(), + PrimaryColorVar: policy.GetPrimaryColor(), hideLoginNameSuffixVar: policy.GetHideLoginNameSuffix(), warnColorVar: policy.GetWarnColor(), backgroundColorVar: policy.GetBackgroundColor(), diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/v2/default_label_policy/resource.go index 716458da..83544003 100644 --- a/zitadel/v2/default_label_policy/resource.go +++ b/zitadel/v2/default_label_policy/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the default label policy.", Schema: map[string]*schema.Schema{ - primaryColorVar: { + PrimaryColorVar: { Type: schema.TypeString, Required: true, Description: "hex value for primary color", diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 91075469..393500c3 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -1,44 +1,40 @@ package default_label_policy_test import ( + "encoding/base64" "fmt" + "io" + "os" + "regexp" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultLabelPolicy(t *testing.T) { - resourceName := "zitadel_default_label_policy" - initialProperty := "#5469d4" - updatedProperty := "#5469d3" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_label_policy") + testSVGFile := writeFile(t, strings.NewReader(testSVG)) + defer testSVGFile.Close() + defer os.Remove(testSVGFile.Name()) + testFontFile := writeFile(t, base64.NewDecoder(base64.StdEncoding, strings.NewReader(testFontBase64))) + defer testFontFile.Close() + defer os.Remove(testFontFile.Name()) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + resourceExample = regexp.MustCompile("/path/to/[a-zA-Z_]+\\.jpg").ReplaceAllString(resourceExample, testSVGFile.Name()) + resourceExample = regexp.MustCompile("/path/to/[a-zA-Z_]+\\.tff").ReplaceAllString(resourceExample, testFontFile.Name()) + exampleProperty := test_utils.AttributeValue(t, default_label_policy.PrimaryColorVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - primary_color = "%s" - hide_login_name_suffix = true - warn_color = "#cd3d56" - background_color = "#fafafa" - font_color = "#000000" - primary_color_dark = "#a5b4fc" - background_color_dark = "#111827" - warn_color_dark = "#ff3b5b" - font_color_dark = "#ffffff" - disable_watermark = false - set_active = true -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "#5469d3", "", "", false, checkRemoteProperty(*frame), @@ -63,3 +59,32 @@ func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resour } } } + +func writeFile(t *testing.T, content io.Reader) *os.File { + file, err := os.CreateTemp("", "TestAccDefaultLabelPolicy") + if err != nil { + t.Fatalf("creating temp file failed: %v", err) + } + if _, err := io.Copy(file, content); err != nil { + t.Fatalf("writing temp file failed: %v", err) + } + return file +} + +const ( + testSVG = ` + + + +` + testFontBase64 = ` +AAEAAAAHAEAAAgAwY21hcAAJAHYAAAEAAAAALGdseWbxy2aYAAABNAAAAFxoZWFk8jXd+AAAAHwA +AAA2aGhlYQZhAMoAAAC0AAAAJGhtdHgEdABqAAAA+AAAAAhsb2NhAC4AFAAAASwAAAAGbWF4cAAF +AAsAAADYAAAAIAABAAAAAQAA9ZwpRF8PPPUAAgPoAAAAALSS9AAAAAAA3C+mXAAGAAACWAK8AAAA +AwACAAAAAAAAAAEAAAQA/nAAAAJYAAb//wJYAAEAAAAAAAAAAAAAAAAAAAACAAEAAAACAAsAAgAA +AAAAAAAAAAAAAAAAAAAAAAAAAAACWABkAhwABgAAAAEAAAADAAAADAAEACAAAAAEAAQAAQAAAEH/ +/wAAAEH////AAAEAAAAAAAAAFAAuAAAAAgBkAAACWAK8AAMABwAAMxEhESUhESFkAfT+NAGk/lwC +vP1EKAJsAAIABgAAAh0CkAACAAoAABMzAwETMxMjJyMHrcRj/vjaYN1ZPu9CAQsBQP21ApD9cMjI +AA== +` +) diff --git a/zitadel/v2/default_lockout_policy/const.go b/zitadel/v2/default_lockout_policy/const.go index ff032c6a..3be06c27 100644 --- a/zitadel/v2/default_lockout_policy/const.go +++ b/zitadel/v2/default_lockout_policy/const.go @@ -1,5 +1,5 @@ package default_lockout_policy const ( - maxPasswordAttemptsVar = "max_password_attempts" + MaxPasswordAttemptsVar = "max_password_attempts" ) diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/v2/default_lockout_policy/funcs.go index d3900de8..c8215701 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/v2/default_lockout_policy/funcs.go @@ -30,9 +30,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } id := "" - if d.HasChanges(maxPasswordAttemptsVar) { + if d.HasChanges(MaxPasswordAttemptsVar) { resp, err := client.UpdateLockoutPolicy(ctx, &admin.UpdateLockoutPolicyRequest{ - MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), + MaxPasswordAttempts: uint32(d.Get(MaxPasswordAttemptsVar).(int)), }) if helper.IgnorePreconditionError(err) != nil { return diag.Errorf("failed to update default lockout policy: %v", err) @@ -76,7 +76,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn policy := resp.Policy set := map[string]interface{}{ - maxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), + MaxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), } for k, v := range set { diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/v2/default_lockout_policy/resource.go index ef03d14a..3f5fd210 100644 --- a/zitadel/v2/default_lockout_policy/resource.go +++ b/zitadel/v2/default_lockout_policy/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the default lockout policy.", Schema: map[string]*schema.Schema{ - maxPasswordAttemptsVar: { + MaxPasswordAttemptsVar: { Type: schema.TypeInt, Required: true, Description: "Maximum password check attempts before the account gets locked. Attempts are reset as soon as the password is entered correctly or the password is reset.", diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index 74bdd78b..abb3e595 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -2,33 +2,30 @@ package default_lockout_policy_test import ( "fmt" + "strconv" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultLockoutPolicy(t *testing.T) { - resourceName := "zitadel_default_lockout_policy" - initialProperty := uint64(3) - updatedProperty := uint64(5) - frame, err := test_utils.NewInstanceTestFrame(resourceName) + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_lockout_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty, err := strconv.ParseUint(test_utils.AttributeValue(t, default_lockout_policy.MaxPasswordAttemptsVar, exampleAttributes).AsString(), 10, 64) if err != nil { - t.Fatalf("setting up test context failed: %v", err) + t.Fatalf("could not parse example property: %v", err) } - test_utils.RunLifecyleTest[uint64]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty uint64, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - max_password_attempts = "%d" -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, 10, "", "", false, checkRemoteProperty(*frame), diff --git a/zitadel/v2/default_login_policy/const.go b/zitadel/v2/default_login_policy/const.go index eed1e292..15f96df8 100644 --- a/zitadel/v2/default_login_policy/const.go +++ b/zitadel/v2/default_login_policy/const.go @@ -13,7 +13,7 @@ const ( secondFactorCheckLifetimeVar = "second_factor_check_lifetime" multiFactorCheckLifetimeVar = "multi_factor_check_lifetime" ignoreUnknownUsernamesVar = "ignore_unknown_usernames" - defaultRedirectURIVar = "default_redirect_uri" + DefaultRedirectURIVar = "default_redirect_uri" secondFactorsVar = "second_factors" multiFactorsVar = "multi_factors" idpsVar = "idps" diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/v2/default_login_policy/funcs.go index 222ac3ae..36cc7e5e 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/v2/default_login_policy/funcs.go @@ -45,7 +45,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia passwordlessTypeVar, hidePasswordResetVar, ignoreUnknownUsernamesVar, - defaultRedirectURIVar, + DefaultRedirectURIVar, allowDomainDiscovery, disableLoginWithEmail, disableLoginWithPhone, @@ -78,7 +78,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), HidePasswordReset: d.Get(hidePasswordResetVar).(bool), IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), - DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), + DefaultRedirectUri: d.Get(DefaultRedirectURIVar).(string), PasswordCheckLifetime: durationpb.New(passwordCheckLT), ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), @@ -215,7 +215,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn passwordlessTypeVar: resp.Policy.GetPasswordlessType().String(), hidePasswordResetVar: resp.Policy.GetHidePasswordReset(), ignoreUnknownUsernamesVar: resp.Policy.GetIgnoreUnknownUsernames(), - defaultRedirectURIVar: resp.Policy.GetDefaultRedirectUri(), + DefaultRedirectURIVar: resp.Policy.GetDefaultRedirectUri(), passwordCheckLifetimeVar: resp.Policy.GetPasswordCheckLifetime().AsDuration().String(), externalLoginCheckLifetimeVar: resp.Policy.GetExternalLoginCheckLifetime().AsDuration().String(), mfaInitSkipLifetimeVar: resp.Policy.GetMfaInitSkipLifetime().AsDuration().String(), diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 4a649f06..08cc45aa 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -43,7 +43,7 @@ func GetResource() *schema.Resource { Required: true, Description: "defines if unknown username on login screen directly return an error or always display the password screen", }, - defaultRedirectURIVar: { + DefaultRedirectURIVar: { Type: schema.TypeString, Required: true, Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index 2c23207e..fe3e50b8 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -8,44 +8,24 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" ) func TestAccDefaultLoginPolicy(t *testing.T) { - resourceName := "zitadel_default_login_policy" - initialProperty := true - updatedProperty := false - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_login_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, default_login_policy.DefaultRedirectURIVar, exampleAttributes).AsString() + azureADDep, _ := idp_azure_ad_test_dep.Create(t, frame.BaseTestFrame, frame) + googleDep, _ := idp_google_test_dep.Create(t, frame.BaseTestFrame, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - user_login = %t - allow_register = true - allow_external_idp = true - force_mfa = false - passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" - hide_password_reset = "false" - password_check_lifetime = "240h0m0s" - external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "24h0m0s" - mfa_init_skip_lifetime = "720h0m0s" - second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = true - default_redirect_uri = "localhost:8080" - second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] - multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - allow_domain_discovery = true - disable_login_with_email = true - disable_login_with_phone = true -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + []string{azureADDep, googleDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "localhost:9090", "", "", false, checkRemoteProperty(*frame), @@ -55,16 +35,16 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { - return func(expect bool) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLoginPolicy(frame, &admin.GetLoginPolicyRequest{}) if err != nil { return fmt.Errorf("getting policy failed: %w", err) } - actual := resp.GetPolicy().GetAllowUsernamePassword() + actual := resp.GetPolicy().GetDefaultRedirectUri() if actual != expect { - return fmt.Errorf("expected %t, but got %t", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/default_login_texts/resource.go b/zitadel/v2/default_login_texts/resource.go index 161a51af..37aab426 100644 --- a/zitadel/v2/default_login_texts/resource.go +++ b/zitadel/v2/default_login_texts/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultLoginTextsResource) Delete(ctx context.Context, req resource.Del func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index 4d4fc35a..3dc8f58d 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -9,321 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_texts" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultLoginTexts(t *testing.T) { - resourceName := "zitadel_default_login_texts" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_login_texts") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := "example" + exampleLanguage := test_utils.AttributeValue(t, default_login_texts.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - email_verification_done_text = { - cancel_button_text = "example" - description = "example" - login_button_text = "example" - next_button_text = "example" - title = "%s" - } - email_verification_text = { - code_label = "example" - description = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - external_registration_user_overview_text = { - back_button_text = "example" - description = "example" - email_label = "example" - firstname_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - nickname_label = "example" - phone_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - external_user_not_found_text = { - auto_register_button_text = "example" - description = "example" - link_button_text = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - } - footer_text = { - help = "example" - privacy_policy = "example" - tos = "example" - } - init_mfa_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_mfa_otp_text = { - cancel_button_text = "example" - code_label = "example" - description = "example" - description_otp = "example" - next_button_text = "example" - secret_label = "example" - title = "example" - } - init_mfa_prompt_text = { - description = "example" - next_button_text = "example" - otp_option = "example" - skip_button_text = "example" - title = "example" - u2f_option = "example" - } - init_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - init_password_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_password_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - initialize_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - initialize_user_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - linking_user_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - login_text = { - description = "example" - description_linking_process = "example" - external_user_description = "example" - login_name_label = "example" - login_name_placeholder = "example" - next_button_text = "example" - register_button_text = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - user_name_placeholder = "example" - } - logout_text = { - description = "example" - login_button_text = "example" - title = "example" - } - mfa_providers_text = { - choose_other = "example" - otp = "example" - u2f = "example" - } - password_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_change_text = { - cancel_button_text = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - old_password_label = "example" - title = "example" - } - password_reset_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_text = { - back_button_text = "example" - confirmation = "example" - description = "example" - has_lowercase = "example" - has_number = "example" - has_symbol = "example" - has_uppercase = "example" - min_length = "example" - next_button_text = "example" - password_label = "example" - reset_link_text = "example" - title = "example" - } - passwordless_prompt_text = { - description = "example" - description_init = "example" - next_button_text = "example" - passwordless_button_text = "example" - skip_button_text = "example" - title = "example" - } - passwordless_registration_done_text = { - cancel_button_text = "example" - description = "example" - description_close = "example" - next_button_text = "example" - title = "example" - } - passwordless_registration_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - passwordless_text = { - description = "example" - error_retry = "example" - login_with_pw_button_text = "example" - not_supported = "example" - title = "example" - validate_token_button_text = "example" - } - registration_option_text = { - description = "example" - external_login_description = "example" - title = "example" - user_name_button_text = "example" - } - registration_org_text = { - description = "example" - email_label = "example" - firstname_label = "example" - lastname_label = "example" - orgname_label = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - save_button_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - registration_user_text = { - back_button_text = "example" - description = "example" - description_org_register = "example" - email_label = "example" - firstname_label = "example" - gender_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - select_account_text = { - description = "example" - description_linking_process = "example" - other_user = "example" - session_state_active = "example" - session_state_inactive = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - } - success_login_text = { - auto_redirect_description = "example" - next_button_text = "example" - redirected_description = "example" - title = "example" - } - username_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - username_change_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - username_label = "example" - } - verify_mfa_otp_text = { - code_label = "example" - description = "example" - next_button_text = "example" - title = "example" - } - verify_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - title = "example" - validate_token_text = "example" - } -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtext", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)(""), + checkRemoteProperty(frame, exampleLanguage)(""), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 47cc1683..38c0c024 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -12,22 +12,16 @@ import ( ) func TestAccDefaultNotificationPolicy(t *testing.T) { - resourceName := "zitadel_default_notification_policy" + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_notification_policy") + resourceExample, _ := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := false initialProperty := true updatedProperty := false - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - password_change = %t -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, "", "", false, diff --git a/zitadel/v2/default_oidc_settings/const.go b/zitadel/v2/default_oidc_settings/const.go index 00285d4e..6ce95434 100644 --- a/zitadel/v2/default_oidc_settings/const.go +++ b/zitadel/v2/default_oidc_settings/const.go @@ -4,5 +4,5 @@ const ( accessTokenLifetimeVar = "access_token_lifetime" idTokenLifetimeVar = "id_token_lifetime" refreshTokenIdleExpirationVar = "refresh_token_idle_expiration" - refreshTokenExpirationVar = "refresh_token_expiration" + RefreshTokenExpirationVar = "refresh_token_expiration" ) diff --git a/zitadel/v2/default_oidc_settings/datasource.go b/zitadel/v2/default_oidc_settings/datasource.go index 56f90814..798712ae 100644 --- a/zitadel/v2/default_oidc_settings/datasource.go +++ b/zitadel/v2/default_oidc_settings/datasource.go @@ -18,7 +18,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "lifetime duration of id tokens", }, - refreshTokenExpirationVar: { + RefreshTokenExpirationVar: { Type: schema.TypeString, Computed: true, Description: "expiration duration of refresh tokens", diff --git a/zitadel/v2/default_oidc_settings/funcs.go b/zitadel/v2/default_oidc_settings/funcs.go index 5345ab92..02993763 100644 --- a/zitadel/v2/default_oidc_settings/funcs.go +++ b/zitadel/v2/default_oidc_settings/funcs.go @@ -35,7 +35,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - refreshTokenExp, err := time.ParseDuration(d.Get(refreshTokenExpirationVar).(string)) + refreshTokenExp, err := time.ParseDuration(d.Get(RefreshTokenExpirationVar).(string)) if err != nil { return diag.FromErr(err) } @@ -90,7 +90,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn accessTokenLifetimeVar: resp.GetSettings().GetAccessTokenLifetime().AsDuration().String(), idTokenLifetimeVar: resp.GetSettings().GetIdTokenLifetime().AsDuration().String(), refreshTokenIdleExpirationVar: resp.GetSettings().GetRefreshTokenIdleExpiration().AsDuration().String(), - refreshTokenExpirationVar: resp.GetSettings().GetRefreshTokenExpiration().AsDuration().String(), + RefreshTokenExpirationVar: resp.GetSettings().GetRefreshTokenExpiration().AsDuration().String(), } for k, v := range set { diff --git a/zitadel/v2/default_oidc_settings/resource.go b/zitadel/v2/default_oidc_settings/resource.go index 08d7f6a9..d533c32e 100644 --- a/zitadel/v2/default_oidc_settings/resource.go +++ b/zitadel/v2/default_oidc_settings/resource.go @@ -18,7 +18,7 @@ func GetResource() *schema.Resource { Required: true, Description: "lifetime duration of id tokens", }, - refreshTokenExpirationVar: { + RefreshTokenExpirationVar: { Type: schema.TypeString, Required: true, Description: "expiration duration of refresh tokens", diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 8b7a2c03..736f9cca 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -8,30 +8,20 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultOIDCSettings(t *testing.T) { - resourceName := "zitadel_default_oidc_settings" - initialProperty := "123h0m0s" - updatedProperty := "456h0m0s" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_oidc_settings") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, default_oidc_settings.RefreshTokenExpirationVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - access_token_lifetime = "%s" - id_token_lifetime = "777h0m0s" - refresh_token_idle_expiration = "888h0m0s" - refresh_token_expiration = "999h0m0s" -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "456h0m0s", "", "", false, checkRemoteProperty(*frame), @@ -48,7 +38,7 @@ func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(string) resour if err != nil { return fmt.Errorf("getting oidc settings failed: %w", err) } - actual := resp.GetSettings().GetAccessTokenLifetime().AsDuration().String() + actual := resp.GetSettings().GetRefreshTokenExpiration().AsDuration().String() if actual != expect { return fmt.Errorf("expected %s, but got %s", expect, actual) } diff --git a/zitadel/v2/default_password_change_message_text/resource.go b/zitadel/v2/default_password_change_message_text/resource.go index 38ae24bc..d76eb47d 100644 --- a/zitadel/v2/default_password_change_message_text/resource.go +++ b/zitadel/v2/default_password_change_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultPasswordChangeMessageTextResource) Delete(ctx context.Context, r func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index dbd76e7b..872eb32b 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -9,42 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_change_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultPasswordChangeMessageText(t *testing.T) { - resourceName := "zitadel_default_password_change_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_password_change_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_password_change_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Password of user has changed"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Password of user has changed"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_password_complexity_policy/const.go b/zitadel/v2/default_password_complexity_policy/const.go index 5e830e3a..b6aaebac 100644 --- a/zitadel/v2/default_password_complexity_policy/const.go +++ b/zitadel/v2/default_password_complexity_policy/const.go @@ -1,7 +1,7 @@ package default_password_complexity_policy const ( - minLengthVar = "min_length" + MinLengthVar = "min_length" hasUppercaseVar = "has_uppercase" hasLowercaseVar = "has_lowercase" hasNumberVar = "has_number" diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/v2/default_password_complexity_policy/funcs.go index 752166e5..6c690c9b 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/v2/default_password_complexity_policy/funcs.go @@ -30,9 +30,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } id := "" - if d.HasChanges(minLengthVar, hasUppercaseVar, hasLowercaseVar, hasNumberVar, hasSymbolVar) { + if d.HasChanges(MinLengthVar, hasUppercaseVar, hasLowercaseVar, hasNumberVar, hasSymbolVar) { resp, err := client.UpdatePasswordComplexityPolicy(ctx, &admin.UpdatePasswordComplexityPolicyRequest{ - MinLength: uint32(d.Get(minLengthVar).(int)), + MinLength: uint32(d.Get(MinLengthVar).(int)), HasUppercase: d.Get(hasUppercaseVar).(bool), HasLowercase: d.Get(hasLowercaseVar).(bool), HasNumber: d.Get(hasNumberVar).(bool), @@ -80,7 +80,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn policy := resp.Policy set := map[string]interface{}{ - minLengthVar: policy.GetMinLength(), + MinLengthVar: policy.GetMinLength(), hasUppercaseVar: policy.GetHasUppercase(), hasLowercaseVar: policy.GetHasLowercase(), hasNumberVar: policy.GetHasNumber(), diff --git a/zitadel/v2/default_password_complexity_policy/resource.go b/zitadel/v2/default_password_complexity_policy/resource.go index ac2c3d26..55ade57f 100644 --- a/zitadel/v2/default_password_complexity_policy/resource.go +++ b/zitadel/v2/default_password_complexity_policy/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the default password complexity policy.", Schema: map[string]*schema.Schema{ - minLengthVar: { + MinLengthVar: { Type: schema.TypeInt, Required: true, Description: "Minimal length for the password", diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 62d3980c..60606d94 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -2,37 +2,30 @@ package default_password_complexity_policy_test import ( "fmt" + "strconv" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultPasswordComplexityPolicy(t *testing.T) { - resourceName := "zitadel_default_password_complexity_policy" - initialProperty := true - updatedProperty := false - frame, err := test_utils.NewInstanceTestFrame(resourceName) + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_password_complexity_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty, err := strconv.ParseUint(test_utils.AttributeValue(t, default_password_complexity_policy.MinLengthVar, exampleAttributes).AsString(), 10, 64) if err != nil { - t.Fatalf("setting up test context failed: %v", err) + t.Fatalf("could not parse example property: %v", err) } - test_utils.RunLifecyleTest[bool]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - min_length = "8" - has_uppercase = true - has_lowercase = true - has_number = true - has_symbol = %t -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, 10, "", "", false, checkRemoteProperty(*frame), @@ -42,16 +35,16 @@ resource "%s" "%s" { ) } -func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { - return func(expect bool) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.InstanceTestFrame) func(uint64) resource.TestCheckFunc { + return func(expect uint64) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPasswordComplexityPolicy(frame, &admin.GetPasswordComplexityPolicyRequest{}) if err != nil { return fmt.Errorf("getting policy failed: %w", err) } - actual := resp.GetPolicy().GetHasSymbol() + actual := resp.GetPolicy().GetMinLength() if actual != expect { - return fmt.Errorf("expected %t, but got %t", expect, actual) + return fmt.Errorf("expected %d, but got %d", expect, actual) } return nil } diff --git a/zitadel/v2/default_password_reset_message_text/resource.go b/zitadel/v2/default_password_reset_message_text/resource.go index e1618a75..b92d1ea7 100644 --- a/zitadel/v2/default_password_reset_message_text/resource.go +++ b/zitadel/v2/default_password_reset_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultPasswordResetMessageTextResource) Delete(ctx context.Context, re func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index 36b3cf11..a446f661 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -9,42 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultPassswordResetMessageText(t *testing.T) { - resourceName := "zitadel_default_password_reset_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_password_reset_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_password_reset_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Reset password"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Reset password"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource.go b/zitadel/v2/default_passwordless_registration_message_text/resource.go index 5f70f59b..e7ac0df8 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultPasswordlessRegistrationMessageTextResource) Delete(ctx context. func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 52b52888..493f53b9 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -9,42 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultPasswordlessRegistrationMessageText(t *testing.T) { - resourceName := "zitadel_default_passwordless_registration_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_passwordless_registration_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_passwordless_registration_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Add Passwordless Login"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Add Passwordless Login"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_privacy_policy/const.go b/zitadel/v2/default_privacy_policy/const.go index c3c5224e..fc142b45 100644 --- a/zitadel/v2/default_privacy_policy/const.go +++ b/zitadel/v2/default_privacy_policy/const.go @@ -3,6 +3,6 @@ package default_privacy_policy const ( tosLinkVar = "tos_link" privacyLinkVar = "privacy_link" - helpLinkVar = "help_link" + HelpLinkVar = "help_link" supportEmailVar = "support_email" ) diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/v2/default_privacy_policy/funcs.go index 1804bb84..2caaf970 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/v2/default_privacy_policy/funcs.go @@ -30,11 +30,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } id := "" - if d.HasChanges(tosLinkVar, privacyLinkVar, helpLinkVar, supportEmailVar) { + if d.HasChanges(tosLinkVar, privacyLinkVar, HelpLinkVar, supportEmailVar) { resp, err := client.UpdatePrivacyPolicy(ctx, &admin.UpdatePrivacyPolicyRequest{ TosLink: d.Get(tosLinkVar).(string), PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + HelpLink: d.Get(HelpLinkVar).(string), SupportEmail: d.Get(supportEmailVar).(string), }) if helper.IgnorePreconditionError(err) != nil { @@ -81,7 +81,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ tosLinkVar: policy.GetTosLink(), privacyLinkVar: policy.GetPrivacyLink(), - helpLinkVar: policy.GetHelpLink(), + HelpLinkVar: policy.GetHelpLink(), supportEmailVar: policy.GetSupportEmail(), } diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/v2/default_privacy_policy/resource.go index 2503a115..6b927158 100644 --- a/zitadel/v2/default_privacy_policy/resource.go +++ b/zitadel/v2/default_privacy_policy/resource.go @@ -18,7 +18,7 @@ func GetResource() *schema.Resource { Required: true, Description: "", }, - helpLinkVar: { + HelpLinkVar: { Type: schema.TypeString, Required: true, Description: "", diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index ec0d3271..7d87b564 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -8,30 +8,20 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_privacy_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultPrivacyPolicy(t *testing.T) { - resourceName := "zitadel_default_privacy_policy" - updatedProperty := "https://zitadel.com" - initialProperty := "https://google.com" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_privacy_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, default_privacy_policy.HelpLinkVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - tos_link = "https://google.com" - privacy_link = "https://google.com" - support_email = "support@email.com" - help_link = "%s" -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "http://example.com/acctest", "", "", false, checkRemoteProperty(*frame), diff --git a/zitadel/v2/default_verify_email_message_text/resource.go b/zitadel/v2/default_verify_email_message_text/resource.go index 94a80b67..02be0702 100644 --- a/zitadel/v2/default_verify_email_message_text/resource.go +++ b/zitadel/v2/default_verify_email_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultVerifyEmailMessageTextResource) Delete(ctx context.Context, req func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 3f8c4dbb..109b6dc4 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -9,42 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_email_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultVerifyEmailMessageText(t *testing.T) { - resourceName := "zitadel_default_verify_email_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_verify_email_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_verify_email_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Verify email"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Verify email"), nil, nil, "", "", ) } diff --git a/zitadel/v2/default_verify_phone_message_text/resource.go b/zitadel/v2/default_verify_phone_message_text/resource.go index 0cdb9c14..0627b881 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource.go +++ b/zitadel/v2/default_verify_phone_message_text/resource.go @@ -18,7 +18,7 @@ import ( ) const ( - languageVar = "language" + LanguageVar = "language" ) var ( @@ -208,7 +208,7 @@ func (r *defaultVerifyPhoneMessageTextResource) Delete(ctx context.Context, req func setID(obj types.Object, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(language) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) string { @@ -217,7 +217,7 @@ func getID(ctx context.Context, obj types.Object) string { func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) string { var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } @@ -226,7 +226,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) s func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) string { var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "" } diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index 69f709a6..16f1e6ad 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -9,42 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_phone_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDefaultVerifyPhoneMessageText(t *testing.T) { - resourceName := "zitadel_default_verify_phone_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_default_verify_phone_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_verify_phone_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, language, configProperty) - }, - initialProperty, updatedProperty, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Verify phone"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Verify phone"), nil, nil, "", "", ) } diff --git a/zitadel/v2/domain/const.go b/zitadel/v2/domain/const.go index 80d8a9ed..d5d86fd2 100644 --- a/zitadel/v2/domain/const.go +++ b/zitadel/v2/domain/const.go @@ -2,7 +2,7 @@ package domain const ( orgIDVar = "org_id" - nameVar = "name" + NameVar = "name" isVerifiedVar = "is_verified" isPrimaryVar = "is_primary" validationTypeVar = "validation_type" diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index 60ede410..016cd5c5 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -65,7 +65,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - name := d.Get(nameVar).(string) + name := d.Get(NameVar).(string) _, err = client.AddOrgDomain(ctx, &management.AddOrgDomainRequest{ Domain: name, }) @@ -95,7 +95,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - name := d.Get(nameVar).(string) + name := d.Get(NameVar).(string) d.SetId(name) if d.HasChange(isPrimaryVar) { if d.Get(isPrimaryVar).(bool) { @@ -143,7 +143,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { domain := resp.Result[0] set := map[string]interface{}{ - nameVar: domain.GetDomainName(), + NameVar: domain.GetDomainName(), orgIDVar: domain.GetOrgId(), isVerifiedVar: domain.GetIsVerified(), isPrimaryVar: domain.GetIsPrimary(), diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index a708641d..647c19f7 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a domain of the organization.", Schema: map[string]*schema.Schema{ - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the domain", diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 846b3c60..8fb62b3a 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -10,33 +10,25 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDomain(t *testing.T) { - resourceName := "zitadel_domain" - initialProperty := "initial.default.127.0.0.1.sslip.io" + frame := test_utils.NewOrgTestFrame(t, "zitadel_domain") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, domain.NameVar, exampleAttributes).AsString() updatedProperty := "updated.default.127.0.0.1.sslip.io" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - is_primary = false -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, checkRemoteProperty(frame), - regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, initialProperty, updatedProperty)), + regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, exampleProperty, updatedProperty)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index 8aee1252..13b6cdeb 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index e6fa09b0..e3b4962b 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -9,43 +9,27 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDomainClaimedMessageText(t *testing.T) { - resourceName := "zitadel_domain_claimed_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_domain_claimed_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, default_domain_claimed_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", - false, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + true, + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("Zitadel - Domain has been claimed"), + checkRemoteProperty(frame, exampleLanguage)("Zitadel - Domain has been claimed"), nil, nil, "", "", ) } diff --git a/zitadel/v2/domain_policy/const.go b/zitadel/v2/domain_policy/const.go index 422a290e..39cdf7cb 100644 --- a/zitadel/v2/domain_policy/const.go +++ b/zitadel/v2/domain_policy/const.go @@ -2,7 +2,7 @@ package domain_policy const ( orgIDVar = "org_id" - userLoginMustBeDomainVar = "user_login_must_be_domain" + UserLoginMustBeDomainVar = "user_login_must_be_domain" validateOrgDomainVar = "validate_org_domains" smtpSenderVar = "smtp_sender_address_matches_instance_domain" ) diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 1fdc14cc..6ac5bc7c 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -51,7 +51,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateCustomDomainPolicy(ctx, &admin.UpdateCustomDomainPolicyRequest{ OrgId: org, - UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + UserLoginMustBeDomain: d.Get(UserLoginMustBeDomainVar).(bool), ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), }) @@ -78,7 +78,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.AddCustomDomainPolicy(ctx, &admin.AddCustomDomainPolicyRequest{ OrgId: org, - UserLoginMustBeDomain: d.Get(userLoginMustBeDomainVar).(bool), + UserLoginMustBeDomain: d.Get(UserLoginMustBeDomainVar).(bool), ValidateOrgDomains: d.Get(validateOrgDomainVar).(bool), SmtpSenderAddressMatchesInstanceDomain: d.Get(smtpSenderVar).(bool), }) @@ -119,7 +119,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set := map[string]interface{}{ orgIDVar: policy.GetDetails().GetResourceOwner(), - userLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), + UserLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), validateOrgDomainVar: policy.GetValidateOrgDomains(), smtpSenderVar: policy.GetSmtpSenderAddressMatchesInstanceDomain(), } diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/v2/domain_policy/resource.go index 08edb597..a4c194b9 100644 --- a/zitadel/v2/domain_policy/resource.go +++ b/zitadel/v2/domain_policy/resource.go @@ -14,7 +14,7 @@ func GetResource() *schema.Resource { Description: "Id for the organization", ForceNew: true, }, - userLoginMustBeDomainVar: { + UserLoginMustBeDomainVar: { Type: schema.TypeBool, Required: true, Description: "User login must be domain", diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 5152c9e4..b8e107e4 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -2,45 +2,37 @@ package domain_policy_test import ( "fmt" + "strconv" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) func TestAccDomainPolicy(t *testing.T) { - resourceName := "zitadel_domain_policy" - initialProperty := false - updatedProperty := true - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - otherFrame, err := frame.AnotherOrg("domain-policy-org-" + frame.UniqueResourcesID) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_domain_policy") + otherFrame := frame.AnotherOrg(t, "domain-policy-org-"+frame.UniqueResourcesID) + resourceExample, resourceAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, domain_policy.UserLoginMustBeDomainVar, resourceAttributes).True() + test_utils.RunLifecyleTest( t, otherFrame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_login_must_be_domain = %t - validate_org_domains = false - smtp_sender_address_matches_instance_domain = false -}`, resourceName, otherFrame.UniqueResourcesID, otherFrame.OrgID, configProperty) + []string{otherFrame.AsOrgDefaultDependency}, + func(property bool, secret string) string { + // only replace first bool for the smtp_sender_address_matches_instance_domain property + return strings.Replace(resourceExample, strconv.FormatBool(exampleProperty), strconv.FormatBool(property), 1) }, - initialProperty, updatedProperty, + exampleProperty, !exampleProperty, "", "", false, checkRemoteProperty(*otherFrame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*otherFrame)(initialProperty), + checkRemoteProperty(*otherFrame)(false), nil, nil, "", "", ) } diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/v2/helper/test_utils/base_frame.go index 1faf96cc..7c74fe7b 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/v2/helper/test_utils/base_frame.go @@ -3,13 +3,7 @@ package test_utils import ( "context" "fmt" - "os" - "path" - "strings" - "testing" - "github.com/hashicorp/hcl/v2" - "github.com/hashicorp/hcl/v2/hclparse" "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tfprotov6" @@ -17,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zclconf/go-cty/cty" "github.com/zitadel/terraform-provider-zitadel/zitadel" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" @@ -34,6 +27,7 @@ type BaseTestFrame struct { ClientInfo *helper.ClientInfo ProviderSnippet, UniqueResourcesID string ResourceType string + InstanceDomain string TerraformName string v6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error) } @@ -69,6 +63,7 @@ KEY UniqueResourcesID: uniqueID, TerraformName: terraformName, ResourceType: resourceType, + InstanceDomain: domain, } frame.v6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ "zitadel": func() (tfprotov6.ProviderServer, error) { @@ -101,44 +96,3 @@ func (b *BaseTestFrame) State(state *terraform.State) *terraform.InstanceState { } return resources["data."+b.TerraformName].Primary } - -type examplesFolder string - -const ( - Datasources examplesFolder = "data-sources" - Resources examplesFolder = "resources" -) - -func (b *BaseTestFrame) ReadExample(t *testing.T, folder examplesFolder, exampleType string) (string, hcl.Attributes) { - fileName := strings.Replace(exampleType, "zitadel_", "", 1) + ".tf" - filePath := path.Join("..", "..", "..", "examples", "provider", string(folder), fileName) - content, err := os.ReadFile(filePath) - if err != nil { - t.Fatalf("error reading example file: %v", err) - } - hclFile, diags := hclparse.NewParser().ParseHCL(content, filePath) - if diags.HasErrors() { - t.Fatalf("error parsing example file: %s", diags.Error()) - } - blocks := hclFile.BlocksAtPos(hcl.Pos{ - Line: 1, - Column: 1, - Byte: 1, - }) - if len(blocks) != 1 { - t.Fatalf("error parsing example file: %s", "unexpected number of blocks") - } - attr, diag := blocks[0].Body.JustAttributes() - if diag.HasErrors() { - t.Fatalf("error parsing example file: %s", diag.Error()) - } - return string(content), attr -} - -func AttributeValue(t *testing.T, key string, attributes hcl.Attributes) cty.Value { - val, diag := attributes[key].Expr.Value(&hcl.EvalContext{}) - if diag.HasErrors() { - t.Fatalf("error parsing example file: %s", diag.Error()) - } - return val -} diff --git a/zitadel/v2/helper/test_utils/dependency.go b/zitadel/v2/helper/test_utils/dependency.go new file mode 100644 index 00000000..df934b66 --- /dev/null +++ b/zitadel/v2/helper/test_utils/dependency.go @@ -0,0 +1,15 @@ +package test_utils + +import ( + "strings" + "testing" +) + +func CreateDefaultDependency(t *testing.T, datasourceType string, idField string, newDependencyID func() (string, error)) (string, string) { + datasourceExample, datasourceExampleAttributes := ReadExample(t, Datasources, datasourceType) + dependencyID, err := newDependencyID() + if err != nil { + t.Fatalf("failed to create dependency for %s: %v", datasourceType, err) + } + return strings.Replace(datasourceExample, AttributeValue(t, idField, datasourceExampleAttributes).AsString(), dependencyID, 1), dependencyID +} diff --git a/zitadel/v2/helper/test_utils/example.go b/zitadel/v2/helper/test_utils/example.go new file mode 100644 index 00000000..b4e1f750 --- /dev/null +++ b/zitadel/v2/helper/test_utils/example.go @@ -0,0 +1,64 @@ +package test_utils + +import ( + "fmt" + "os" + "path" + "strings" + "testing" + + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclparse" + "github.com/zclconf/go-cty/cty" +) + +type examplesFolder string + +const ( + Datasources examplesFolder = "data-sources" + Resources examplesFolder = "resources" +) + +func ReadExample(t *testing.T, folder examplesFolder, exampleType string) (string, hcl.Attributes) { + fileName := strings.Replace(exampleType, "zitadel_", "", 1) + ".tf" + filePath := path.Join("..", "..", "..", "examples", "provider", string(folder), fileName) + content, err := os.ReadFile(filePath) + if err != nil { + t.Fatalf("error reading example file: %v", err) + } + hclFile, diags := hclparse.NewParser().ParseHCL(content, filePath) + if diags.HasErrors() { + t.Fatalf("error parsing example file: %s", diags.Error()) + } + blocks := hclFile.BlocksAtPos(hcl.Pos{ + Line: 1, + Column: 1, + Byte: 1, + }) + if len(blocks) != 1 { + t.Fatalf("error parsing example file: %s", "unexpected number of blocks") + } + attr, diag := blocks[0].Body.JustAttributes() + if diag.HasErrors() { + t.Fatalf("error parsing example file: %s", diag.Error()) + } + return string(content), attr +} + +func AttributeValue(t *testing.T, key string, attributes hcl.Attributes) cty.Value { + val, diag := attributes[key].Expr.Value(&hcl.EvalContext{}) + if diag.HasErrors() { + t.Fatalf("error parsing example file: %s", diag.Error()) + } + return val +} + +func ReplaceAll[T comparable](resourceExample string, exampleProperty T, exampleSecret string) func(T, string) string { + return func(configProperty T, secretProperty string) string { + cfg := strings.ReplaceAll(resourceExample, fmt.Sprintf("%v", exampleProperty), fmt.Sprintf("%v", configProperty)) + if secretProperty != "" { + cfg = strings.Replace(cfg, exampleSecret, secretProperty, 1) + } + return cfg + } +} diff --git a/zitadel/v2/helper/test_utils/instance_frame.go b/zitadel/v2/helper/test_utils/instance_frame.go index bb678dbb..50e151ff 100644 --- a/zitadel/v2/helper/test_utils/instance_frame.go +++ b/zitadel/v2/helper/test_utils/instance_frame.go @@ -2,6 +2,7 @@ package test_utils import ( "context" + "testing" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" @@ -14,19 +15,19 @@ type InstanceTestFrame struct { *admin.Client } -func NewInstanceTestFrame(resourceType string) (*InstanceTestFrame, error) { +func NewInstanceTestFrame(t *testing.T, resourceType string) *InstanceTestFrame { ctx := context.Background() cfg := acceptance.GetConfig().InstanceLevel baseFrame, err := NewBaseTestFrame(ctx, resourceType, cfg.Domain, cfg.AdminSAJSON) if err != nil { - return nil, err + t.Fatalf("setting up test context failed: %v", err) } adminClient, err := helper.GetAdminClient(baseFrame.ClientInfo) if err != nil { - return nil, err + t.Fatalf("setting up test context failed: %v", err) } return &InstanceTestFrame{ BaseTestFrame: *baseFrame, Client: adminClient, - }, nil + } } diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/v2/helper/test_utils/org_frame.go index 380e7613..3bacf8dd 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/v2/helper/test_utils/org_frame.go @@ -3,6 +3,8 @@ package test_utils import ( "context" "fmt" + "strings" + "testing" "github.com/zitadel/zitadel-go/v2/pkg/client/admin" mgmt "github.com/zitadel/zitadel-go/v2/pkg/client/management" @@ -15,9 +17,9 @@ import ( type OrgTestFrame struct { BaseTestFrame *mgmt.Client - Admin *admin.Client - OrgID string - OrgExampleDatasource string + Admin *admin.Client + OrgID string + AsOrgDefaultDependency string } func (o *OrgTestFrame) useOrgContext(orgID string) (err error) { @@ -26,39 +28,46 @@ func (o *OrgTestFrame) useOrgContext(orgID string) (err error) { return err } o.Admin, err = helper.GetAdminClient(o.BaseTestFrame.ClientInfo) + o.AsOrgDefaultDependency = strings.Replace(o.AsOrgDefaultDependency, o.OrgID, orgID, 1) o.OrgID = orgID return err } -func NewOrgTestFrame(resourceType string) (*OrgTestFrame, error) { +func NewOrgTestFrame(t *testing.T, resourceType string) *OrgTestFrame { ctx := context.Background() cfg := acceptance.GetConfig().OrgLevel baseFrame, err := NewBaseTestFrame(ctx, resourceType, cfg.Domain, cfg.AdminSAJSON) if err != nil { - return nil, err + t.Fatalf("setting up test context failed: %v", err) } orgFrame := &OrgTestFrame{ BaseTestFrame: *baseFrame, } if err = orgFrame.useOrgContext(""); err != nil { - return nil, err + t.Fatalf("setting up test context failed: %v", err) } org, err := orgFrame.GetOrgByDomainGlobal(baseFrame, &management.GetOrgByDomainGlobalRequest{Domain: "zitadel." + cfg.Domain}) + if err != nil { + t.Fatalf("failed to get org by domain: %v", err) + } orgFrame.OrgID = org.GetOrg().GetId() - orgFrame.OrgExampleDatasource = fmt.Sprintf(` + orgFrame.AsOrgDefaultDependency = fmt.Sprintf(` data "zitadel_org" "default" { id = "%s" } `, orgFrame.OrgID) - return orgFrame, err + return orgFrame } -func (o OrgTestFrame) AnotherOrg(name string) (*OrgTestFrame, error) { +func (o OrgTestFrame) AnotherOrg(t *testing.T, name string) *OrgTestFrame { org, err := o.Client.AddOrg(o, &management.AddOrgRequest{ Name: name, }) if err != nil { - return nil, err + t.Fatalf("failed to create org: %v", err) + } + if err := o.useOrgContext(org.GetId()); err != nil { + t.Fatalf("failed to use org context: %v", err) } - return &o, o.useOrgContext(org.GetId()) + return &o } diff --git a/zitadel/v2/human_user/const.go b/zitadel/v2/human_user/const.go index 84519b75..db6abfe3 100644 --- a/zitadel/v2/human_user/const.go +++ b/zitadel/v2/human_user/const.go @@ -1,17 +1,17 @@ package human_user const ( - userIDVar = "user_id" + UserIDVar = "user_id" orgIDVar = "org_id" userStateVar = "state" - userNameVar = "user_name" + UserNameVar = "user_name" loginNamesVar = "login_names" preferredLoginNameVar = "preferred_login_name" firstNameVar = "first_name" lastNameVar = "last_name" nickNameVar = "nick_name" - displayNameVar = "display_name" + DisplayNameVar = "display_name" preferredLanguageVar = "preferred_language" genderVar = "gender" diff --git a/zitadel/v2/human_user/datasource.go b/zitadel/v2/human_user/datasource.go index 1ad13f91..977ae3f4 100644 --- a/zitadel/v2/human_user/datasource.go +++ b/zitadel/v2/human_user/datasource.go @@ -8,7 +8,7 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", @@ -23,7 +23,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "State of the user", }, - userNameVar: { + UserNameVar: { Type: schema.TypeString, Computed: true, Description: "Username", @@ -56,7 +56,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "Nick name of the user", }, - displayNameVar: { + DisplayNameVar: { Type: schema.TypeString, Computed: true, Description: "Display name of the user", diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index 04a86241..0caf125e 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -50,7 +50,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia firstName := d.Get(firstNameVar).(string) lastName := d.Get(lastNameVar).(string) addUser := &management.AddHumanUserRequest{ - UserName: d.Get(userNameVar).(string), + UserName: d.Get(UserNameVar).(string), Profile: &management.AddHumanUserRequest_Profile{ FirstName: firstName, LastName: lastName, @@ -61,10 +61,10 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia InitialPassword: d.Get(initialPasswordVar).(string), } - if displayname, ok := d.GetOk(displayNameVar); ok { + if displayname, ok := d.GetOk(DisplayNameVar); ok { addUser.Profile.DisplayName = displayname.(string) } else { - if err := d.Set(displayNameVar, defaultDisplayName(firstName, lastName)); err != nil { + if err := d.Set(DisplayNameVar, defaultDisplayName(firstName, lastName)); err != nil { return diag.Errorf("failed to set default display name for human user: %v", err) } } @@ -114,23 +114,23 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - if d.HasChange(userNameVar) { + if d.HasChange(UserNameVar) { _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ UserId: d.Id(), - UserName: d.Get(userNameVar).(string), + UserName: d.Get(UserNameVar).(string), }) if err != nil { return diag.Errorf("failed to update username: %v", err) } } - if d.HasChanges(firstNameVar, lastNameVar, nickNameVar, displayNameVar, preferredLanguageVar, genderVar) { + if d.HasChanges(firstNameVar, lastNameVar, nickNameVar, DisplayNameVar, preferredLanguageVar, genderVar) { _, err := client.UpdateHumanProfile(ctx, &management.UpdateHumanProfileRequest{ UserId: d.Id(), FirstName: d.Get(firstNameVar).(string), LastName: d.Get(lastNameVar).(string), NickName: d.Get(nickNameVar).(string), - DisplayName: d.Get(displayNameVar).(string), + DisplayName: d.Get(DisplayNameVar).(string), PreferredLanguage: d.Get(preferredLanguageVar).(string), Gender: user.Gender(user.Gender_value[d.Get(genderVar).(string)]), }) @@ -176,7 +176,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) + respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, UserIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -189,7 +189,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ orgIDVar: user.GetDetails().GetResourceOwner(), userStateVar: user.GetState().String(), - userNameVar: user.GetUserName(), + UserNameVar: user.GetUserName(), loginNamesVar: user.GetLoginNames(), preferredLoginNameVar: user.GetPreferredLoginName(), } @@ -198,7 +198,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if profile := human.GetProfile(); profile != nil { set[firstNameVar] = profile.GetFirstName() set[lastNameVar] = profile.GetLastName() - set[displayNameVar] = profile.GetDisplayName() + set[DisplayNameVar] = profile.GetDisplayName() set[nickNameVar] = profile.GetNickName() set[preferredLanguageVar] = profile.GetPreferredLanguage() if gender := profile.GetGender().String(); gender != "" { diff --git a/zitadel/v2/human_user/human_user_test_dep/dependency.go b/zitadel/v2/human_user/human_user_test_dep/dependency.go new file mode 100644 index 00000000..9cddc7db --- /dev/null +++ b/zitadel/v2/human_user/human_user_test_dep/dependency.go @@ -0,0 +1,27 @@ +package human_user_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_human_user", human_user.UserIDVar, func() (string, error) { + user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ + UserName: frame.UniqueResourcesID, + Profile: &management.ImportHumanUserRequest_Profile{ + FirstName: "Don't", + LastName: "Care", + }, + Email: &management.ImportHumanUserRequest_Email{ + Email: "dont@care.com", + IsEmailVerified: true, + }, + }) + return user.GetUserId(), err + }) +} diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index ea83f64c..389ce0bb 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -31,7 +31,7 @@ func GetResource() *schema.Resource { return EnumValueValidation(userStateVar, value.(string), user.UserState_value) },*/ }, - userNameVar: { + UserNameVar: { Type: schema.TypeString, Required: true, Description: "Username", @@ -67,7 +67,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "Nick name of the user", }, - displayNameVar: { + DisplayNameVar: { Type: schema.TypeString, Optional: true, Description: "Display name of the user", @@ -121,13 +121,13 @@ func GetResource() *schema.Resource { DeleteContext: delete, UpdateContext: update, CustomizeDiff: customdiff.All( - customdiff.IfValue(displayNameVar, func(ctx context.Context, value, meta interface{}) bool { + customdiff.IfValue(DisplayNameVar, func(ctx context.Context, value, meta interface{}) bool { if value == "" { return true } return false }, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { - return diff.SetNew(displayNameVar, defaultDisplayName(diff.Get(firstNameVar).(string), diff.Get(lastNameVar).(string))) + return diff.SetNew(DisplayNameVar, defaultDisplayName(diff.Get(firstNameVar).(string), diff.Get(lastNameVar).(string))) }), customdiff.IfValue(genderVar, func(ctx context.Context, value, meta interface{}) bool { if value == "" { diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index 79e9c954..fc0ccedb 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -2,6 +2,7 @@ package human_user_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -9,38 +10,22 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" ) func TestAccHumanUser(t *testing.T) { - resourceName := "zitadel_human_user" - initialProperty := "en" - updatedProperty := "de" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_human_user") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleUsername := test_utils.AttributeValue(t, human_user.UserNameVar, exampleAttributes).AsString() + resourceExample = strings.Replace(resourceExample, exampleUsername, frame.UniqueResourcesID, 1) + exampleProperty := test_utils.AttributeValue(t, human_user.DisplayNameVar, exampleAttributes).AsString() + updatedProperty := "updatedproperty" + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, secretProperty string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_name = "test@zitadel.com" - first_name = "firstname" - last_name = "lastname" - nick_name = "nickname" - display_name = "displayname" - preferred_language = "%s" - gender = "GENDER_MALE" - phone = "+41799999999" - is_phone_verified = true - email = "%s@example.com" - is_email_verified = true - initial_password = "Password1!" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty, frame.UniqueResourcesID) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(frame), @@ -57,7 +42,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.T if err != nil { return err } - actual := remoteResource.GetUser().GetHuman().GetProfile().GetPreferredLanguage() + actual := remoteResource.GetUser().GetHuman().GetProfile().GetDisplayName() if actual != expect { return fmt.Errorf("expected %s, but got %s", expect, actual) } diff --git a/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go b/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go new file mode 100644 index 00000000..cb424374 --- /dev/null +++ b/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go @@ -0,0 +1,27 @@ +package idp_azure_ad_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func Create(t *testing.T, frame test_utils.BaseTestFrame, client admin.AdminServiceClient) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_idp_azure_ad", idp_utils.IdpIDVar, func() (string, error) { + i, err := client.AddAzureADProvider(frame, &admin.AddAzureADProviderRequest{ + Name: "Azure AD " + frame.UniqueResourcesID, + Tenant: &idp.AzureADTenant{ + Type: &idp.AzureADTenant_TenantType{ + TenantType: idp.AzureADTenantType_AZURE_AD_TENANT_TYPE_COMMON, + }, + }, + ClientId: "dummy", + ClientSecret: "dummy", + }) + return i.GetId(), err + }) +} diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/v2/idp_azure_ad/resource_test.go index 77074675..3b9b5a39 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/v2/idp_azure_ad/resource_test.go @@ -1,33 +1,12 @@ package idp_azure_ad_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPAzureAD(t *testing.T) { - resourceName := "zitadel_idp_azure_ad" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" - email_verified = true - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_azure_ad", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/v2/idp_github/resource_test.go index b0dca150..d90785a2 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/v2/idp_github/resource_test.go @@ -1,31 +1,12 @@ package idp_github_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitHub(t *testing.T) { - resourceName := "zitadel_idp_github" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_github", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/v2/idp_github_es/resource_test.go index 3c77b4cf..57cb3c89 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/v2/idp_github_es/resource_test.go @@ -1,34 +1,12 @@ package idp_github_es_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitHubES(t *testing.T) { - resourceName := "zitadel_idp_github_es" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - authorization_endpoint = "https://auth.endpoint" - token_endpoint = "https://token.endpoint" - user_endpoint = "https://user.endpoint" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_github_es", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/v2/idp_gitlab/resource_test.go index 3fad74fb..62a232f7 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/v2/idp_gitlab/resource_test.go @@ -1,31 +1,12 @@ package idp_gitlab_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitLab(t *testing.T) { - resourceName := "zitadel_idp_gitlab" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_gitlab", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go index c81e7717..d2e3b8b0 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource_test.go @@ -1,32 +1,12 @@ package idp_gitlab_self_hosted_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitLabSelfHosted(t *testing.T) { - resourceName := "zitadel_idp_gitlab_self_hosted" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - issuer = "https://issuer" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_gitlab_self_hosted", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_google/idp_google_test_dep/dependency.go b/zitadel/v2/idp_google/idp_google_test_dep/dependency.go new file mode 100644 index 00000000..2742f2b8 --- /dev/null +++ b/zitadel/v2/idp_google/idp_google_test_dep/dependency.go @@ -0,0 +1,21 @@ +package idp_google_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func Create(t *testing.T, frame test_utils.BaseTestFrame, client admin.AdminServiceClient) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_idp_google", idp_utils.IdpIDVar, func() (string, error) { + i, err := client.AddGoogleProvider(frame, &admin.AddGoogleProviderRequest{ + Name: "Google " + frame.UniqueResourcesID, + ClientId: "dummy", + ClientSecret: "dummy", + }) + return i.GetId(), err + }) +} diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/v2/idp_google/resource_test.go index 6938fc39..31fcfde9 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/v2/idp_google/resource_test.go @@ -1,31 +1,12 @@ package idp_google_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGoogle(t *testing.T) { - resourceName := "zitadel_idp_google" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_utils.ClientSecretVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_google", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/v2/idp_ldap/resource_test.go index f629bf0d..867127a0 100644 --- a/zitadel/v2/idp_ldap/resource_test.go +++ b/zitadel/v2/idp_ldap/resource_test.go @@ -1,40 +1,12 @@ package idp_ldap_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" ) func TestAccInstanceIdPLDAP(t *testing.T) { - resourceName := "zitadel_idp_ldap" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - idp_test_utils.RunInstanceIDPLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" - servers = ["a server"] - start_tls = true - base_dn = "a base dn" - bind_dn = "a bind dn" - bind_password = "%s" - user_base = "a user base" - user_object_classes = ["a user object class"] - user_filters = ["a user filter"] - timeout = "5s" - id_attribute = "a id_attribute" - first_name_attribute = "a first name attribute" - last_name_attribute = "a last name attribute" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, name, secret) - }, idp_ldap.BindPasswordVar) + idp_test_utils.RunInstanceIDPLifecyleTest(t, "zitadel_idp_ldap", idp_ldap.BindPasswordVar) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/v2/idp_utils/idp_test_utils/checks.go index 97bcce30..60aa1d4b 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/v2/idp_utils/idp_test_utils/checks.go @@ -12,16 +12,16 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource.TestCheckFunc { - return func(expectName string) resource.TestCheckFunc { +func CheckCreationAllowed(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { + return func(expectAllowed bool) resource.TestCheckFunc { return func(state *terraform.State) error { remoteProvider, err := frame.Client.GetProviderByID(frame, &admin.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } - actual := remoteProvider.GetIdp().GetName() - if actual != expectName { - return fmt.Errorf("expected name %s, actual name: %s", expectName, actual) + actual := remoteProvider.GetIdp().GetConfig().GetOptions().GetIsCreationAllowed() + if actual != expectAllowed { + return fmt.Errorf("expected creation allowed to be %t, but got %t", expectAllowed, actual) } return nil } @@ -30,7 +30,7 @@ func CheckProviderName(frame test_utils.InstanceTestFrame) func(string) resource func CheckDestroy(frame test_utils.InstanceTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - err := CheckProviderName(frame)("")(state) + err := CheckCreationAllowed(frame)(true)(state) if status.Code(err) != codes.NotFound { return fmt.Errorf("expected not found error but got: %w", err) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index 9120f97a..0293b4d1 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -2,30 +2,35 @@ package idp_test_utils import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) -func RunInstanceIDPLifecyleTest( - t *testing.T, - frame test_utils.InstanceTestFrame, - resourceFunc func(string, string) string, - secretAttribute string, -) { +func RunInstanceIDPLifecyleTest(t *testing.T, resourceName, secretAttribute string) { const importedSecret = "an_imported_secret" - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, resourceName) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + nameProperty := test_utils.AttributeValue(t, idp_utils.NameVar, exampleAttributes).AsString() + // Using a unique name makes the test idempotent on failures + resourceExample = strings.Replace(resourceExample, nameProperty, frame.UniqueResourcesID, 1) + exampleProperty := test_utils.AttributeValue(t, idp_utils.IsCreationAllowedVar, exampleAttributes).True() + exampleSecret := test_utils.AttributeValue(t, secretAttribute, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - resourceFunc, - "an initial provider name", "an updated provider name", - "an_initial_secret", "an_updated_secret", + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), + true, false, + exampleSecret, "an_updated_secret", false, - CheckProviderName(frame), + CheckCreationAllowed(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - CheckDestroy(frame), + CheckDestroy(*frame), func(state *terraform.State) error { // Check the secret is imported correctly actual := frame.State(state).Attributes[secretAttribute] diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go index 7eb8dbc6..b7b76639 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/v2/init_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index d2967a79..8d523789 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -10,42 +10,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" ) func TestAccInitMessageText(t *testing.T) { - resourceName := "zitadel_init_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_init_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, init_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("Zitadel - Initialize User"), + checkRemoteProperty(frame, exampleLanguage)("Zitadel - Initialize User"), nil, nil, "", "", ) } diff --git a/zitadel/v2/instance_member/const.go b/zitadel/v2/instance_member/const.go index 7272c360..a3a282f5 100644 --- a/zitadel/v2/instance_member/const.go +++ b/zitadel/v2/instance_member/const.go @@ -2,5 +2,5 @@ package instance_member const ( userIDVar = "user_id" - rolesVar = "roles" + RolesVar = "roles" ) diff --git a/zitadel/v2/instance_member/funcs.go b/zitadel/v2/instance_member/funcs.go index 2d79e645..13c4ea6c 100644 --- a/zitadel/v2/instance_member/funcs.go +++ b/zitadel/v2/instance_member/funcs.go @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateIAMMember(ctx, &admin.UpdateIAMMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { return diag.Errorf("failed to update instance member: %v", err) @@ -74,7 +74,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia userID := d.Get(userIDVar).(string) resp, err := client.AddIAMMember(ctx, &admin.AddIAMMemberRequest{ UserId: userID, - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { return diag.Errorf("failed to create instance member: %v", err) @@ -118,7 +118,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn member := resp.Result[0] set := map[string]interface{}{ userIDVar: member.GetUserId(), - rolesVar: member.GetRoles(), + RolesVar: member.GetRoles(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/v2/instance_member/resource.go index d2c541a8..aa19b4dc 100644 --- a/zitadel/v2/instance_member/resource.go +++ b/zitadel/v2/instance_member/resource.go @@ -14,7 +14,7 @@ func GetResource() *schema.Resource { Description: "ID of the user", ForceNew: true, }, - rolesVar: { + RolesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index bd9d2f6d..5dea5231 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -7,46 +7,24 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" ) func TestAccInstanceMember(t *testing.T) { - resourceName := "zitadel_instance_member" - initialProperty := "IAM_OWNER" - updatedProperty := "IAM_OWNER_VIEWER" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ - UserName: frame.UniqueResourcesID, - Profile: &management.ImportHumanUserRequest_Profile{ - FirstName: "Don't", - LastName: "Care", - }, - Email: &management.ImportHumanUserRequest_Email{ - Email: "dont@care.com", - IsEmailVerified: true, - }, - }) - userID := user.GetUserId() - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_instance_member") + userDep, userID := human_user_test_dep.Create(t, frame) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, instance_member.RolesVar, exampleAttributes).AsValueSlice()[0].AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - user_id = "%s" - roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "IAM_OWNER_VIEWER", "", "", true, checkRemoteProperty(*frame, userID), diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index 5093a284..4c0b762a 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -1,7 +1,12 @@ package label_policy_test import ( + "encoding/base64" "fmt" + "io" + "os" + "regexp" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -12,39 +17,28 @@ import ( ) func TestAccLabelPolicy(t *testing.T) { - resourceName := "zitadel_label_policy" - initialProperty := "#5469d4" - updatedProperty := "#5469d3" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_label_policy") + testSVGFile := writeFile(t, strings.NewReader(testSVG)) + defer testSVGFile.Close() + defer os.Remove(testSVGFile.Name()) + testFontFile := writeFile(t, base64.NewDecoder(base64.StdEncoding, strings.NewReader(testFontBase64))) + defer testFontFile.Close() + defer os.Remove(testFontFile.Name()) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + resourceExample = regexp.MustCompile("/path/to/[a-zA-Z_]+\\.jpg").ReplaceAllString(resourceExample, testSVGFile.Name()) + resourceExample = regexp.MustCompile("/path/to/[a-zA-Z_]+\\.tff").ReplaceAllString(resourceExample, testFontFile.Name()) + exampleProperty := test_utils.AttributeValue(t, "primary_color", exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - primary_color = "%s" - hide_login_name_suffix = true - warn_color = "#cd3d56" - background_color = "#fafafa" - font_color = "#000000" - primary_color_dark = "#a5b4fc" - background_color_dark = "#111827" - warn_color_dark = "#ff3b5b" - font_color_dark = "#ffffff" - disable_watermark = false - set_active = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "#5469d3", "", "", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*frame)(initialProperty), + checkRemoteProperty(*frame)(exampleProperty), nil, nil, "", "", ) } @@ -64,3 +58,32 @@ func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.Te } } } + +func writeFile(t *testing.T, content io.Reader) *os.File { + file, err := os.CreateTemp("", "TestAccDefaultLabelPolicy") + if err != nil { + t.Fatalf("creating temp file failed: %v", err) + } + if _, err := io.Copy(file, content); err != nil { + t.Fatalf("writing temp file failed: %v", err) + } + return file +} + +const ( + testSVG = ` + + + +` + testFontBase64 = ` +AAEAAAAHAEAAAgAwY21hcAAJAHYAAAEAAAAALGdseWbxy2aYAAABNAAAAFxoZWFk8jXd+AAAAHwA +AAA2aGhlYQZhAMoAAAC0AAAAJGhtdHgEdABqAAAA+AAAAAhsb2NhAC4AFAAAASwAAAAGbWF4cAAF +AAsAAADYAAAAIAABAAAAAQAA9ZwpRF8PPPUAAgPoAAAAALSS9AAAAAAA3C+mXAAGAAACWAK8AAAA +AwACAAAAAAAAAAEAAAQA/nAAAAJYAAb//wJYAAEAAAAAAAAAAAAAAAAAAAACAAEAAAACAAsAAgAA +AAAAAAAAAAAAAAAAAAAAAAAAAAACWABkAhwABgAAAAEAAAADAAAADAAEACAAAAAEAAQAAQAAAEH/ +/wAAAEH////AAAEAAAAAAAAAFAAuAAAAAgBkAAACWAK8AAMABwAAMxEhESUhESFkAfT+NAGk/lwC +vP1EKAJsAAIABgAAAh0CkAACAAoAABMzAwETMxMjJyMHrcRj/vjaYN1ZPu9CAQsBQP21ApD9cMjI +AA== +` +) diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index dcb2c4f9..07c3589e 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -2,6 +2,7 @@ package lockout_policy_test import ( "fmt" + "strconv" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -12,29 +13,23 @@ import ( ) func TestAccLockoutPolicy(t *testing.T) { - resourceName := "zitadel_lockout_policy" - initialProperty := uint64(3) - updatedProperty := uint64(5) - frame, err := test_utils.NewOrgTestFrame(resourceName) + frame := test_utils.NewOrgTestFrame(t, "zitadel_lockout_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty, err := strconv.ParseUint(test_utils.AttributeValue(t, "max_password_attempts", exampleAttributes).AsString(), 10, 64) if err != nil { - t.Fatalf("setting up test context failed: %v", err) + t.Fatalf("could not parse example property: %v", err) } - test_utils.RunLifecyleTest[uint64]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty uint64, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - max_password_attempts = "%d" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, 10, "", "", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*frame)(uint64(0)), + checkRemoteProperty(*frame)(0), nil, nil, "", "", ) } diff --git a/zitadel/v2/login_policy/const.go b/zitadel/v2/login_policy/const.go index ed75c06c..d8188bab 100644 --- a/zitadel/v2/login_policy/const.go +++ b/zitadel/v2/login_policy/const.go @@ -14,7 +14,7 @@ const ( secondFactorCheckLifetimeVar = "second_factor_check_lifetime" multiFactorCheckLifetimeVar = "multi_factor_check_lifetime" ignoreUnknownUsernamesVar = "ignore_unknown_usernames" - defaultRedirectURIVar = "default_redirect_uri" + DefaultRedirectURIVar = "default_redirect_uri" secondFactorsVar = "second_factors" multiFactorsVar = "multi_factors" idpsVar = "idps" diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 2799545a..b37fb7b9 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -58,7 +58,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia passwordlessTypeVar, hidePasswordResetVar, ignoreUnknownUsernamesVar, - defaultRedirectURIVar, + DefaultRedirectURIVar, passwordCheckLifetimeVar, externalLoginCheckLifetimeVar, mfaInitSkipLifetimeVar, @@ -96,7 +96,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), HidePasswordReset: d.Get(hidePasswordResetVar).(bool), IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), - DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), + DefaultRedirectUri: d.Get(DefaultRedirectURIVar).(string), PasswordCheckLifetime: durationpb.New(passwordCheckLT), ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), @@ -229,7 +229,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia PasswordlessType: policy.PasswordlessType(policy.PasswordlessType_value[d.Get(passwordlessTypeVar).(string)]), HidePasswordReset: d.Get(hidePasswordResetVar).(bool), IgnoreUnknownUsernames: d.Get(ignoreUnknownUsernamesVar).(bool), - DefaultRedirectUri: d.Get(defaultRedirectURIVar).(string), + DefaultRedirectUri: d.Get(DefaultRedirectURIVar).(string), PasswordCheckLifetime: durationpb.New(passwordCheckLT), ExternalLoginCheckLifetime: durationpb.New(externalLoginCheckLT), MfaInitSkipLifetime: durationpb.New(mfaInitSkipLT), @@ -321,7 +321,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn passwordlessTypeVar: policy.GetPasswordlessType().String(), hidePasswordResetVar: policy.GetHidePasswordReset(), ignoreUnknownUsernamesVar: policy.GetIgnoreUnknownUsernames(), - defaultRedirectURIVar: policy.GetDefaultRedirectUri(), + DefaultRedirectURIVar: policy.GetDefaultRedirectUri(), passwordCheckLifetimeVar: policy.GetPasswordCheckLifetime().AsDuration().String(), externalLoginCheckLifetimeVar: policy.GetExternalLoginCheckLifetime().AsDuration().String(), mfaInitSkipLifetimeVar: policy.GetMfaInitSkipLifetime().AsDuration().String(), diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index b26337d8..9e4bedee 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -49,7 +49,7 @@ func GetResource() *schema.Resource { Required: true, Description: "defines if unknown username on login screen directly return an error or always display the password screen", }, - defaultRedirectURIVar: { + DefaultRedirectURIVar: { Type: schema.TypeString, Required: true, Description: "defines where the user will be redirected to if the login is started without app context (e.g. from mail)", diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index 676fd41d..0fab648c 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -9,63 +9,42 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" ) func TestAccLoginPolicy(t *testing.T) { - resourceName := "zitadel_login_policy" - initialProperty := true - updatedProperty := false - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_login_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, login_policy.DefaultRedirectURIVar, exampleAttributes).AsString() + azureADDep, _ := idp_azure_ad_test_dep.Create(t, frame.BaseTestFrame, frame.Admin) + googleDep, _ := idp_google_test_dep.Create(t, frame.BaseTestFrame, frame.Admin) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_login = %t - allow_register = true - allow_external_idp = true - force_mfa = false - passwordless_type = "PASSWORDLESS_TYPE_ALLOWED" - hide_password_reset = "false" - password_check_lifetime = "240h0m0s" - external_login_check_lifetime = "240h0m0s" - multi_factor_check_lifetime = "24h0m0s" - mfa_init_skip_lifetime = "720h0m0s" - second_factor_check_lifetime = "24h0m0s" - ignore_unknown_usernames = true - default_redirect_uri = "localhost:8080" - second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] - multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - allow_domain_discovery = true - disable_login_with_email = true - disable_login_with_phone = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, azureADDep, googleDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "localhost:9090", "", "", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*frame)(initialProperty), + checkRemoteProperty(*frame)(""), nil, nil, "", "", ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { - return func(expect bool) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetLoginPolicy(frame, &management.GetLoginPolicyRequest{}) if err != nil { return fmt.Errorf("getting policy failed: %w", err) } - actual := resp.GetPolicy().GetAllowUsernamePassword() + actual := resp.GetPolicy().GetDefaultRedirectUri() if actual != expect { - return fmt.Errorf("expected %t, but got %t", expect, actual) + return fmt.Errorf("expected %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index f80ff810..b4dc0a42 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index bc418c63..08a1a409 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -10,321 +10,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_texts" ) func TestAccLoginTexts(t *testing.T) { - resourceName := "zitadel_login_texts" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_login_texts") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := "example" + exampleLanguage := test_utils.AttributeValue(t, login_texts.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - email_verification_done_text = { - cancel_button_text = "example" - description = "example" - login_button_text = "example" - next_button_text = "example" - title = "%s" - } - email_verification_text = { - code_label = "example" - description = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - external_registration_user_overview_text = { - back_button_text = "example" - description = "example" - email_label = "example" - firstname_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - nickname_label = "example" - phone_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - external_user_not_found_text = { - auto_register_button_text = "example" - description = "example" - link_button_text = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - } - footer_text = { - help = "example" - privacy_policy = "example" - tos = "example" - } - init_mfa_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_mfa_otp_text = { - cancel_button_text = "example" - code_label = "example" - description = "example" - description_otp = "example" - next_button_text = "example" - secret_label = "example" - title = "example" - } - init_mfa_prompt_text = { - description = "example" - next_button_text = "example" - otp_option = "example" - skip_button_text = "example" - title = "example" - u2f_option = "example" - } - init_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - init_password_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - init_password_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - initialize_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - initialize_user_text = { - code_label = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - resend_button_text = "example" - title = "example" - } - linking_user_done_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - } - login_text = { - description = "example" - description_linking_process = "example" - external_user_description = "example" - login_name_label = "example" - login_name_placeholder = "example" - next_button_text = "example" - register_button_text = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - user_name_placeholder = "example" - } - logout_text = { - description = "example" - login_button_text = "example" - title = "example" - } - mfa_providers_text = { - choose_other = "example" - otp = "example" - u2f = "example" - } - password_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_change_text = { - cancel_button_text = "example" - description = "example" - new_password_confirm_label = "example" - new_password_label = "example" - next_button_text = "example" - old_password_label = "example" - title = "example" - } - password_reset_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - password_text = { - back_button_text = "example" - confirmation = "example" - description = "example" - has_lowercase = "example" - has_number = "example" - has_symbol = "example" - has_uppercase = "example" - min_length = "example" - next_button_text = "example" - password_label = "example" - reset_link_text = "example" - title = "example" - } - passwordless_prompt_text = { - description = "example" - description_init = "example" - next_button_text = "example" - passwordless_button_text = "example" - skip_button_text = "example" - title = "example" - } - passwordless_registration_done_text = { - cancel_button_text = "example" - description = "example" - description_close = "example" - next_button_text = "example" - title = "example" - } - passwordless_registration_text = { - description = "example" - error_retry = "example" - not_supported = "example" - register_token_button_text = "example" - title = "example" - token_name_label = "example" - } - passwordless_text = { - description = "example" - error_retry = "example" - login_with_pw_button_text = "example" - not_supported = "example" - title = "example" - validate_token_button_text = "example" - } - registration_option_text = { - description = "example" - external_login_description = "example" - title = "example" - user_name_button_text = "example" - } - registration_org_text = { - description = "example" - email_label = "example" - firstname_label = "example" - lastname_label = "example" - orgname_label = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - save_button_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - registration_user_text = { - back_button_text = "example" - description = "example" - description_org_register = "example" - email_label = "example" - firstname_label = "example" - gender_label = "example" - language_label = "example" - lastname_label = "example" - next_button_text = "example" - password_confirm_label = "example" - password_label = "example" - privacy_link_text = "example" - title = "example" - tos_and_privacy_label = "example" - tos_confirm = "example" - tos_confirm_and = "example" - tos_link_text = "example" - username_label = "example" - } - select_account_text = { - description = "example" - description_linking_process = "example" - other_user = "example" - session_state_active = "example" - session_state_inactive = "example" - title = "example" - title_linking_process = "example" - user_must_be_member_of_org = "example" - } - success_login_text = { - auto_redirect_description = "example" - next_button_text = "example" - redirected_description = "example" - title = "example" - } - username_change_done_text = { - description = "example" - next_button_text = "example" - title = "example" - } - username_change_text = { - cancel_button_text = "example" - description = "example" - next_button_text = "example" - title = "example" - username_label = "example" - } - verify_mfa_otp_text = { - code_label = "example" - description = "example" - next_button_text = "example" - title = "example" - } - verify_mfa_u2f_text = { - description = "example" - error_retry = "example" - not_supported = "example" - title = "example" - validate_token_text = "example" - } -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtext", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)(""), + checkRemoteProperty(frame, exampleLanguage)(""), nil, nil, "", "", ) } diff --git a/zitadel/v2/machine_key/const.go b/zitadel/v2/machine_key/const.go index ce57aa59..9b255aa5 100644 --- a/zitadel/v2/machine_key/const.go +++ b/zitadel/v2/machine_key/const.go @@ -5,5 +5,5 @@ const ( userIDVar = "user_id" keyTypeVar = "key_type" keyDetailsVar = "key_details" - expirationDateVar = "expiration_date" + ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go index 746bbe9b..90359b15 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/v2/machine_key/funcs.go @@ -57,7 +57,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia Type: authn.KeyType(authn.KeyType_value[keyType]), } - if expiration, ok := d.GetOk(expirationDateVar); ok { + if expiration, ok := d.GetOk(ExpirationDateVar); ok { t, err := time.Parse(time.RFC3339, expiration.(string)) if err != nil { return diag.Errorf("failed to parse time: %v", err) @@ -104,7 +104,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(resp.GetKey().GetId()) set := map[string]interface{}{ - expirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), + ExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), userIDVar: userID, orgIDVar: orgID, } diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index 36d53fd2..cccaf8c5 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -34,7 +34,7 @@ func GetResource() *schema.Resource { return helper.EnumValueValidation(keyTypeVar, value, authn.KeyType_value) }, }, - expirationDateVar: { + ExpirationDateVar: { Type: schema.TypeString, Optional: true, Description: "Expiration date of the machine key in the RFC3339 format", diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index 7764de03..218e158e 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -9,37 +9,21 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" ) func TestAccMachineKey(t *testing.T) { - resourceName := "zitadel_machine_key" - initialProperty := "2050-01-01T00:00:00Z" - updatedProperty := "2051-01-01T00:00:00Z" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - user, err := frame.AddMachineUser(frame, &management.AddMachineUserRequest{ - UserName: frame.UniqueResourcesID, - Name: "Don't care", - }) - userID := user.GetUserId() - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_machine_key") + userDep, userID := machine_user_test_dep.Create(t, frame) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, machine_key.ExpirationDateVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_id = "%s" - key_type = "KEY_TYPE_JSON" - expiration_date = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "2051-01-01T00:00:00Z", "", "", false, checkRemoteProperty(*frame, userID), diff --git a/zitadel/v2/machine_user/const.go b/zitadel/v2/machine_user/const.go index 4d077e54..e8ae79a4 100644 --- a/zitadel/v2/machine_user/const.go +++ b/zitadel/v2/machine_user/const.go @@ -5,16 +5,15 @@ import ( ) const ( - userIDVar = "user_id" + UserIDVar = "user_id" orgIDVar = "org_id" userStateVar = "state" - userNameVar = "user_name" + UserNameVar = "user_name" loginNamesVar = "login_names" preferredLoginNameVar = "preferred_login_name" - - nameVar = "name" - descriptionVar = "description" - accessTokenTypeVar = "access_token_type" + nameVar = "name" + DescriptionVar = "description" + accessTokenTypeVar = "access_token_type" ) var ( diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index b0977bf9..c7005d3a 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -6,7 +6,7 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", @@ -21,7 +21,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "State of the user", }, - userNameVar: { + UserNameVar: { Type: schema.TypeString, Computed: true, Description: "Username", @@ -45,7 +45,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "Name of the machine user", }, - descriptionVar: { + DescriptionVar: { Type: schema.TypeString, Computed: true, Description: "Description of the user", diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 6e302009..07ee3261 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -48,9 +48,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } respUser, err := client.AddMachineUser(ctx, &management.AddMachineUserRequest{ - UserName: d.Get(userNameVar).(string), + UserName: d.Get(UserNameVar).(string), Name: d.Get(nameVar).(string), - Description: d.Get(descriptionVar).(string), + Description: d.Get(DescriptionVar).(string), AccessTokenType: user.AccessTokenType(user.AccessTokenType_value[(d.Get(accessTokenTypeVar).(string))]), }) if err != nil { @@ -75,21 +75,21 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - if d.HasChange(userNameVar) { + if d.HasChange(UserNameVar) { _, err = client.UpdateUserName(ctx, &management.UpdateUserNameRequest{ UserId: d.Id(), - UserName: d.Get(userNameVar).(string), + UserName: d.Get(UserNameVar).(string), }) if err != nil { return diag.Errorf("failed to update username: %v", err) } } - if d.HasChanges(nameVar, descriptionVar, accessTokenTypeVar) { + if d.HasChanges(nameVar, DescriptionVar, accessTokenTypeVar) { _, err := client.UpdateMachine(ctx, &management.UpdateMachineRequest{ UserId: d.Id(), Name: d.Get(nameVar).(string), - Description: d.Get(descriptionVar).(string), + Description: d.Get(DescriptionVar).(string), AccessTokenType: user.AccessTokenType(user.AccessTokenType_value[(d.Get(accessTokenTypeVar).(string))]), }) if err != nil { @@ -112,7 +112,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, userIDVar)}) + respUser, err := client.GetUserByID(ctx, &management.GetUserByIDRequest{Id: helper.GetID(d, UserIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -125,13 +125,13 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ orgIDVar: user.GetDetails().GetResourceOwner(), userStateVar: user.GetState().String(), - userNameVar: user.GetUserName(), + UserNameVar: user.GetUserName(), loginNamesVar: user.GetLoginNames(), preferredLoginNameVar: user.GetPreferredLoginName(), } if machine := user.GetMachine(); machine != nil { set[nameVar] = machine.GetName() - set[descriptionVar] = machine.GetDescription() + set[DescriptionVar] = machine.GetDescription() set[accessTokenTypeVar] = machine.GetAccessTokenType().String() } for k, v := range set { diff --git a/zitadel/v2/machine_user/machine_user_test_dep/dependency.go b/zitadel/v2/machine_user/machine_user_test_dep/dependency.go new file mode 100644 index 00000000..3313f1df --- /dev/null +++ b/zitadel/v2/machine_user/machine_user_test_dep/dependency.go @@ -0,0 +1,21 @@ +package machine_user_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_machine_user", machine_user.UserIDVar, func() (string, error) { + user, err := frame.AddMachineUser(frame, &management.AddMachineUserRequest{ + UserName: frame.UniqueResourcesID, + Name: "Don't care", + }) + userID := user.GetUserId() + return userID, err + }) +} diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 9765085d..3d47e771 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -28,7 +28,7 @@ func GetResource() *schema.Resource { return EnumValueValidation(userStateVar, value.(string), user.UserState_value) },*/ }, - userNameVar: { + UserNameVar: { Type: schema.TypeString, Required: true, Description: "Username", @@ -51,7 +51,7 @@ func GetResource() *schema.Resource { Required: true, Description: "Name of the machine user", }, - descriptionVar: { + DescriptionVar: { Type: schema.TypeString, Optional: true, Description: "Description of the user", diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go index fd30c3ad..b7c7b995 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/v2/machine_user/resource_test.go @@ -2,6 +2,7 @@ package machine_user_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -9,34 +10,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" ) func TestAccMachineUser(t *testing.T) { - resourceName := "zitadel_machine_user" - initialProperty := "Initial Service Account" - updatedProperty := "Updated Service Account" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_machine_user") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleUsername := test_utils.AttributeValue(t, machine_user.UserNameVar, exampleAttributes).AsString() + resourceExample = strings.Replace(resourceExample, exampleUsername, frame.UniqueResourcesID, 1) + exampleProperty := test_utils.AttributeValue(t, machine_user.DescriptionVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, secretProperty string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_name = "%s" - name = "%s" - description = "description" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, frame.UniqueResourcesID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedproperty", "", "", false, checkRemoteProperty(frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), nil, nil, "", "", ) } @@ -48,7 +41,7 @@ func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.T if err != nil { return err } - actual := remoteResource.GetUser().GetMachine().GetName() + actual := remoteResource.GetUser().GetMachine().GetDescription() if actual != expect { return fmt.Errorf("expected %s, but got %s", expect, actual) } diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index dda16fb1..d8c11d93 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -12,23 +12,16 @@ import ( ) func TestAccNotificationPolicy(t *testing.T) { - resourceName := "zitadel_notification_policy" + frame := test_utils.NewOrgTestFrame(t, "zitadel_notification_policy") + resourceExample, _ := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := false initialProperty := true updatedProperty := false - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[bool]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - password_change = %t -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, "", "", false, diff --git a/zitadel/v2/org/const.go b/zitadel/v2/org/const.go index 76793447..450075aa 100644 --- a/zitadel/v2/org/const.go +++ b/zitadel/v2/org/const.go @@ -1,11 +1,11 @@ package org const ( - orgIDVar = "id" + OrgIDVar = "id" orgIDsVar = "ids" - nameVar = "name" + NameVar = "name" nameMethodVar = "name_method" - domainVar = "domain" + DomainVar = "domain" domainMethodVar = "domain_method" stateVar = "state" primaryDomainVar = "primary_domain" diff --git a/zitadel/v2/org/datasource.go b/zitadel/v2/org/datasource.go index 04ce44cb..a546ca2c 100644 --- a/zitadel/v2/org/datasource.go +++ b/zitadel/v2/org/datasource.go @@ -14,12 +14,12 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", Schema: map[string]*schema.Schema{ - orgIDVar: { + OrgIDVar: { Type: schema.TypeString, Required: true, Description: "An organizations resource ID.", }, - nameVar: { + NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the org.", @@ -49,7 +49,7 @@ func ListDatasources() *schema.Resource { Description: "A set of all organization IDs.", Elem: &schema.Schema{Type: schema.TypeString}, }, - nameVar: { + NameVar: { Type: schema.TypeString, Optional: true, Description: "Name of the org.", @@ -63,7 +63,7 @@ func ListDatasources() *schema.Resource { }, Default: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS_IGNORE_CASE.String(), }, - domainVar: { + DomainVar: { Type: schema.TypeString, Optional: true, Description: "A domain of the org.", diff --git a/zitadel/v2/org/datasource_test.go b/zitadel/v2/org/datasource_test.go index 3503effd..569cf42f 100644 --- a/zitadel/v2/org/datasource_test.go +++ b/zitadel/v2/org/datasource_test.go @@ -2,30 +2,23 @@ package org_test import ( "fmt" + "strings" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" ) func TestAccOrgDatasource_ID(t *testing.T) { - datasourceName := "zitadel_org" - frame, err := test_utils.NewOrgTestFrame(datasourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } + frame := test_utils.NewOrgTestFrame(t, "zitadel_org") orgName := "org_datasource_" + frame.UniqueResourcesID - otherFrame, err := frame.AnotherOrg(orgName) - if err != nil { - t.Fatalf("could not switch to another org: %v", err) - } + otherFrame := frame.AnotherOrg(t, orgName) test_utils.RunDatasourceTest( t, otherFrame.BaseTestFrame, - fmt.Sprintf(` -data "%s" "%s" { - id = "%s" -} -`, datasourceName, otherFrame.UniqueResourcesID, otherFrame.OrgID), + otherFrame.AsOrgDefaultDependency, nil, map[string]string{ "id": otherFrame.OrgID, @@ -35,26 +28,24 @@ data "%s" "%s" { ) } -func TestAccOrgDatasources_ID_Name_Match(t *testing.T) { +func TestAccOrgsDatasources_ID_Name_Match(t *testing.T) { datasourceName := "zitadel_orgs" - frame, err := test_utils.NewOrgTestFrame(datasourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - orgName := "org_datasource_" + frame.UniqueResourcesID - otherFrame, err := frame.AnotherOrg(orgName) - if err != nil { - t.Fatalf("could not switch to another org: %v", err) - } + frame := test_utils.NewOrgTestFrame(t, datasourceName) + config, attributes := test_utils.ReadExample(t, test_utils.Datasources, datasourceName) + exampleName := test_utils.AttributeValue(t, org.NameVar, attributes).AsString() + exampleDomain := test_utils.AttributeValue(t, org.DomainVar, attributes).AsString() + orgName := fmt.Sprintf("%s-%s", exampleName, frame.UniqueResourcesID) + // for-each is not supported in acceptance tests, so we cut the example down to the first block + // https://github.com/hashicorp/terraform-plugin-sdk/issues/536 + config = strings.Join(strings.Split(config, "\n")[0:7], "\n") + config = strings.Replace(config, exampleName, orgName, 1) + config = strings.Replace(config, exampleDomain, orgName, 1) + otherFrame := frame.AnotherOrg(t, orgName) test_utils.RunDatasourceTest( t, otherFrame.BaseTestFrame, - fmt.Sprintf(` -data "%s" "%s" { - name = "%s" -} -`, datasourceName, otherFrame.UniqueResourcesID, orgName), - nil, + config, + checkRemoteProperty(otherFrame, idFromFrame(otherFrame))(orgName), map[string]string{ "ids.0": otherFrame.OrgID, "ids.#": "1", @@ -62,26 +53,23 @@ data "%s" "%s" { ) } -func TestAccOrgDatasources_ID_Name_Mismatch(t *testing.T) { +func TestAccOrgsDatasources_ID_Name_Mismatch(t *testing.T) { datasourceName := "zitadel_orgs" - frame, err := test_utils.NewOrgTestFrame(datasourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - orgName := "org_datasource_" + frame.UniqueResourcesID - otherFrame, err := frame.AnotherOrg(orgName) - if err != nil { - t.Fatalf("could not switch to another org: %v", err) - } + frame := test_utils.NewOrgTestFrame(t, datasourceName) + config, attributes := test_utils.ReadExample(t, test_utils.Datasources, datasourceName) + orgName := fmt.Sprintf("%s_%s", test_utils.AttributeValue(t, org.NameVar, attributes), frame.UniqueResourcesID) + otherFrame := frame.AnotherOrg(t, orgName) test_utils.RunDatasourceTest( t, otherFrame.BaseTestFrame, - fmt.Sprintf(` -data "%s" "%s" { - name = "mismatching_org_name" -} -`, datasourceName, otherFrame.UniqueResourcesID), - nil, + config, + checkRemoteProperty(otherFrame, idFromFrame(otherFrame))(orgName), map[string]string{"ids.#": "0"}, ) } + +func idFromFrame(frame *test_utils.OrgTestFrame) func(state *terraform.State) string { + return func(state *terraform.State) string { + return frame.OrgID + } +} diff --git a/zitadel/v2/org/funcs.go b/zitadel/v2/org/funcs.go index 9eb89f04..306497d8 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/v2/org/funcs.go @@ -45,7 +45,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } resp, err := client.AddOrg(ctx, &management.AddOrgRequest{ - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), }) if err != nil { return diag.FromErr(err) @@ -66,7 +66,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateOrg(ctx, &management.UpdateOrgRequest{ - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), }) if err != nil { return diag.Errorf("failed to update org: %v", err) @@ -84,7 +84,7 @@ func get(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagno if err != nil { return diag.FromErr(err) } - orgID := helper.GetID(d, orgIDVar) + orgID := helper.GetID(d, OrgIDVar) resp, err := client.GetOrgByID(ctx, &admin.GetOrgByIDRequest{ Id: orgID, }) @@ -93,7 +93,7 @@ func get(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagno } remoteOrg := resp.GetOrg() d.SetId(remoteOrg.Id) - if err := d.Set(nameVar, remoteOrg.Name); err != nil { + if err := d.Set(NameVar, remoteOrg.Name); err != nil { return diag.Errorf("error while setting org name %s: %v", remoteOrg.Name, err) } if err := d.Set(primaryDomainVar, remoteOrg.PrimaryDomain); err != nil { @@ -108,9 +108,9 @@ func get(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagno func list(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started list") - orgName := d.Get(nameVar).(string) + orgName := d.Get(NameVar).(string) orgNameMethod := d.Get(nameMethodVar).(string) - orgDomain := d.Get(domainVar).(string) + orgDomain := d.Get(DomainVar).(string) orgDomainMethod := d.Get(domainMethodVar).(string) orgState := d.Get(stateVar).(string) clientinfo, ok := m.(*helper.ClientInfo) diff --git a/zitadel/v2/org/org_test_dep/dependency.go b/zitadel/v2/org/org_test_dep/dependency.go new file mode 100644 index 00000000..fc0b1405 --- /dev/null +++ b/zitadel/v2/org/org_test_dep/dependency.go @@ -0,0 +1,18 @@ +package org_test_dep + +import ( + "fmt" + "strings" + "testing" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame, resourceName string) (string, string, *test_utils.OrgTestFrame) { + otherFrame := frame.AnotherOrg(t, fmt.Sprintf("%s_%s", resourceName, frame.UniqueResourcesID)) + cfg, id := test_utils.CreateDefaultDependency(t, "zitadel_org", org.OrgIDVar, func() (string, error) { + return otherFrame.OrgID, nil + }) + return strings.Replace(cfg, "default", resourceName, 1), id, otherFrame +} diff --git a/zitadel/v2/org/remote_test.go b/zitadel/v2/org/remote_test.go index 27cae84a..22c49aa1 100644 --- a/zitadel/v2/org/remote_test.go +++ b/zitadel/v2/org/remote_test.go @@ -11,10 +11,10 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { +func checkRemoteProperty(frame *test_utils.OrgTestFrame, id func(state *terraform.State) string) func(string) resource.TestCheckFunc { return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: frame.State(state).ID}) + remoteResource, err := frame.Admin.GetOrgByID(frame, &admin.GetOrgByIDRequest{Id: id(state)}) if err != nil { return err } diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go index 300d6ae2..f3a385ab 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/v2/org/resource.go @@ -8,7 +8,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an organization in ZITADEL, which is the highest level after the instance and contains several other resource including policies if the configuration differs to the default policies on the instance.", Schema: map[string]*schema.Schema{ - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the org", diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index 928f4ed1..24b16c06 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -1,35 +1,37 @@ package org_test import ( - "fmt" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" ) func TestAccOrg(t *testing.T) { - resourceName := "zitadel_org" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } + frame := test_utils.NewOrgTestFrame(t, "zitadel_org") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, org.NameVar, exampleAttributes).AsString() initialProperty := "initialorgname_" + frame.UniqueResourcesID updatedProperty := "updatedorgname_" + frame.UniqueResourcesID - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - name = "%s" -}`, resourceName, frame.UniqueResourcesID, configProperty) - }, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, "", "", false, - checkRemoteProperty(frame), + checkRemoteProperty(frame, idFromState(frame)), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, idFromState(frame)), updatedProperty), nil, nil, "", "", ) } + +func idFromState(frame *test_utils.OrgTestFrame) func(*terraform.State) string { + return func(state *terraform.State) string { + return frame.State(state).ID + } +} diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/v2/org_idp_azure_ad/resource_test.go index 41774f29..afe372ca 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/v2/org_idp_azure_ad/resource_test.go @@ -1,34 +1,12 @@ package org_idp_azure_ad_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPAzureAD(t *testing.T) { - resourceName := "zitadel_org_idp_azure_ad" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - tenant_type = "AZURE_AD_TENANT_TYPE_COMMON" - email_verified = true - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_azure_ad", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/v2/org_idp_github/resource_test.go index ea3c889d..4761f629 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/v2/org_idp_github/resource_test.go @@ -1,32 +1,12 @@ package org_idp_github_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitHub(t *testing.T) { - resourceName := "zitadel_org_idp_github" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_github", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/v2/org_idp_github_es/resource_test.go index ffe5fc2d..57f08216 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/v2/org_idp_github_es/resource_test.go @@ -1,35 +1,12 @@ package org_idp_github_es_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitHubES(t *testing.T) { - resourceName := "zitadel_org_idp_github_es" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - authorization_endpoint = "https://auth.endpoint" - token_endpoint = "https://token.endpoint" - user_endpoint = "https://user.endpoint" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_github_es", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/v2/org_idp_gitlab/resource_test.go index 2f70aaaf..4d2f063e 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/v2/org_idp_gitlab/resource_test.go @@ -1,32 +1,12 @@ package org_idp_gitlab_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitLab(t *testing.T) { - resourceName := "zitadel_org_idp_gitlab" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_gitlab", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go index 59a7acd3..7d09c32b 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go @@ -1,33 +1,12 @@ package org_idp_gitlab_self_hosted_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitLabSelfHosted(t *testing.T) { - resourceName := "zitadel_org_idp_gitlab_self_hosted" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - issuer = "https://issuer" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_gitlab_self_hosted", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go b/zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go new file mode 100644 index 00000000..7eeeb512 --- /dev/null +++ b/zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go @@ -0,0 +1,20 @@ +package org_idp_google_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" +) + +func Create(t *testing.T, frame *test_utils.InstanceTestFrame) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_idp_google", idp_utils.IdpIDVar, func() (string, error) { + i, err := frame.AddGoogleProvider(frame, &admin.AddGoogleProviderRequest{ + Name: "Google " + frame.UniqueResourcesID, + ClientId: "dummy", + }) + return i.GetId(), err + }) +} diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/v2/org_idp_google/resource_test.go index c129df07..6f4f98a6 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/v2/org_idp_google/resource_test.go @@ -1,32 +1,12 @@ package org_idp_google_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGoogle(t *testing.T) { - resourceName := "zitadel_org_idp_google" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - scopes = ["two", "scopes"] - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_google", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_jwt/const.go b/zitadel/v2/org_idp_jwt/const.go index 60ec8116..02bccfdf 100644 --- a/zitadel/v2/org_idp_jwt/const.go +++ b/zitadel/v2/org_idp_jwt/const.go @@ -7,7 +7,7 @@ const ( stylingTypeVar = "styling_type" issuerVar = "issuer" autoRegisterVar = "auto_register" - jwtEndpointVar = "jwt_endpoint" + JwtEndpointVar = "jwt_endpoint" keysEndpointVar = "keys_endpoint" headerNameVar = "header_name" ) diff --git a/zitadel/v2/org_idp_jwt/datasource.go b/zitadel/v2/org_idp_jwt/datasource.go index 009e7665..5b607469 100644 --- a/zitadel/v2/org_idp_jwt/datasource.go +++ b/zitadel/v2/org_idp_jwt/datasource.go @@ -28,7 +28,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "Some identity providers specify the styling of the button to their login", }, - jwtEndpointVar: { + JwtEndpointVar: { Type: schema.TypeString, Computed: true, Description: "the endpoint where the jwt can be extracted", diff --git a/zitadel/v2/org_idp_jwt/funcs.go b/zitadel/v2/org_idp_jwt/funcs.go index 2c5772e3..aaf54dfd 100644 --- a/zitadel/v2/org_idp_jwt/funcs.go +++ b/zitadel/v2/org_idp_jwt/funcs.go @@ -50,7 +50,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddOrgJWTIDP(ctx, &management.AddOrgJWTIDPRequest{ Name: d.Get(nameVar).(string), StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), - JwtEndpoint: d.Get(jwtEndpointVar).(string), + JwtEndpoint: d.Get(JwtEndpointVar).(string), Issuer: d.Get(issuerVar).(string), KeysEndpoint: d.Get(keysEndpointVar).(string), HeaderName: d.Get(headerNameVar).(string), @@ -88,10 +88,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChanges(jwtEndpointVar, issuerVar, keysEndpointVar, headerNameVar) { + if d.HasChanges(JwtEndpointVar, issuerVar, keysEndpointVar, headerNameVar) { _, err = client.UpdateOrgIDPJWTConfig(ctx, &management.UpdateOrgIDPJWTConfigRequest{ IdpId: d.Id(), - JwtEndpoint: d.Get(jwtEndpointVar).(string), + JwtEndpoint: d.Get(JwtEndpointVar).(string), Issuer: d.Get(issuerVar).(string), KeysEndpoint: d.Get(keysEndpointVar).(string), HeaderName: d.Get(headerNameVar).(string), @@ -131,7 +131,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn orgIDVar: idp.GetDetails().ResourceOwner, nameVar: idp.GetName(), stylingTypeVar: idp.GetStylingType().String(), - jwtEndpointVar: jwt.GetJwtEndpoint(), + JwtEndpointVar: jwt.GetJwtEndpoint(), issuerVar: jwt.GetIssuer(), keysEndpointVar: jwt.GetKeysEndpoint(), headerNameVar: jwt.GetHeaderName(), diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index 8b6e4c68..2d20f85f 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -33,7 +33,7 @@ func GetResource() *schema.Resource { return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) }, }, - jwtEndpointVar: { + JwtEndpointVar: { Type: schema.TypeString, Required: true, Description: "the endpoint where the jwt can be extracted", diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go index a5fada5f..2c07d87c 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -2,6 +2,7 @@ package org_idp_jwt_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -9,52 +10,43 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" ) func TestAccOrgIDPJWT(t *testing.T) { - resourceName := "zitadel_org_idp_jwt" - initialProperty := "https://initialproperty.com" - updatedProperty := "https://updatedproperty.com" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_org_idp_jwt") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, org_idp_jwt.JwtEndpointVar, exampleAttributes).AsString() + updatedProperty := "https://example.com/updated" + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, + []string{frame.AsOrgDefaultDependency}, func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - styling_type = "STYLING_TYPE_UNSPECIFIED" - jwt_endpoint = "%s" - issuer = "https://google.com" - keys_endpoint = "https://jwtendpoint.com/keys" - header_name = "x-auth-token" - auto_register = false -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, frame.UniqueResourcesID, configProperty) + return strings.Replace(resourceExample, exampleProperty, configProperty, 1) }, - initialProperty, updatedProperty, + exampleProperty, updatedProperty, "", "", - false, - checkRemoteProperty(frame), + true, + checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame *test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { return func(expect string) resource.TestCheckFunc { return func(state *terraform.State) error { - remoteResource, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{Id: frame.State(state).ID}) + resp, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{ + Id: frame.State(state).ID, + }) if err != nil { return err } - actual := remoteResource.GetIdp().GetJwtConfig().GetJwtEndpoint() - if actual != expect { - return fmt.Errorf("expected %s, but got %s", expect, actual) + actual := resp.GetIdp().GetJwtConfig().GetJwtEndpoint() + if expect != actual { + return fmt.Errorf("expected jwt endpoint %s, but got %s", expect, actual) } return nil } diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index 269905b2..28b82610 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -1,41 +1,13 @@ package org_idp_ldap_test import ( - "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPLDAP(t *testing.T) { - resourceName := "zitadel_org_idp_ldap" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - servers = ["a server"] - start_tls = true - base_dn = "a base dn" - bind_dn = "a bind dn" - bind_password = "%s" - user_base = "a user base" - user_object_classes = ["a user object class"] - user_filters = ["a user filter"] - timeout = "5s" - id_attribute = "a id_attribute" - first_name_attribute = "a first name attribute" - last_name_attribute = "a last name attribute" - is_linking_allowed = false - is_creation_allowed = true - is_auto_creation = false - is_auto_update = true -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_ldap.BindPasswordVar) + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_ldap", idp_ldap.BindPasswordVar) + } diff --git a/zitadel/v2/org_idp_oidc/const.go b/zitadel/v2/org_idp_oidc/const.go index f30fc8d3..7200ded4 100644 --- a/zitadel/v2/org_idp_oidc/const.go +++ b/zitadel/v2/org_idp_oidc/const.go @@ -9,7 +9,7 @@ const ( clientSecretVar = "client_secret" issuerVar = "issuer" scopesVar = "scopes" - displayNameMappingVar = "display_name_mapping" + DisplayNameMappingVar = "display_name_mapping" usernameMappingVar = "username_mapping" autoRegisterVar = "auto_register" ) diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go index 87acf1c3..dfd71212 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -53,7 +53,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - displayNameMappingVar: { + DisplayNameMappingVar: { Type: schema.TypeString, Computed: true, Description: "definition which field is mapped to the display name of the user", diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index 5683b382..34da65f0 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -54,7 +54,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia ClientSecret: d.Get(clientSecretVar).(string), Issuer: d.Get(issuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, scopesVar), - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(displayNameMappingVar).(string)]), + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(DisplayNameMappingVar).(string)]), UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), AutoRegister: d.Get(autoRegisterVar).(bool), }) @@ -91,14 +91,14 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } } - if d.HasChanges(clientIDVar, clientSecretVar, issuerVar, displayNameMappingVar, usernameMappingVar, scopesVar) { + if d.HasChanges(clientIDVar, clientSecretVar, issuerVar, DisplayNameMappingVar, usernameMappingVar, scopesVar) { _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ IdpId: d.Id(), ClientId: d.Get(clientIDVar).(string), ClientSecret: d.Get(clientSecretVar).(string), Issuer: d.Get(issuerVar).(string), Scopes: helper.GetOkSetToStringSlice(d, scopesVar), - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(displayNameMappingVar).(string)]), + DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(DisplayNameMappingVar).(string)]), UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), }) if err != nil { @@ -141,7 +141,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn clientSecretVar: d.Get(clientSecretVar).(string), issuerVar: oidc.GetIssuer(), scopesVar: oidc.GetScopes(), - displayNameMappingVar: oidc.GetDisplayNameMapping().String(), + DisplayNameMappingVar: oidc.GetDisplayNameMapping().String(), usernameMappingVar: oidc.GetUsernameMapping().String(), autoRegisterVar: idp.GetAutoRegister(), } diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index a3ca27e7..89c12ef0 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -58,7 +58,7 @@ func GetResource() *schema.Resource { Required: true, Description: "the scopes requested by ZITADEL during the request on the identity provider", }, - displayNameMappingVar: { + DisplayNameMappingVar: { Type: schema.TypeString, Required: true, Description: "definition which field is mapped to the display name of the user", diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go index 9b42c70f..642048c7 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -2,32 +2,54 @@ package org_idp_oidc_test import ( "fmt" + "strings" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" ) -func TestAccOrgIdPOIDC(t *testing.T) { - resourceName := "zitadel_org_idp_oidc" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) +func TestAccOrgIDPJWT(t *testing.T) { + frame := test_utils.NewOrgTestFrame(t, "zitadel_org_idp_oidc") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, org_idp_oidc.DisplayNameMappingVar, exampleAttributes).AsString() + updatedProperty := idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL.String() + test_utils.RunLifecyleTest( + t, + frame.BaseTestFrame, + []string{frame.AsOrgDefaultDependency}, + func(configProperty, _ string) string { + return strings.Replace(resourceExample, exampleProperty, configProperty, 1) + }, + exampleProperty, updatedProperty, + "", "", + true, + checkRemoteProperty(*frame), + test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), + nil, nil, "", "", + ) +} + +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { + return func(expect string) resource.TestCheckFunc { + return func(state *terraform.State) error { + resp, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{ + Id: frame.State(state).ID, + }) + if err != nil { + return err + } + actual := resp.GetIdp().GetOidcConfig().GetDisplayNameMapping().String() + if expect != actual { + return fmt.Errorf("expected jwt endpoint %s, but got %s", expect, actual) + } + return nil + } } - org_idp_test_utils.RunOrgLifecyleTest(t, *frame, func(name, secret string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - client_id = "aclientid" - client_secret = "%s" - styling_type = "STYLING_TYPE_UNSPECIFIED" - issuer = "https://google.com" - scopes = ["openid", "profile", "email"] - display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - auto_register = false -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, name, secret) - }, idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go index 5b94252f..568f84fe 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go @@ -12,16 +12,16 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) -func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { - return func(expectName string) resource.TestCheckFunc { +func CheckCreationAllowed(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { + return func(expectAllowed bool) resource.TestCheckFunc { return func(state *terraform.State) error { remoteProvider, err := frame.GetProviderByID(frame, &management.GetProviderByIDRequest{Id: frame.State(state).ID}) if err != nil { return err } - actual := remoteProvider.GetIdp().GetName() - if actual != expectName { - return fmt.Errorf("expected name %s, but got name %s", expectName, actual) + actual := remoteProvider.GetIdp().GetConfig().GetOptions().GetIsCreationAllowed() + if actual != expectAllowed { + return fmt.Errorf("expected creation allowed to be %t, but got %t", expectAllowed, actual) } return nil } @@ -30,7 +30,7 @@ func CheckProviderName(frame test_utils.OrgTestFrame) func(string) resource.Test func CheckDestroy(frame test_utils.OrgTestFrame) resource.TestCheckFunc { return func(state *terraform.State) error { - err := CheckProviderName(frame)("")(state) + err := CheckCreationAllowed(frame)(false)(state) if status.Code(err) != codes.NotFound { return fmt.Errorf("expected not found error but got: %w", err) } diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 9499e129..3f424532 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -2,31 +2,36 @@ package org_idp_test_utils import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) -func RunOrgLifecyleTest( - t *testing.T, - frame test_utils.OrgTestFrame, - resourceFunc func(string, string) string, - secretAttribute string, -) { +func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { const importedSecret = "an_imported_secret" - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, resourceName) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + nameProperty := test_utils.AttributeValue(t, idp_utils.NameVar, exampleAttributes).AsString() + // Using a unique name makes the test idempotent on failures + resourceExample = strings.Replace(resourceExample, nameProperty, frame.UniqueResourcesID, 1) + exampleProperty := test_utils.AttributeValue(t, idp_utils.IsCreationAllowedVar, exampleAttributes).True() + exampleSecret := test_utils.AttributeValue(t, secretAttribute, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - resourceFunc, - "an initial provider name", "an updated provider name", - "an_initial_secret", "an_updated_secret", + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), + true, false, + exampleSecret, "an_updated_secret", false, - CheckProviderName(frame), + CheckCreationAllowed(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - CheckDestroy(frame), + CheckDestroy(*frame), func(state *terraform.State) error { // Check the secretAttribute is imported correctly actual := frame.State(state).Attributes[secretAttribute] diff --git a/zitadel/v2/org_member/const.go b/zitadel/v2/org_member/const.go index 4ef49dd9..bbdc3261 100644 --- a/zitadel/v2/org_member/const.go +++ b/zitadel/v2/org_member/const.go @@ -3,5 +3,5 @@ package org_member const ( orgIDVar = "org_id" userIDVar = "user_id" - rolesVar = "roles" + RolesVar = "roles" ) diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index c3c0c8de..f30f8306 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateOrgMember(ctx, &management.UpdateOrgMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { return diag.Errorf("failed to update orgmember: %v", err) @@ -75,7 +75,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia userID := d.Get(userIDVar).(string) _, err = client.AddOrgMember(ctx, &management.AddOrgMemberRequest{ UserId: userID, - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { return diag.Errorf("failed to create orgmember: %v", err) @@ -120,7 +120,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ userIDVar: orgMember.GetUserId(), orgIDVar: orgMember.GetDetails().GetResourceOwner(), - rolesVar: orgMember.GetRoles(), + RolesVar: orgMember.GetRoles(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_member/resource.go b/zitadel/v2/org_member/resource.go index a5ab4c8b..e9aebad0 100644 --- a/zitadel/v2/org_member/resource.go +++ b/zitadel/v2/org_member/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { Description: "ID of the user", ForceNew: true, }, - rolesVar: { + RolesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index 3a194db8..9ccfd01b 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -10,43 +10,22 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" ) func TestAccOrgMember(t *testing.T) { - resourceName := "zitadel_org_member" - initialProperty := "ORG_OWNER" + frame := test_utils.NewOrgTestFrame(t, "zitadel_org_member") + userDep, userID := human_user_test_dep.Create(t, frame) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, org_member.RolesVar, exampleAttributes).AsValueSlice()[0].AsString() updatedProperty := "ORG_OWNER_VIEWER" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ - UserName: frame.UniqueResourcesID, - Profile: &management.ImportHumanUserRequest_Profile{ - FirstName: "Don't", - LastName: "Care", - }, - Email: &management.ImportHumanUserRequest_Email{ - Email: "dont@care.com", - IsEmailVerified: true, - }, - }) - userID := user.GetUserId() - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_id = "%s" - roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, checkRemoteProperty(*frame, userID), diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/v2/password_change_message_text/resource.go index 2584d820..704db239 100644 --- a/zitadel/v2/password_change_message_text/resource.go +++ b/zitadel/v2/password_change_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index ea5513c3..2ccb48b1 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -10,42 +10,27 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_change_message_text" ) func TestAccPasswordChangeMessageText(t *testing.T) { - resourceName := "zitadel_password_change_message_text" - initialProperty := "initialtitle" + frame := test_utils.NewOrgTestFrame(t, "zitadel_password_change_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + exampleLanguage := test_utils.AttributeValue(t, password_change_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Password of user has changed"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Password of user has changed"), nil, nil, "", "", ) } diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index bbfec642..f9b78d32 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -2,6 +2,7 @@ package password_complexity_policy_test import ( "fmt" + "strconv" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -12,47 +13,38 @@ import ( ) func TestAccPasswordComplexityPolicy(t *testing.T) { - resourceName := "zitadel_password_complexity_policy" - initialProperty := true - updatedProperty := false - frame, err := test_utils.NewOrgTestFrame(resourceName) + frame := test_utils.NewOrgTestFrame(t, "zitadel_password_complexity_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty, err := strconv.ParseUint(test_utils.AttributeValue(t, "min_length", exampleAttributes).AsString(), 10, 64) if err != nil { - t.Fatalf("setting up test context failed: %v", err) + t.Fatalf("could not parse example property: %v", err) } - test_utils.RunLifecyleTest[bool]( + updatedProperty := uint64(10) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty bool, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - min_length = "8" - has_uppercase = true - has_lowercase = true - has_number = true - has_symbol = %t -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, - checkRemoteProperty(*frame)(initialProperty), + checkRemoteProperty(*frame)(exampleProperty), nil, nil, "", "", ) } -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { - return func(expect bool) resource.TestCheckFunc { +func checkRemoteProperty(frame test_utils.OrgTestFrame) func(uint64) resource.TestCheckFunc { + return func(expect uint64) resource.TestCheckFunc { return func(state *terraform.State) error { resp, err := frame.GetPasswordComplexityPolicy(frame, &management.GetPasswordComplexityPolicyRequest{}) if err != nil { return fmt.Errorf("getting policy failed: %w", err) } - actual := resp.GetPolicy().GetHasSymbol() + actual := resp.GetPolicy().GetMinLength() if actual != expect { - return fmt.Errorf("expected %t, but got %t", expect, actual) + return fmt.Errorf("expected %d, but got %d", expect, actual) } return nil } diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index efd9ce70..8740e163 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index bee49c27..57d0bfde 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -10,42 +10,27 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_reset_message_text" ) func TestAccPasswordResetMessageText(t *testing.T) { - resourceName := "zitadel_password_reset_message_text" - initialProperty := "initialtitle" + frame := test_utils.NewOrgTestFrame(t, "zitadel_password_reset_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + exampleLanguage := test_utils.AttributeValue(t, password_reset_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("Zitadel - Reset password"), + checkRemoteProperty(frame, exampleLanguage)("Zitadel - Reset password"), nil, nil, "", "", ) } diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go index 5b263239..215495dd 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index 57195677..7ddd2da4 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -10,42 +10,27 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/passwordless_registration_message_text" ) func TestAccPasswordlessRegistrationMessageText(t *testing.T) { - resourceName := "zitadel_passwordless_registration_message_text" - initialProperty := "initialtitle" + frame := test_utils.NewOrgTestFrame(t, "zitadel_passwordless_registration_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + exampleLanguage := test_utils.AttributeValue(t, passwordless_registration_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("ZITADEL - Add Passwordless Login"), + checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Add Passwordless Login"), nil, nil, "", "", ) } diff --git a/zitadel/v2/pat/const.go b/zitadel/v2/pat/const.go index ba910db3..d7334d5d 100644 --- a/zitadel/v2/pat/const.go +++ b/zitadel/v2/pat/const.go @@ -4,5 +4,5 @@ const ( orgIDVar = "org_id" userIDVar = "user_id" tokenVar = "token" - expirationDateVar = "expiration_date" + ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go index 93d71f98..02fd5c02 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/v2/pat/funcs.go @@ -53,7 +53,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia req := &management.AddPersonalAccessTokenRequest{ UserId: d.Get(userIDVar).(string), } - if expiration, ok := d.GetOk(expirationDateVar); ok { + if expiration, ok := d.GetOk(ExpirationDateVar); ok { t, err := time.Parse(time.RFC3339, expiration.(string)) if err != nil { return diag.Errorf("failed to parse time: %v", err) @@ -100,7 +100,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set := map[string]interface{}{ - expirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), + ExpirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), userIDVar: userID, orgIDVar: orgID, } diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index e4b0ca5e..d5b52f0e 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -26,7 +26,7 @@ func GetResource() *schema.Resource { Description: "Value of the token", Sensitive: true, }, - expirationDateVar: { + ExpirationDateVar: { Type: schema.TypeString, Optional: true, Description: "Expiration date of the token in the RFC3339 format", diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index 2c32822d..3be50f4e 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -9,36 +9,22 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" ) func TestAccPersonalAccessToken(t *testing.T) { - resourceName := "zitadel_personal_access_token" - initialProperty := "2050-01-01T00:00:00Z" + frame := test_utils.NewOrgTestFrame(t, "zitadel_personal_access_token") + userDep, userID := machine_user_test_dep.Create(t, frame) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, pat.ExpirationDateVar, exampleAttributes).AsString() updatedProperty := "2051-01-01T00:00:00Z" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - user, err := frame.AddMachineUser(frame, &management.AddMachineUserRequest{ - UserName: frame.UniqueResourcesID, - Name: "Don't care", - }) - userID := user.GetUserId() - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - user_id = "%s" - expiration_date = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(*frame, userID), diff --git a/zitadel/v2/privacy_policy/const.go b/zitadel/v2/privacy_policy/const.go index 17acc93f..10e390ce 100644 --- a/zitadel/v2/privacy_policy/const.go +++ b/zitadel/v2/privacy_policy/const.go @@ -4,6 +4,6 @@ const ( orgIDVar = "org_id" tosLinkVar = "tos_link" privacyLinkVar = "privacy_link" - helpLinkVar = "help_link" + HelpLinkVar = "help_link" supportEmailVar = "support_email" ) diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index 5d5221de..02b4aa89 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -49,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateCustomPrivacyPolicy(ctx, &management.UpdateCustomPrivacyPolicyRequest{ TosLink: d.Get(tosLinkVar).(string), PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + HelpLink: d.Get(HelpLinkVar).(string), SupportEmail: d.Get(supportEmailVar).(string), }) if err != nil { @@ -75,7 +75,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.AddCustomPrivacyPolicy(ctx, &management.AddCustomPrivacyPolicyRequest{ TosLink: d.Get(tosLinkVar).(string), PrivacyLink: d.Get(privacyLinkVar).(string), - HelpLink: d.Get(helpLinkVar).(string), + HelpLink: d.Get(HelpLinkVar).(string), SupportEmail: d.Get(supportEmailVar).(string), }) if err != nil { @@ -117,7 +117,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn orgIDVar: policy.GetDetails().GetResourceOwner(), tosLinkVar: policy.GetTosLink(), privacyLinkVar: policy.GetPrivacyLink(), - helpLinkVar: policy.GetHelpLink(), + HelpLinkVar: policy.GetHelpLink(), supportEmailVar: policy.GetSupportEmail(), } diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go index da54651d..be732eed 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/v2/privacy_policy/resource.go @@ -24,7 +24,7 @@ func GetResource() *schema.Resource { Required: true, Description: "", }, - helpLinkVar: { + HelpLinkVar: { Type: schema.TypeString, Required: true, Description: "", diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index 557a523f..4eca409e 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -9,30 +9,19 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" ) func TestAccPrivacyPolicy(t *testing.T) { - resourceName := "zitadel_privacy_policy" - updatedProperty := "https://example.com" - initialProperty := "https://httpbin.org" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_privacy_policy") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, privacy_policy.HelpLinkVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - tos_link = "https://google.com" - privacy_link = "https://google.com" - support_email = "support@email.com" - help_link = "%s" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "http://example.com/acctest", "", "", false, checkRemoteProperty(*frame), diff --git a/zitadel/v2/project/const.go b/zitadel/v2/project/const.go index a623d19f..ca552f24 100644 --- a/zitadel/v2/project/const.go +++ b/zitadel/v2/project/const.go @@ -3,8 +3,8 @@ package project import "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" const ( - projectIDVar = "project_id" - nameVar = "name" + ProjectIDVar = "project_id" + NameVar = "name" stateVar = "state" orgIDVar = "org_id" roleAssertionVar = "project_role_assertion" diff --git a/zitadel/v2/project/datasource.go b/zitadel/v2/project/datasource.go index 7c6f2d90..65323cc3 100644 --- a/zitadel/v2/project/datasource.go +++ b/zitadel/v2/project/datasource.go @@ -8,12 +8,12 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing the project, which can then be granted to different organizations or users directly, containing different applications.", Schema: map[string]*schema.Schema{ - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", }, - nameVar: { + NameVar: { Type: schema.TypeString, Computed: true, Description: "Name of the project", diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go index cc0f99b4..1ab5a1ac 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/v2/project/funcs.go @@ -49,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProject(ctx, &management.UpdateProjectRequest{ Id: d.Id(), - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), ProjectRoleCheck: d.Get(roleCheckVar).(bool), ProjectRoleAssertion: d.Get(roleAssertionVar).(bool), HasProjectCheck: d.Get(hasProjectCheckVar).(bool), @@ -77,7 +77,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia plSetting := d.Get(privateLabelingSettingVar).(string) resp, err := client.AddProject(ctx, &management.AddProjectRequest{ - Name: d.Get(nameVar).(string), + Name: d.Get(NameVar).(string), ProjectRoleAssertion: d.Get(roleAssertionVar).(bool), ProjectRoleCheck: d.Get(roleCheckVar).(bool), HasProjectCheck: d.Get(hasProjectCheckVar).(bool), @@ -103,7 +103,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - resp, err := client.GetProjectByID(ctx, &management.GetProjectByIDRequest{Id: helper.GetID(d, projectIDVar)}) + resp, err := client.GetProjectByID(ctx, &management.GetProjectByIDRequest{Id: helper.GetID(d, ProjectIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -116,7 +116,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ orgIDVar: project.GetDetails().GetResourceOwner(), stateVar: project.GetState().String(), - nameVar: project.GetName(), + NameVar: project.GetName(), roleAssertionVar: project.GetProjectRoleAssertion(), roleCheckVar: project.GetProjectRoleCheck(), hasProjectCheckVar: project.GetHasProjectCheck(), diff --git a/zitadel/v2/project/project_test_dep/dependency.go b/zitadel/v2/project/project_test_dep/dependency.go new file mode 100644 index 00000000..9bf740c0 --- /dev/null +++ b/zitadel/v2/project/project_test_dep/dependency.go @@ -0,0 +1,17 @@ +package project_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { + return test_utils.CreateDefaultDependency(t, "zitadel_project", project.ProjectIDVar, func() (string, error) { + p, err := frame.AddProject(frame, &management.AddProjectRequest{Name: frame.UniqueResourcesID}) + return p.GetId(), err + }) +} diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index 5b5bba34..eab7934e 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -13,7 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the project, which can then be granted to different organizations or users directly, containing different applications.", Schema: map[string]*schema.Schema{ - nameVar: { + NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the project", diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go index cc1e62ab..5366797d 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/v2/project/resource_test.go @@ -9,31 +9,20 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" ) func TestAccProject(t *testing.T) { - resourceName := "zitadel_project" - initialProperty := "initialproperty" + frame := test_utils.NewOrgTestFrame(t, "zitadel_project") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, project.NameVar, exampleAttributes).AsString() updatedProperty := "updatedproperty" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - name = "%s" - project_role_assertion = true - project_role_check = true - has_project_check = true - private_labeling_setting = "PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(frame), diff --git a/zitadel/v2/project_grant/const.go b/zitadel/v2/project_grant/const.go index cf2c9bd0..34bf5bc3 100644 --- a/zitadel/v2/project_grant/const.go +++ b/zitadel/v2/project_grant/const.go @@ -4,5 +4,5 @@ const ( orgIDVar = "org_id" projectIDVar = "project_id" grantedOrgIDVar = "granted_org_id" - roleKeysVar = "role_keys" + RoleKeysVar = "role_keys" ) diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go index 42684684..025bc94b 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/v2/project_grant/funcs.go @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectGrant(ctx, &management.UpdateProjectGrantRequest{ GrantId: d.Id(), ProjectId: d.Get(projectIDVar).(string), - RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), + RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { return diag.Errorf("failed to update projectgrant: %v", err) @@ -74,7 +74,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddProjectGrant(ctx, &management.AddProjectGrantRequest{ GrantedOrgId: d.Get(grantedOrgIDVar).(string), ProjectId: d.Get(projectIDVar).(string), - RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), + RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { return diag.Errorf("failed to create projectgrant: %v", err) @@ -109,7 +109,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ projectIDVar: projectGrant.GetProjectId(), grantedOrgIDVar: projectGrant.GetGrantedOrgId(), - roleKeysVar: projectGrant.GetGrantedRoleKeys(), + RoleKeysVar: projectGrant.GetGrantedRoleKeys(), orgIDVar: projectGrant.GetDetails().GetResourceOwner(), } for k, v := range set { diff --git a/zitadel/v2/project_grant/project_grant_test_dep/dependency.go b/zitadel/v2/project_grant/project_grant_test_dep/dependency.go new file mode 100644 index 00000000..d7f485fe --- /dev/null +++ b/zitadel/v2/project_grant/project_grant_test_dep/dependency.go @@ -0,0 +1,20 @@ +package project_grant_test_dep + +import ( + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID, grantedOrgID string) string { + dep, err := frame.AddProjectGrant(frame, &management.AddProjectGrantRequest{ + ProjectId: projectID, + GrantedOrgId: grantedOrgID, + }) + if err != nil { + t.Errorf("failed to create a project grant: %v", err) + } + return dep.GetGrantId() +} diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/v2/project_grant/resource.go index 00a870d5..8d620135 100644 --- a/zitadel/v2/project_grant/resource.go +++ b/zitadel/v2/project_grant/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { Description: "ID of the organization granted the project", ForceNew: true, }, - roleKeysVar: { + RoleKeysVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 7f9c627f..4f4ecf3e 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -9,53 +9,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role/project_role_test_dep" ) func TestAccProjectGrant(t *testing.T) { - resourceName := "zitadel_project_grant" - initialProperty := "initialProperty" - updatedProperty := "updatedProperty" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - projectID := project.GetId() - for _, role := range []string{initialProperty, updatedProperty} { - _, err = frame.AddProjectRole(frame, &management.AddProjectRoleRequest{ - ProjectId: projectID, - RoleKey: role, - DisplayName: role, - }) - if err != nil { - t.Fatalf("failed to create project role %s: %v", role, err) - } - } - org, err := frame.AddOrg(frame, &management.AddOrgRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create org: %v", err) - } - grantedOrgID := org.GetId() - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_project_grant") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, project_grant.RoleKeysVar, exampleAttributes).AsValueSlice()[0].AsString() + updatedProperty := "updatedproperty" + projectDep, projectID := project_test_dep.Create(t, frame) + project_role_test_dep.Create(t, frame, projectID, exampleProperty, updatedProperty) + grantedOrgDep, _, _ := org_test_dep.Create(t, frame, "granted_org") + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - granted_org_id = "%s" - role_keys = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, grantedOrgID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep, grantedOrgDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", false, checkRemoteProperty(*frame, projectID), diff --git a/zitadel/v2/project_grant_member/const.go b/zitadel/v2/project_grant_member/const.go index 7132933c..f5f08567 100644 --- a/zitadel/v2/project_grant_member/const.go +++ b/zitadel/v2/project_grant_member/const.go @@ -3,7 +3,7 @@ package project_grant_member const ( orgIDVar = "org_id" projectIDVar = "project_id" - grantIDVar = "grant_id" + GrantIDVar = "grant_id" userIDVar = "user_id" - rolesVar = "roles" + RolesVar = "roles" ) diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index 2eb7d62a..43dc5407 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -28,7 +28,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.RemoveProjectGrantMember(ctx, &management.RemoveProjectGrantMemberRequest{ UserId: d.Get(userIDVar).(string), ProjectId: d.Get(projectIDVar).(string), - GrantId: d.Get(grantIDVar).(string), + GrantId: d.Get(GrantIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete projectmember: %v", err) @@ -51,9 +51,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectGrantMember(ctx, &management.UpdateProjectGrantMemberRequest{ UserId: d.Get(userIDVar).(string), - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), ProjectId: d.Get(projectIDVar).(string), - GrantId: d.Get(grantIDVar).(string), + GrantId: d.Get(GrantIDVar).(string), }) if err != nil { return diag.Errorf("failed to update projectmember: %v", err) @@ -77,12 +77,12 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia userID := d.Get(userIDVar).(string) projectID := d.Get(projectIDVar).(string) - grantID := d.Get(grantIDVar).(string) + grantID := d.Get(GrantIDVar).(string) _, err = client.AddProjectGrantMember(ctx, &management.AddProjectGrantMemberRequest{ UserId: userID, ProjectId: projectID, GrantId: grantID, - Roles: helper.GetOkSetToStringSlice(d, rolesVar), + Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { return diag.Errorf("failed to create projectgrantmember: %v", err) @@ -105,7 +105,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } projectID := d.Get(projectIDVar).(string) - grantID := d.Get(grantIDVar).(string) + grantID := d.Get(GrantIDVar).(string) userID := d.Get(userIDVar).(string) resp, err := client.ListProjectGrantMembers(ctx, &management.ListProjectGrantMembersRequest{ ProjectId: projectID, @@ -132,8 +132,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn userIDVar: userID, orgIDVar: org, projectIDVar: projectID, - rolesVar: memberRes.GetRoles(), - grantIDVar: grantID, + RolesVar: memberRes.GetRoles(), + GrantIDVar: grantID, } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/v2/project_grant_member/resource.go index 812681ad..c2e7a879 100644 --- a/zitadel/v2/project_grant_member/resource.go +++ b/zitadel/v2/project_grant_member/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { Description: "ID of the project", ForceNew: true, }, - grantIDVar: { + GrantIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the grant", @@ -32,7 +32,7 @@ func GetResource() *schema.Resource { Description: "ID of the user", ForceNew: true, }, - rolesVar: { + RolesVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index 089df40b..d346d420 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -2,6 +2,7 @@ package project_grant_member_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -10,69 +11,34 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant/project_grant_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" ) func TestAccProjectGrantMember(t *testing.T) { - resourceName := "zitadel_project_grant_member" - initialProperty := "PROJECT_GRANT_OWNER" - updatedProperty := "PROJECT_GRANT_OWNER_VIEWER" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - projectID := project.GetId() - otherOrgFrame, err := frame.AnotherOrg(frame.UniqueResourcesID) - if err != nil { - t.Fatalf("failed to switch to another org: %v", err) - } - grant, err := frame.AddProjectGrant(frame, &management.AddProjectGrantRequest{ - ProjectId: projectID, - GrantedOrgId: otherOrgFrame.OrgID, - }) - if err != nil { - t.Fatalf("failed create project grant: %v", err) - } - grantID := grant.GetGrantId() - otherOrgUser, err := otherOrgFrame.ImportHumanUser(otherOrgFrame, &management.ImportHumanUserRequest{ - UserName: otherOrgFrame.UniqueResourcesID, - Profile: &management.ImportHumanUserRequest_Profile{ - FirstName: "Don't", - LastName: "Care", - }, - Email: &management.ImportHumanUserRequest_Email{ - Email: "dont@care.com", - IsEmailVerified: true, - }, - }) - otherOrgUserID := otherOrgUser.GetUserId() - if err != nil { - t.Fatalf("failed to create otherOrgUser: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_project_grant_member") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, project_grant_member.RolesVar, exampleAttributes).AsValueSlice()[0].AsString() + grantIDProperty := test_utils.AttributeValue(t, project_grant_member.GrantIDVar, exampleAttributes).AsString() + projectDep, projectID := project_test_dep.Create(t, frame) + userDep, userID := human_user_test_dep.Create(t, frame) + _, grantedOrgID, _ := org_test_dep.Create(t, frame, "granting_org") + grantID := project_grant_test_dep.Create(t, frame, projectID, grantedOrgID) + resourceExample = strings.Replace(resourceExample, grantIDProperty, grantID, 1) + test_utils.RunLifecyleTest( t, - otherOrgFrame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - grant_id = "%s" - user_id = "%s" - roles = ["%s"] -}`, resourceName, otherOrgFrame.UniqueResourcesID, otherOrgFrame.OrgID, projectID, grantID, otherOrgUserID, configProperty) - }, - initialProperty, updatedProperty, + frame.BaseTestFrame, + []string{frame.AsOrgDefaultDependency, projectDep, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "PROJECT_GRANT_OWNER_VIEWER", "", "", true, - checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), + checkRemoteProperty(*frame, projectID, grantID, userID), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*otherOrgFrame, projectID, grantID, otherOrgUserID), ""), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, grantID, userID), ""), nil, nil, "", "", ) } diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go index 0b0457a9..d16a43fa 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/v2/project_member/resource_test.go @@ -10,51 +10,23 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" ) func TestAccProjectMember(t *testing.T) { - resourceName := "zitadel_project_member" - initialProperty := "PROJECT_OWNER" - updatedProperty := "PROJECT_OWNER_VIEWER" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - projectID := project.GetId() - user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ - UserName: frame.UniqueResourcesID, - Profile: &management.ImportHumanUserRequest_Profile{ - FirstName: "Don't", - LastName: "Care", - }, - Email: &management.ImportHumanUserRequest_Email{ - Email: "dont@care.com", - IsEmailVerified: true, - }, - }) - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - userID := user.GetUserId() - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_project_member") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, project_grant_member.RolesVar, exampleAttributes).AsValueSlice()[0].AsString() + projectDep, projectID := project_test_dep.Create(t, frame) + userDep, userID := human_user_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - user_id = "%s" - roles = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "PROJECT_OWNER_VIEWER", "", "", true, checkRemoteProperty(*frame, projectID, userID), diff --git a/zitadel/v2/project_role/const.go b/zitadel/v2/project_role/const.go index bd4022f6..a459a2fd 100644 --- a/zitadel/v2/project_role/const.go +++ b/zitadel/v2/project_role/const.go @@ -3,7 +3,7 @@ package project_role const ( orgIDVar = "org_id" projectIDVar = "project_id" - keyVar = "role_key" + KeyVar = "role_key" displayNameVar = "display_name" groupVar = "group" ) diff --git a/zitadel/v2/project_role/datasource.go b/zitadel/v2/project_role/datasource.go index bbd40b77..9efd32ce 100644 --- a/zitadel/v2/project_role/datasource.go +++ b/zitadel/v2/project_role/datasource.go @@ -16,7 +16,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "ID of the organization", }, - keyVar: { + KeyVar: { Type: schema.TypeString, Required: true, Description: "Key used for project role", diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/v2/project_role/funcs.go index f7e7bd56..2f2d6de8 100644 --- a/zitadel/v2/project_role/funcs.go +++ b/zitadel/v2/project_role/funcs.go @@ -28,7 +28,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.RemoveProjectRole(ctx, &management.RemoveProjectRoleRequest{ ProjectId: d.Get(projectIDVar).(string), - RoleKey: d.Get(keyVar).(string), + RoleKey: d.Get(KeyVar).(string), }) if err != nil { return diag.Errorf("failed to delete project role: %v", err) @@ -51,7 +51,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectRole(ctx, &management.UpdateProjectRoleRequest{ ProjectId: d.Get(projectIDVar).(string), - RoleKey: d.Get(keyVar).(string), + RoleKey: d.Get(KeyVar).(string), DisplayName: d.Get(displayNameVar).(string), Group: d.Get(groupVar).(string), }) @@ -77,7 +77,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } projectID := d.Get(projectIDVar).(string) - roleKey := d.Get(keyVar).(string) + roleKey := d.Get(KeyVar).(string) _, err = client.AddProjectRole(ctx, &management.AddProjectRoleRequest{ ProjectId: projectID, RoleKey: roleKey, @@ -112,7 +112,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn Queries: []*project2.RoleQuery{ {Query: &project2.RoleQuery_KeyQuery{ KeyQuery: &project2.RoleKeyQuery{ - Key: d.Get(keyVar).(string), + Key: d.Get(KeyVar).(string), Method: object.TextQueryMethod_TEXT_QUERY_METHOD_EQUALS, }, }}, @@ -129,7 +129,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ projectIDVar: projectID, orgIDVar: orgID, - keyVar: roleKey, + KeyVar: roleKey, displayNameVar: projectRole.GetDisplayName(), groupVar: projectRole.GetGroup(), } diff --git a/zitadel/v2/project_role/project_role_test_dep/dependency.go b/zitadel/v2/project_role/project_role_test_dep/dependency.go new file mode 100644 index 00000000..79b7fe1e --- /dev/null +++ b/zitadel/v2/project_role/project_role_test_dep/dependency.go @@ -0,0 +1,27 @@ +package project_role_test_dep + +import ( + "strings" + "testing" + + "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" +) + +func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID string, key ...string) string { + deps := make([]string, len(key)) + for i, k := range key { + _, dep := test_utils.CreateDefaultDependency(t, "zitadel_project_role", project_role.KeyVar, func() (string, error) { + _, err := frame.AddProjectRole(frame, &management.AddProjectRoleRequest{ + ProjectId: projectID, + RoleKey: k, + DisplayName: k, + }) + return k, err + }) + deps[i] = dep + } + return strings.Join(deps, "\n") +} diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go index 2447e4a0..6f0cba5d 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/v2/project_role/resource.go @@ -20,7 +20,7 @@ func GetResource() *schema.Resource { Description: "ID of the organization", ForceNew: true, }, - keyVar: { + KeyVar: { Type: schema.TypeString, Required: true, ForceNew: true, diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index 26889ef1..7d9fdcce 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -10,37 +10,21 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" ) func TestAccProjectRole(t *testing.T) { - resourceName := "zitadel_project_role" - initialProperty := "initialProperty" - updatedProperty := "updatedProperty" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - proj, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - projectID := proj.GetId() - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_project_role") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, project_role.KeyVar, exampleAttributes).AsString() + projectDep, projectID := project_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - role_key = "%s" - display_name = "display_name2" - group = "role_group" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedProperty", "", "", true, checkRemoteProperty(*frame, projectID), diff --git a/zitadel/v2/sms_provider_twilio/const.go b/zitadel/v2/sms_provider_twilio/const.go index d0367b0f..2bf42fd6 100644 --- a/zitadel/v2/sms_provider_twilio/const.go +++ b/zitadel/v2/sms_provider_twilio/const.go @@ -3,5 +3,5 @@ package sms_provider_twilio const ( sidVar = "sid" TokenVar = "token" - senderNumberVar = "sender_number" + SenderNumberVar = "sender_number" ) diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/v2/sms_provider_twilio/funcs.go index 4fe1209e..c91f8bea 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/v2/sms_provider_twilio/funcs.go @@ -47,7 +47,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddSMSProviderTwilio(ctx, &admin.AddSMSProviderTwilioRequest{ Sid: d.Get(sidVar).(string), Token: d.Get(TokenVar).(string), - SenderNumber: d.Get(senderNumberVar).(string), + SenderNumber: d.Get(SenderNumberVar).(string), }) if err != nil { return diag.Errorf("failed to create sms provider twilio: %v", err) @@ -70,11 +70,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - if d.HasChanges(senderNumberVar, sidVar) { + if d.HasChanges(SenderNumberVar, sidVar) { _, err = client.UpdateSMSProviderTwilio(ctx, &admin.UpdateSMSProviderTwilioRequest{ Id: d.Id(), Sid: d.Get(sidVar).(string), - SenderNumber: d.Get(senderNumberVar).(string), + SenderNumber: d.Get(SenderNumberVar).(string), }) if err != nil { return diag.Errorf("failed to update sms provider twilio: %v", err) @@ -120,7 +120,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ sidVar: resp.GetConfig().GetTwilio().GetSid(), - senderNumberVar: resp.GetConfig().GetTwilio().GetSenderNumber(), + SenderNumberVar: resp.GetConfig().GetTwilio().GetSenderNumber(), } if token, ok := d.GetOk(TokenVar); ok { set[TokenVar] = token diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go index 6e30fed7..7b0bc4e5 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -19,7 +19,7 @@ func GetResource() *schema.Resource { Description: "Token used to communicate with Twilio.", Sensitive: true, }, - senderNumberVar: { + SenderNumberVar: { Type: schema.TypeString, Required: true, Description: "Sender number which is used to send the SMS.", diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index a8fe37eb..af41bf73 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -13,28 +13,17 @@ import ( ) func TestAccSMSProviderTwilio(t *testing.T) { - resourceName := "zitadel_sms_provider_twilio" - initialProperty := "123456789" - updatedProperty := "987654321" - initialSecret := "initialSecret" - updatedSecret := "updatedSecret" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewInstanceTestFrame(t, "zitadel_sms_provider_twilio") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, sms_provider_twilio.SenderNumberVar, exampleAttributes).AsString() + exampleSecret := test_utils.AttributeValue(t, sms_provider_twilio.TokenVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, secretProperty string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - sid = "sid" - sender_number = "%s" - token = "%s" -}`, resourceName, frame.UniqueResourcesID, configProperty, secretProperty) - }, - initialProperty, updatedProperty, - initialSecret, updatedSecret, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), + exampleProperty, "987654321", + exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, diff --git a/zitadel/v2/smtp_config/const.go b/zitadel/v2/smtp_config/const.go index de45e186..df0eb6bb 100644 --- a/zitadel/v2/smtp_config/const.go +++ b/zitadel/v2/smtp_config/const.go @@ -1,8 +1,8 @@ package smtp_config const ( - senderAddressVar = "sender_address" - senderNameVar = "sender_name" + SenderAddressVar = "sender_address" + SenderNameVar = "sender_name" tlsVar = "tls" hostVar = "host" userVar = "user" diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/v2/smtp_config/funcs.go index 733c8510..5abd551c 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/v2/smtp_config/funcs.go @@ -45,8 +45,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } req := &admin.AddSMTPConfigRequest{ - SenderAddress: d.Get(senderAddressVar).(string), - SenderName: d.Get(senderNameVar).(string), + SenderAddress: d.Get(SenderAddressVar).(string), + SenderName: d.Get(SenderNameVar).(string), Host: d.Get(hostVar).(string), User: d.Get(userVar).(string), Tls: d.Get(tlsVar).(bool), @@ -75,10 +75,10 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - if d.HasChanges(senderAddressVar, senderNameVar, tlsVar, hostVar, userVar) { + if d.HasChanges(SenderAddressVar, SenderNameVar, tlsVar, hostVar, userVar) { _, err = client.UpdateSMTPConfig(ctx, &admin.UpdateSMTPConfigRequest{ - SenderAddress: d.Get(senderAddressVar).(string), - SenderName: d.Get(senderNameVar).(string), + SenderAddress: d.Get(SenderAddressVar).(string), + SenderName: d.Get(SenderNameVar).(string), Host: d.Get(hostVar).(string), Tls: d.Get(tlsVar).(bool), User: d.Get(userVar).(string), @@ -123,8 +123,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set := map[string]interface{}{ - senderAddressVar: resp.GetSmtpConfig().GetSenderAddress(), - senderNameVar: resp.GetSmtpConfig().GetSenderName(), + SenderAddressVar: resp.GetSmtpConfig().GetSenderAddress(), + SenderNameVar: resp.GetSmtpConfig().GetSenderName(), tlsVar: resp.GetSmtpConfig().GetTls(), hostVar: resp.GetSmtpConfig().GetHost(), userVar: resp.GetSmtpConfig().GetUser(), diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index a4d2e16e..f6e2dae4 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -8,12 +8,12 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the SMTP configuration of an instance.", Schema: map[string]*schema.Schema{ - senderAddressVar: { + SenderAddressVar: { Type: schema.TypeString, Required: true, Description: "Address used to send emails.", }, - senderNameVar: { + SenderNameVar: { Type: schema.TypeString, Required: true, Description: "Sender name used to send emails.", diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index 83c82f1b..681b49a2 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -2,6 +2,7 @@ package smtp_config_test import ( "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -15,35 +16,23 @@ import ( ) func TestAccSMTPConfig(t *testing.T) { - resourceName := "zitadel_smtp_config" - initialProperty := "initialProperty" - updatedProperty := "updatedProperty" - initialSecret := "initialSecret" - updatedSecret := "updatedSecret" - frame, err := test_utils.NewInstanceTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - _, err = frame.RemoveSMTPConfig(frame, &admin.RemoveSMTPConfigRequest{}) - if err != nil && status.Code(err) != codes.NotFound { + frame := test_utils.NewInstanceTestFrame(t, "zitadel_smtp_config") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + senderAddressProperty := test_utils.AttributeValue(t, smtp_config.SenderAddressVar, exampleAttributes).AsString() + resourceExample = strings.Replace(resourceExample, senderAddressProperty, fmt.Sprintf("zitadel@%s", frame.InstanceDomain), 1) + exampleProperty := test_utils.AttributeValue(t, smtp_config.SenderNameVar, exampleAttributes).AsString() + exampleSecret := test_utils.AttributeValue(t, smtp_config.PasswordVar, exampleAttributes).AsString() + // TODO: Does not work yet, because the smtp config is not deleted (API bug?) + if _, err := frame.RemoveSMTPConfig(frame, &admin.RemoveSMTPConfigRequest{}); err != nil && status.Code(err) != codes.NotFound { t.Fatalf("failed to remove smtp config: %v", err) } - test_utils.RunLifecyleTest[string]( + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, secretProperty string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - sender_address = "address" - sender_name = "%s" - tls = true - host = "localhost:25" - user = "user" - password = "%s" -}`, resourceName, frame.UniqueResourcesID, configProperty, secretProperty) - }, - initialProperty, updatedProperty, - initialSecret, updatedSecret, + nil, + test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), + exampleProperty, "updatedProperty", + exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), test_utils.ZITADEL_GENERATED_ID_REGEX, diff --git a/zitadel/v2/trigger_actions/const.go b/zitadel/v2/trigger_actions/const.go index 8c67e37b..3c8f1a16 100644 --- a/zitadel/v2/trigger_actions/const.go +++ b/zitadel/v2/trigger_actions/const.go @@ -2,7 +2,7 @@ package trigger_actions const ( orgIDVar = "org_id" - flowTypeVar = "flow_type" - triggerTypeVar = "trigger_type" + FlowTypeVar = "flow_type" + TriggerTypeVar = "trigger_type" actionsVar = "action_ids" ) diff --git a/zitadel/v2/trigger_actions/datasource.go b/zitadel/v2/trigger_actions/datasource.go index a6f9049e..4dac245f 100644 --- a/zitadel/v2/trigger_actions/datasource.go +++ b/zitadel/v2/trigger_actions/datasource.go @@ -14,12 +14,12 @@ func GetDatasource() *schema.Resource { Description: "ID of the organization", ForceNew: true, }, - flowTypeVar: { + FlowTypeVar: { Type: schema.TypeString, Required: true, Description: "Type of the flow to which the action triggers belong", }, - triggerTypeVar: { + TriggerTypeVar: { Type: schema.TypeString, Required: true, Description: "Trigger type on when the actions get triggered", diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index df3cbc2d..7e00360f 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -25,9 +25,9 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - flowType := d.Get(flowTypeVar).(string) + flowType := d.Get(FlowTypeVar).(string) flowTypeValues := helper.EnumValueMap(FlowTypes()) - triggerType := d.Get(triggerTypeVar).(string) + triggerType := d.Get(TriggerTypeVar).(string) triggerTypeValues := helper.EnumValueMap(TriggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: strconv.Itoa(int(flowTypeValues[flowType])), @@ -50,9 +50,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - flowType := d.Get(flowTypeVar).(string) + flowType := d.Get(FlowTypeVar).(string) flowTypeValues := helper.EnumValueMap(FlowTypes()) - triggerType := d.Get(triggerTypeVar).(string) + triggerType := d.Get(TriggerTypeVar).(string) triggerTypeValues := helper.EnumValueMap(TriggerTypes()) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ FlowType: strconv.Itoa(int(flowTypeValues[flowType])), @@ -76,9 +76,9 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - flowType := d.Get(flowTypeVar).(string) + flowType := d.Get(FlowTypeVar).(string) flowTypeValues := helper.EnumValueMap(FlowTypes()) - triggerType := d.Get(triggerTypeVar).(string) + triggerType := d.Get(TriggerTypeVar).(string) triggerTypeValues := helper.EnumValueMap(TriggerTypes()) actionIDs := helper.GetOkSetToStringSlice(d, actionsVar) _, err = client.SetTriggerActions(ctx, &management.SetTriggerActionsRequest{ @@ -100,8 +100,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } orgID := d.Get(orgIDVar).(string) - flowType := d.Get(flowTypeVar).(string) - triggerType := d.Get(triggerTypeVar).(string) + flowType := d.Get(FlowTypeVar).(string) + triggerType := d.Get(TriggerTypeVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index abce8254..125f59f3 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -18,21 +18,21 @@ func GetResource() *schema.Resource { Description: "ID of the organization", ForceNew: true, }, - flowTypeVar: { + FlowTypeVar: { Type: schema.TypeString, Required: true, Description: "Type of the flow to which the action triggers belong" + helper.DescriptionEnumValuesList(FlowTypes()), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(flowTypeVar, value, helper.EnumValueMap(FlowTypes())) + return helper.EnumValueValidation(FlowTypeVar, value, helper.EnumValueMap(FlowTypes())) }, ForceNew: true, }, - triggerTypeVar: { + TriggerTypeVar: { Type: schema.TypeString, Required: true, Description: "Trigger type on when the actions get triggered" + helper.DescriptionEnumValuesList(TriggerTypes()), ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(triggerTypeVar, value, helper.EnumValueMap(TriggerTypes())) + return helper.EnumValueValidation(TriggerTypeVar, value, helper.EnumValueMap(TriggerTypes())) }, ForceNew: true, }, diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 1b492acf..20d82bf8 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -4,55 +4,34 @@ import ( "fmt" "strconv" "testing" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "google.golang.org/protobuf/types/known/durationpb" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action/action_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" ) func TestAccTriggerActions(t *testing.T) { - resourceName := "zitadel_trigger_actions" - flowType := "FLOW_TYPE_CUSTOMISE_TOKEN" - initialTriggerType := "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION" - updatedTriggerType := "TRIGGER_TYPE_PRE_USERINFO_CREATION" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - // Always creates a new action - action, err := frame.CreateAction(frame, &management.CreateActionRequest{ - Name: frame.UniqueResourcesID, - Script: "not a script", - Timeout: durationpb.New(10 * time.Second), - AllowedToFail: true, - }) - if err != nil { - t.Fatalf("failed to create action: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_trigger_actions") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, trigger_actions.TriggerTypeVar, exampleAttributes).AsString() + flowType := test_utils.AttributeValue(t, trigger_actions.FlowTypeVar, exampleAttributes).AsString() + actionDep, _ := action_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" -flow_type = "%s" - trigger_type = "%s" - action_ids = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, flowType, configProperty, action.GetId()) - }, - initialTriggerType, updatedTriggerType, + []string{frame.AsOrgDefaultDependency, actionDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "TRIGGER_TYPE_PRE_USERINFO_CREATION", "", "", false, checkRemoteProperty(*frame, flowType), test_utils.ZITADEL_GENERATED_ID_REGEX, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), initialTriggerType), + test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), exampleProperty), nil, nil, "", "", ) } diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go index 6ea4ce37..9f4f8487 100644 --- a/zitadel/v2/user_grant/const.go +++ b/zitadel/v2/user_grant/const.go @@ -4,6 +4,6 @@ const ( projectIDVar = "project_id" projectGrantIDVar = "project_grant_id" userIDVar = "user_id" - roleKeysVar = "role_keys" + RoleKeysVar = "role_keys" orgIDVar = "org_id" ) diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/v2/user_grant/funcs.go index 8a5b1c3b..54d46e51 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/v2/user_grant/funcs.go @@ -51,7 +51,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateUserGrant(ctx, &management.UpdateUserGrantRequest{ GrantId: d.Id(), UserId: d.Get(userIDVar).(string), - RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), + RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { return diag.Errorf("failed to update usergrant: %v", err) @@ -76,7 +76,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia UserId: d.Get(userIDVar).(string), ProjectGrantId: d.Get(projectGrantIDVar).(string), ProjectId: d.Get(projectIDVar).(string), - RoleKeys: helper.GetOkSetToStringSlice(d, roleKeysVar), + RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { return diag.Errorf("failed to create usergrant: %v", err) @@ -134,7 +134,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn grant := grants.GetResult()[0] set := map[string]interface{}{ userIDVar: grant.GetUserId(), - roleKeysVar: grant.GetRoleKeys(), + RoleKeysVar: grant.GetRoleKeys(), orgIDVar: grant.GetDetails().GetResourceOwner(), } if grant.GetProjectId() != "" { diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go index 62680018..ca68b0d2 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/v2/user_grant/resource.go @@ -26,7 +26,7 @@ func GetResource() *schema.Resource { Description: "ID of the user", ForceNew: true, }, - roleKeysVar: { + RoleKeysVar: { Type: schema.TypeSet, Elem: &schema.Schema{ Type: schema.TypeString, diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index fcecf353..63c80da4 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -9,61 +9,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role/project_role_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" ) func TestAccUserGrant(t *testing.T) { - resourceName := "zitadel_user_grant" - initialProperty := "initialProperty" + frame := test_utils.NewOrgTestFrame(t, "zitadel_user_grant") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, user_grant.RoleKeysVar, exampleAttributes).AsValueSlice()[0].AsString() updatedProperty := "updatedProperty" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - project, err := frame.AddProject(frame, &management.AddProjectRequest{ - Name: frame.UniqueResourcesID, - }) - if err != nil { - t.Fatalf("failed to create project: %v", err) - } - projectID := project.GetId() - for _, role := range []string{initialProperty, updatedProperty} { - _, err = frame.AddProjectRole(frame, &management.AddProjectRoleRequest{ - ProjectId: projectID, - RoleKey: role, - DisplayName: role, - }) - if err != nil { - t.Fatalf("failed to create project role %s: %v", role, err) - } - } - user, err := frame.ImportHumanUser(frame, &management.ImportHumanUserRequest{ - UserName: frame.UniqueResourcesID, - Profile: &management.ImportHumanUserRequest_Profile{ - FirstName: "Don't", - LastName: "Care", - }, - Email: &management.ImportHumanUserRequest_Email{ - Email: "dont@care.com", - IsEmailVerified: true, - }, - }) - if err != nil { - t.Fatalf("failed to create user: %v", err) - } - userID := user.GetUserId() - test_utils.RunLifecyleTest[string]( + projectDep, projectID := project_test_dep.Create(t, frame) + project_role_test_dep.Create(t, frame, projectID, exampleProperty, updatedProperty) + userDep, userID := human_user_test_dep.Create(t, frame) + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - project_id = "%s" - user_id = "%s" - role_keys = ["%s"] -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, projectID, userID, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency, projectDep, userDep}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, updatedProperty, "", "", true, checkRemoteProperty(*frame, userID), diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index 841cab1b..d4ac556b 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index 30414b94..ea4ee0f6 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -10,42 +10,27 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_email_message_text" ) func TestAccVerifyEmailMessageText(t *testing.T) { resourceName := "zitadel_verify_email_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, resourceName) + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, verify_email_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("Zitadel - Verify email"), + checkRemoteProperty(frame, exampleLanguage)("Zitadel - Verify email"), nil, nil, "", "", ) } diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index 56c8320c..9d55766f 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -20,7 +20,7 @@ import ( const ( orgIDVar = "org_id" - languageVar = "language" + LanguageVar = "language" ) var ( @@ -209,7 +209,7 @@ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) attrs[orgIDVar] = types.StringValue(orgID) - attrs[languageVar] = types.StringValue(language) + attrs[LanguageVar] = types.StringValue(language) } func getID(ctx context.Context, obj types.Object) (string, string) { @@ -218,7 +218,7 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), languageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { @@ -228,7 +228,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( return "", "" } var language string - diag.Append(plan.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(plan.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } @@ -243,7 +243,7 @@ func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics return "", "" } var language string - diag.Append(state.GetAttribute(ctx, path.Root(languageVar), &language)...) + diag.Append(state.GetAttribute(ctx, path.Root(LanguageVar), &language)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index 4269a312..880d4319 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -10,42 +10,26 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_phone_message_text" ) func TestAccVerifyPhoneMessageText(t *testing.T) { - resourceName := "zitadel_verify_phone_message_text" - initialProperty := "initialtitle" - updatedProperty := "updatedtitle" - language := "en" - frame, err := test_utils.NewOrgTestFrame(resourceName) - if err != nil { - t.Fatalf("setting up test context failed: %v", err) - } - test_utils.RunLifecyleTest[string]( + frame := test_utils.NewOrgTestFrame(t, "zitadel_verify_phone_message_text") + resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) + exampleProperty := test_utils.AttributeValue(t, "title", exampleAttributes).AsString() + exampleLanguage := test_utils.AttributeValue(t, verify_phone_message_text.LanguageVar, exampleAttributes).AsString() + test_utils.RunLifecyleTest( t, frame.BaseTestFrame, - func(configProperty, _ string) string { - return fmt.Sprintf(` -resource "%s" "%s" { - org_id = "%s" - language = "%s" - - title = "%s" - pre_header = "pre_header example" - subject = "subject example" - greeting = "greeting example" - text = "text example" - button_text = "button_text example" - footer_text = "footer_text example" -}`, resourceName, frame.UniqueResourcesID, frame.OrgID, language, configProperty) - }, - initialProperty, updatedProperty, + []string{frame.AsOrgDefaultDependency}, + test_utils.ReplaceAll(resourceExample, exampleProperty, ""), + exampleProperty, "updatedtitle", "", "", true, - checkRemoteProperty(frame, language), - regexp.MustCompile(`^\d{18}_en$`), + checkRemoteProperty(frame, exampleLanguage), + regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned - checkRemoteProperty(frame, language)("Zitadel - Verify phone"), + checkRemoteProperty(frame, exampleLanguage)("Zitadel - Verify phone"), nil, nil, "", "", ) } From fc68c6cf99db824cf3e154301e651511fcf17ff5 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 21 Aug 2023 16:44:37 +0200 Subject: [PATCH 237/260] generate docs --- docs/data-sources/org.md | 2 +- docs/resources/default_domain_policy.md | 4 ++-- docs/resources/default_login_policy.md | 1 + docs/resources/default_privacy_policy.md | 8 ++++---- docs/resources/domain.md | 2 +- docs/resources/domain_policy.md | 4 ++-- docs/resources/login_policy.md | 2 +- docs/resources/machine_user.md | 4 ++-- docs/resources/org_idp_jwt.md | 2 +- docs/resources/privacy_policy.md | 8 ++++---- docs/resources/project_grant.md | 4 ++-- docs/resources/project_grant_member.md | 2 +- docs/resources/project_role.md | 2 +- docs/resources/sms_provider_twilio.md | 2 +- docs/resources/smtp_config.md | 4 ++-- docs/resources/trigger_actions.md | 4 ++-- docs/resources/user_grant.md | 2 +- examples/provider/resources/user_grant.tf | 2 +- 18 files changed, 30 insertions(+), 29 deletions(-) diff --git a/docs/data-sources/org.md b/docs/data-sources/org.md index f5599f3d..2c34e613 100644 --- a/docs/data-sources/org.md +++ b/docs/data-sources/org.md @@ -13,7 +13,7 @@ Datasource representing an organization in ZITADEL, which is the highest level a ```terraform data "zitadel_org" "default" { - org_id = "123456789012345678" + id = "123456789012345678" } output "org" { diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md index a9e94e3b..3efa09b6 100644 --- a/docs/resources/default_domain_policy.md +++ b/docs/resources/default_domain_policy.md @@ -14,8 +14,8 @@ Resource representing the default domain policy. ```terraform resource "zitadel_default_domain_policy" "default" { user_login_must_be_domain = false - validate_org_domains = false - smtp_sender_address_matches_instance_domain = false + validate_org_domains = true + smtp_sender_address_matches_instance_domain = true } ``` diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 14fbbd77..a7338875 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -28,6 +28,7 @@ resource "zitadel_default_login_policy" "default" { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] + idps = [data.zitadel_idp_google.default.id, data.zitadel_idp_azure_ad.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index 67f130e9..c2ce8e06 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -13,10 +13,10 @@ Resource representing the default privacy policy. ```terraform resource "zitadel_default_privacy_policy" "default" { - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" - support_email = "support@email.com" + tos_link = "https://example.com/tos" + privacy_link = "https://example.com/privacy" + help_link = "https://example.com/help" + support_email = "support@example.com" } ``` diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 7cf0e1f0..f65450f8 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -15,7 +15,7 @@ Resource representing a domain of the organization. resource "zitadel_domain" "default" { org_id = data.zitadel_org.default.id name = "zitadel.default.127.0.0.1.sslip.io" - is_primary = true + is_primary = false } ``` diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 10496dd6..388f5cbb 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -14,9 +14,9 @@ Resource representing the custom domain policy of an organization. ```terraform resource "zitadel_domain_policy" "default" { org_id = data.zitadel_org.default.id - user_login_must_be_domain = false + user_login_must_be_domain = true validate_org_domains = false - smtp_sender_address_matches_instance_domain = false + smtp_sender_address_matches_instance_domain = true } ``` diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 2d233887..4a6132b5 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -29,7 +29,7 @@ resource "zitadel_login_policy" "default" { default_redirect_uri = "localhost:8080" second_factors = ["SECOND_FACTOR_TYPE_OTP", "SECOND_FACTOR_TYPE_U2F"] multi_factors = ["MULTI_FACTOR_TYPE_U2F_WITH_VERIFICATION"] - idps = [zitadel_org_idp_oidc.default.id, zitadel_org_idp_jwt.default.id] + idps = [data.zitadel_idp_google.default.id, data.zitadel_idp_azure_ad.default.id] allow_domain_discovery = true disable_login_with_email = true disable_login_with_phone = true diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index ddc6993c..fb5c149e 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -14,9 +14,9 @@ Resource representing a serviceaccount situated under an organization, which the ```terraform resource "zitadel_machine_user" "default" { org_id = data.zitadel_org.default.id - user_name = "machine@localhost.com" + user_name = "machine@example.com" name = "name" - description = "description" + description = "a machine user" } ``` diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index 9ff04706..cd8c7e77 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -16,7 +16,7 @@ resource "zitadel_org_idp_jwt" "default" { org_id = data.zitadel_org.default.id name = "jwtidp" styling_type = "STYLING_TYPE_UNSPECIFIED" - jwt_endpoint = "https://jwtendpoint.com" + jwt_endpoint = "https://jwtendpoint.com/jwt" issuer = "https://google.com" keys_endpoint = "https://jwtendpoint.com/keys" header_name = "x-auth-token" diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index b3a109a8..35255c67 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -14,10 +14,10 @@ Resource representing the custom privacy policy of an organization. ```terraform resource "zitadel_privacy_policy" "default" { org_id = data.zitadel_org.default.id - tos_link = "https://google.com" - privacy_link = "https://google.com" - help_link = "https://google.com" - support_email = "support@email.com" + tos_link = "https://example.com/tos" + privacy_link = "https://example.com/privacy" + help_link = "https://example.com/help" + support_email = "support@example.com" } ``` diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 19abdba5..9512e5a2 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -15,8 +15,8 @@ Resource representing the grant of a project to a different organization, also c resource "zitadel_project_grant" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - granted_org_id = data.zitadel_org.default.id - role_keys = [data.zitadel_project_role.default.role_key] + granted_org_id = data.zitadel_org.granted_org.id + role_keys = ["super-user"] } ``` diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index fcad58da..b0c7715b 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -15,8 +15,8 @@ Resource representing the membership of a user on an granted project, defined wi resource "zitadel_project_grant_member" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - grant_id = data.zitadel_project_grant.default.id user_id = data.zitadel_human_user.default.id + grant_id = "123456789012345678" roles = ["PROJECT_GRANT_OWNER"] } ``` diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index eacae021..b4bdaad2 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -15,7 +15,7 @@ Resource representing the project roles, which can be given as authorizations to resource "zitadel_project_role" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id - role_key = "key" + role_key = "super-user" display_name = "display_name2" group = "role_group" } diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index d00784dc..d62d818e 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -15,7 +15,7 @@ Resource representing the SMS provider Twilio configuration of an instance. resource "zitadel_sms_provider_twilio" "default" { sid = "sid" sender_number = "019920892" - token = "token" + token = "twilio_token" } ``` diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index ae3b031d..377e7d5a 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -13,12 +13,12 @@ Resource representing the SMTP configuration of an instance. ```terraform resource "zitadel_smtp_config" "default" { - sender_address = "address" + sender_address = "sender@example.com" sender_name = "no-reply" tls = true host = "localhost:25" user = "user" - password = "password" + password = "secret_password" } ``` diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index c78a5765..824b62c2 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -14,8 +14,8 @@ Resource representing triggers, when actions get started ```terraform resource "zitadel_trigger_actions" "default" { org_id = data.zitadel_org.default.id - flow_type = "FLOW_TYPE_EXTERNAL_AUTHENTICATION" - trigger_type = "TRIGGER_TYPE_POST_AUTHENTICATION" + flow_type = "FLOW_TYPE_CUSTOMISE_TOKEN" + trigger_type = "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION" action_ids = [data.zitadel_action.default.id] } ``` diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 914cb2e8..10231802 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -15,7 +15,7 @@ Resource representing the authorization given to a user directly, including the resource "zitadel_user_grant" "default" { project_id = data.zitadel_project.default.id org_id = data.zitadel_org.default.id - role_keys = ["key"] + role_keys = ["super-user"] user_id = data.zitadel_human_user.default.id } ``` diff --git a/examples/provider/resources/user_grant.tf b/examples/provider/resources/user_grant.tf index 68024bad..ffe2099c 100644 --- a/examples/provider/resources/user_grant.tf +++ b/examples/provider/resources/user_grant.tf @@ -1,6 +1,6 @@ resource "zitadel_user_grant" "default" { project_id = data.zitadel_project.default.id org_id = data.zitadel_org.default.id - role_keys = ["some_role_key"] + role_keys = ["super-user"] user_id = data.zitadel_human_user.default.id } From 5e8e2b6749014e57ac2dd24baccf5e62317ca30b Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 21 Aug 2023 19:29:02 +0200 Subject: [PATCH 238/260] fix action and app_key importers --- .../zitadel/pkg/grpc/text/text_terraform.go | 3 +- zitadel/v2/action/const.go | 1 - zitadel/v2/action/datasource.go | 13 +- zitadel/v2/action/funcs.go | 10 +- zitadel/v2/action/resource.go | 10 +- zitadel/v2/action/resource_test.go | 9 +- zitadel/v2/app_key/const.go | 7 +- zitadel/v2/app_key/funcs.go | 27 +- zitadel/v2/app_key/resource.go | 20 +- zitadel/v2/app_key/resource_test.go | 14 +- zitadel/v2/application_api/const.go | 1 - zitadel/v2/application_api/datasource.go | 4 +- zitadel/v2/application_api/funcs.go | 10 +- zitadel/v2/application_api/resource.go | 7 +- zitadel/v2/application_oidc/const.go | 1 - zitadel/v2/application_oidc/datasource.go | 4 +- zitadel/v2/application_oidc/funcs.go | 10 +- zitadel/v2/application_oidc/resource.go | 7 +- zitadel/v2/domain/const.go | 1 - zitadel/v2/domain/funcs.go | 10 +- zitadel/v2/domain/resource.go | 8 +- .../domain_claimed_message_text/resource.go | 12 +- zitadel/v2/domain_policy/const.go | 1 - zitadel/v2/domain_policy/funcs.go | 10 +- zitadel/v2/domain_policy/resource.go | 8 +- zitadel/v2/helper/import.go | 203 ++++++++++++ zitadel/v2/helper/import_test.go | 293 ++++++++++++++++++ zitadel/v2/helper/schema.go | 43 +++ zitadel/v2/helper/test_utils/import_id.go | 57 ++++ zitadel/v2/helper/test_utils/lifecyletest.go | 41 +-- zitadel/v2/human_user/const.go | 1 - zitadel/v2/human_user/datasource.go | 4 +- zitadel/v2/human_user/funcs.go | 10 +- zitadel/v2/human_user/resource.go | 7 +- zitadel/v2/init_message_text/resource.go | 9 +- zitadel/v2/label_policy/const.go | 1 - zitadel/v2/label_policy/funcs.go | 8 +- zitadel/v2/label_policy/resource.go | 8 +- zitadel/v2/lockout_policy/const.go | 1 - zitadel/v2/lockout_policy/funcs.go | 10 +- zitadel/v2/lockout_policy/resource.go | 9 +- zitadel/v2/login_policy/const.go | 1 - zitadel/v2/login_policy/funcs.go | 10 +- zitadel/v2/login_policy/resource.go | 8 +- zitadel/v2/login_texts/resource.go | 12 +- zitadel/v2/machine_key/const.go | 1 - zitadel/v2/machine_key/funcs.go | 8 +- zitadel/v2/machine_key/resource.go | 7 +- zitadel/v2/machine_user/const.go | 1 - zitadel/v2/machine_user/datasource.go | 8 +- zitadel/v2/machine_user/funcs.go | 10 +- zitadel/v2/machine_user/resource.go | 7 +- zitadel/v2/notification_policy/const.go | 1 - zitadel/v2/notification_policy/funcs.go | 14 +- zitadel/v2/notification_policy/resource.go | 8 +- zitadel/v2/org/datasource.go | 6 +- zitadel/v2/org_idp_azure_ad/datasource.go | 3 +- zitadel/v2/org_idp_azure_ad/funcs.go | 9 +- zitadel/v2/org_idp_azure_ad/resource.go | 3 +- zitadel/v2/org_idp_github/datasource.go | 3 +- zitadel/v2/org_idp_github/funcs.go | 9 +- zitadel/v2/org_idp_github/resource.go | 3 +- zitadel/v2/org_idp_github_es/datasource.go | 3 +- zitadel/v2/org_idp_github_es/funcs.go | 9 +- zitadel/v2/org_idp_github_es/resource.go | 3 +- zitadel/v2/org_idp_gitlab/datasource.go | 3 +- zitadel/v2/org_idp_gitlab/funcs.go | 9 +- zitadel/v2/org_idp_gitlab/resource.go | 3 +- .../org_idp_gitlab_self_hosted/datasource.go | 3 +- .../v2/org_idp_gitlab_self_hosted/funcs.go | 9 +- .../v2/org_idp_gitlab_self_hosted/resource.go | 3 +- zitadel/v2/org_idp_google/datasource.go | 3 +- zitadel/v2/org_idp_google/funcs.go | 9 +- zitadel/v2/org_idp_google/resource.go | 3 +- zitadel/v2/org_idp_jwt/const.go | 1 - zitadel/v2/org_idp_jwt/datasource.go | 4 +- zitadel/v2/org_idp_jwt/funcs.go | 10 +- zitadel/v2/org_idp_jwt/resource.go | 7 +- zitadel/v2/org_idp_ldap/datasource.go | 3 +- zitadel/v2/org_idp_ldap/funcs.go | 9 +- zitadel/v2/org_idp_ldap/resource.go | 3 +- zitadel/v2/org_idp_oidc/const.go | 1 - zitadel/v2/org_idp_oidc/datasource.go | 4 +- zitadel/v2/org_idp_oidc/funcs.go | 10 +- zitadel/v2/org_idp_oidc/resource.go | 7 +- zitadel/v2/org_idp_utils/funcs.go | 10 +- .../org_idp_test_utils/lifecyletest.go | 4 +- zitadel/v2/org_idp_utils/resource.go | 1 - zitadel/v2/org_idp_utils/schema.go | 21 -- zitadel/v2/org_member/const.go | 1 - zitadel/v2/org_member/funcs.go | 14 +- zitadel/v2/org_member/resource.go | 8 +- .../password_change_message_text/resource.go | 12 +- .../v2/password_complexity_policy/const.go | 1 - .../v2/password_complexity_policy/funcs.go | 10 +- .../v2/password_complexity_policy/resource.go | 8 +- .../password_reset_message_text/resource.go | 12 +- .../resource.go | 9 +- zitadel/v2/pat/const.go | 1 - zitadel/v2/pat/funcs.go | 8 +- zitadel/v2/pat/resource.go | 8 +- zitadel/v2/privacy_policy/const.go | 1 - zitadel/v2/privacy_policy/funcs.go | 10 +- zitadel/v2/privacy_policy/resource.go | 8 +- zitadel/v2/project/const.go | 1 - zitadel/v2/project/datasource.go | 8 +- zitadel/v2/project/funcs.go | 10 +- zitadel/v2/project/resource.go | 6 +- zitadel/v2/project_grant/const.go | 1 - zitadel/v2/project_grant/funcs.go | 10 +- zitadel/v2/project_grant/resource.go | 7 +- zitadel/v2/project_grant_member/const.go | 1 - zitadel/v2/project_grant_member/funcs.go | 18 +- zitadel/v2/project_grant_member/resource.go | 8 +- zitadel/v2/project_member/const.go | 1 - zitadel/v2/project_member/funcs.go | 16 +- zitadel/v2/project_member/resource.go | 8 +- zitadel/v2/project_role/const.go | 1 - zitadel/v2/project_role/datasource.go | 8 +- zitadel/v2/project_role/funcs.go | 18 +- zitadel/v2/project_role/resource.go | 8 +- zitadel/v2/trigger_actions/const.go | 1 - zitadel/v2/trigger_actions/datasource.go | 9 +- zitadel/v2/trigger_actions/funcs.go | 8 +- zitadel/v2/trigger_actions/resource.go | 7 +- zitadel/v2/user_grant/const.go | 1 - zitadel/v2/user_grant/funcs.go | 14 +- zitadel/v2/user_grant/resource.go | 8 +- .../v2/verify_email_message_text/resource.go | 12 +- .../v2/verify_phone_message_text/resource.go | 12 +- 130 files changed, 978 insertions(+), 535 deletions(-) create mode 100644 zitadel/v2/helper/import.go create mode 100644 zitadel/v2/helper/import_test.go create mode 100644 zitadel/v2/helper/schema.go create mode 100644 zitadel/v2/helper/test_utils/import_id.go delete mode 100644 zitadel/v2/org_idp_utils/resource.go delete mode 100644 zitadel/v2/org_idp_utils/schema.go diff --git a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go index 13ab4bdc..2d2bcb7c 100644 --- a/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go +++ b/gen/github.com/zitadel/zitadel/pkg/grpc/text/text_terraform.go @@ -21,8 +21,8 @@ package text import ( context "context" fmt "fmt" - math "math" textpb "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/text" + math "math" _ "github.com/envoyproxy/protoc-gen-validate/validate" proto "github.com/gogo/protobuf/proto" @@ -32,7 +32,6 @@ import ( github_com_hashicorp_terraform_plugin_framework_tfsdk "github.com/hashicorp/terraform-plugin-framework/tfsdk" github_com_hashicorp_terraform_plugin_framework_types "github.com/hashicorp/terraform-plugin-framework/types" github_com_hashicorp_terraform_plugin_go_tftypes "github.com/hashicorp/terraform-plugin-go/tftypes" - ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/zitadel/v2/action/const.go b/zitadel/v2/action/const.go index bbeefaac..2fa536eb 100644 --- a/zitadel/v2/action/const.go +++ b/zitadel/v2/action/const.go @@ -2,7 +2,6 @@ package action const ( ActionIDVar = "action_id" - orgIDVar = "org_id" stateVar = "state" NameVar = "name" ScriptVar = "script" diff --git a/zitadel/v2/action/datasource.go b/zitadel/v2/action/datasource.go index 3feaaf1b..d983b403 100644 --- a/zitadel/v2/action/datasource.go +++ b/zitadel/v2/action/datasource.go @@ -1,6 +1,9 @@ package action -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -11,12 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, stateVar: { Type: schema.TypeInt, Computed: true, @@ -44,6 +42,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/action/funcs.go b/zitadel/v2/action/funcs.go index 69255140..6787e96f 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/v2/action/funcs.go @@ -22,7 +22,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -53,7 +53,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -75,7 +75,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -106,7 +106,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -131,7 +131,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { action := resp.Result[0] set := map[string]interface{}{ - orgIDVar: action.GetDetails().GetResourceOwner(), + helper.OrgIDVar: action.GetDetails().GetResourceOwner(), NameVar: action.GetName(), stateVar: action.GetState(), ScriptVar: action.GetScript(), diff --git a/zitadel/v2/action/resource.go b/zitadel/v2/action/resource.go index 431af64d..221462df 100644 --- a/zitadel/v2/action/resource.go +++ b/zitadel/v2/action/resource.go @@ -2,18 +2,14 @@ package action import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an action belonging to an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, stateVar: { Type: schema.TypeInt, Computed: true, @@ -48,6 +44,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: read, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg(ActionIDVar), } } diff --git a/zitadel/v2/action/resource_test.go b/zitadel/v2/action/resource_test.go index 63e74a73..02801e26 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/v2/action/resource_test.go @@ -26,12 +26,15 @@ func TestAccAction(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedproperty", - "", "", + "", "", "", true, checkRemoteProperty(frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + test_utils.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/app_key/const.go b/zitadel/v2/app_key/const.go index 94b82711..0d4246fa 100644 --- a/zitadel/v2/app_key/const.go +++ b/zitadel/v2/app_key/const.go @@ -1,10 +1,9 @@ package app_key const ( - orgIDVar = "org_id" - projectIDVar = "project_id" - appIDVar = "app_id" + ProjectIDVar = "project_id" + AppIDVar = "app_id" keyTypeVar = "key_type" - keyDetailsVar = "key_details" + KeyDetailsVar = "key_details" ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/app_key/funcs.go index 24999fd6..bde5c99c 100644 --- a/zitadel/v2/app_key/funcs.go +++ b/zitadel/v2/app_key/funcs.go @@ -22,14 +22,14 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } _, err = client.RemoveAppKey(ctx, &management.RemoveAppKeyRequest{ - ProjectId: d.Get(projectIDVar).(string), - AppId: d.Get(appIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), + AppId: d.Get(AppIDVar).(string), KeyId: d.Id(), }) if err != nil { @@ -46,7 +46,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -54,8 +54,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia keyType := d.Get(keyTypeVar).(string) req := &management.AddAppKeyRequest{ - ProjectId: d.Get(projectIDVar).(string), - AppId: d.Get(appIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), + AppId: d.Get(AppIDVar).(string), Type: authn.KeyType(authn.KeyType_value[keyType]), } @@ -72,7 +72,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } d.SetId(resp.GetId()) - if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { + if err := d.Set(KeyDetailsVar, string(resp.GetKeyDetails())); err != nil { return diag.FromErr(err) } return nil @@ -85,14 +85,14 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) - appID := d.Get(appIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) + appID := d.Get(AppIDVar).(string) resp, err := client.GetAppKey(ctx, &management.GetAppKeyRequest{ ProjectId: projectID, AppId: appID, @@ -109,9 +109,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ ExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), - projectIDVar: projectID, - appIDVar: appID, - orgIDVar: orgID, + ProjectIDVar: projectID, + AppIDVar: appID, + helper.OrgIDVar: orgID, + keyTypeVar: resp.GetKey().GetType().String(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index 33ce156d..3301922b 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -13,19 +13,14 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a app key", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, - projectIDVar: { + helper.OrgIDVar: helper.OrgIDResourceField, + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", ForceNew: true, }, - appIDVar: { + AppIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the application", @@ -46,7 +41,7 @@ func GetResource() *schema.Resource { Description: "Expiration date of the app key in the RFC3339 format", ForceNew: true, }, - keyDetailsVar: { + KeyDetailsVar: { Type: schema.TypeString, Computed: true, Description: "Value of the app key", @@ -56,6 +51,11 @@ func GetResource() *schema.Resource { DeleteContext: delete, CreateContext: create, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + "id", + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(AppIDVar, helper.ConvertID, false), + helper.NewImportAttribute(KeyDetailsVar, helper.ConvertJSON, true), + ), } } diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 3f6ddc31..240e081a 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" @@ -27,12 +29,18 @@ func TestAccAppKey(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep, appDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(frame, projectID, appID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID, appID), updatedProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.ProjectIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.AppIDVar), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.KeyDetailsVar), + ), ) } diff --git a/zitadel/v2/application_api/const.go b/zitadel/v2/application_api/const.go index 7cee2013..737d100d 100644 --- a/zitadel/v2/application_api/const.go +++ b/zitadel/v2/application_api/const.go @@ -2,7 +2,6 @@ package application_api const ( AppIDVar = "app_id" - orgIDVar = "org_id" projectIDVar = "project_id" NameVar = "name" authMethodTypeVar = "auth_method_type" diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/v2/application_api/datasource.go index cde2ab93..a8ed45a3 100644 --- a/zitadel/v2/application_api/datasource.go +++ b/zitadel/v2/application_api/datasource.go @@ -2,6 +2,7 @@ package application_api import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "orgID of the application", @@ -35,6 +36,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index 89fcd894..07b037bd 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -43,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -81,7 +81,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -116,7 +116,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -133,7 +133,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn app := resp.GetApp() api := app.GetApiConfig() set := map[string]interface{}{ - orgIDVar: app.GetDetails().GetResourceOwner(), + helper.OrgIDVar: app.GetDetails().GetResourceOwner(), NameVar: app.GetName(), authMethodTypeVar: api.GetAuthMethodType().String(), } diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index 6bc84a0c..51fc1eca 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -13,12 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an API application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/application_oidc/const.go b/zitadel/v2/application_oidc/const.go index a5ac079e..bd2fd899 100644 --- a/zitadel/v2/application_oidc/const.go +++ b/zitadel/v2/application_oidc/const.go @@ -2,7 +2,6 @@ package application_oidc const ( appIDVar = "app_id" - orgIDVar = "org_id" projectIDVar = "project_id" NameVar = "name" redirectURIsVar = "redirect_uris" diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/v2/application_oidc/datasource.go index b02a89c8..414ab118 100644 --- a/zitadel/v2/application_oidc/datasource.go +++ b/zitadel/v2/application_oidc/datasource.go @@ -2,6 +2,7 @@ package application_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "orgID of the application", @@ -115,6 +116,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index 06a2045f..a421effb 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -22,7 +22,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -45,7 +45,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -123,7 +123,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -186,7 +186,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -216,7 +216,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set := map[string]interface{}{ - orgIDVar: oidcApp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: oidcApp.GetDetails().GetResourceOwner(), NameVar: oidcApp.GetName(), redirectURIsVar: oidc.GetRedirectUris(), responseTypesVar: responseTypes, diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index 58a82fe0..d4e0d3a6 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -13,12 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an OIDC application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/domain/const.go b/zitadel/v2/domain/const.go index d5d86fd2..fd6b95e9 100644 --- a/zitadel/v2/domain/const.go +++ b/zitadel/v2/domain/const.go @@ -1,7 +1,6 @@ package domain const ( - orgIDVar = "org_id" NameVar = "name" isVerifiedVar = "is_verified" isPrimaryVar = "is_primary" diff --git a/zitadel/v2/domain/funcs.go b/zitadel/v2/domain/funcs.go index 016cd5c5..d418e462 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/v2/domain/funcs.go @@ -22,7 +22,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -60,7 +60,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -90,7 +90,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -116,7 +116,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -144,7 +144,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn domain := resp.Result[0] set := map[string]interface{}{ NameVar: domain.GetDomainName(), - orgIDVar: domain.GetOrgId(), + helper.OrgIDVar: domain.GetOrgId(), isVerifiedVar: domain.GetIsVerified(), isPrimaryVar: domain.GetIsPrimary(), validationTypeVar: domain.GetValidationType().Number(), diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index 647c19f7..cfe4501f 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -2,24 +2,20 @@ package domain import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a domain of the organization.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDResourceField, NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the domain", ForceNew: true, }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, isVerifiedVar: { Type: schema.TypeBool, Computed: true, diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index 13b6cdeb..b060632c 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *domainClaimedMessageTextResource) Delete(ctx context.Context, req resou func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/domain_policy/const.go b/zitadel/v2/domain_policy/const.go index 39cdf7cb..30bc49a2 100644 --- a/zitadel/v2/domain_policy/const.go +++ b/zitadel/v2/domain_policy/const.go @@ -1,7 +1,6 @@ package domain_policy const ( - orgIDVar = "org_id" UserLoginMustBeDomainVar = "user_login_must_be_domain" validateOrgDomainVar = "validate_org_domains" smtpSenderVar = "smtp_sender_address_matches_instance_domain" diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 6ac5bc7c..60cdf8a2 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -24,7 +24,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) _, err = client.ResetCustomDomainPolicyToDefault(ctx, &admin.ResetCustomDomainPolicyToDefaultRequest{ OrgId: org, @@ -47,7 +47,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) _, err = client.UpdateCustomDomainPolicy(ctx, &admin.UpdateCustomDomainPolicyRequest{ OrgId: org, @@ -74,7 +74,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) _, err = client.AddCustomDomainPolicy(ctx, &admin.AddCustomDomainPolicyRequest{ OrgId: org, @@ -97,7 +97,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -118,7 +118,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), UserLoginMustBeDomainVar: policy.GetUserLoginMustBeDomain(), validateOrgDomainVar: policy.GetValidateOrgDomains(), smtpSenderVar: policy.GetSmtpSenderAddressMatchesInstanceDomain(), diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/v2/domain_policy/resource.go index a4c194b9..1366a318 100644 --- a/zitadel/v2/domain_policy/resource.go +++ b/zitadel/v2/domain_policy/resource.go @@ -2,18 +2,14 @@ package domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom domain policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, UserLoginMustBeDomainVar: { Type: schema.TypeBool, Required: true, diff --git a/zitadel/v2/helper/import.go b/zitadel/v2/helper/import.go new file mode 100644 index 00000000..b5f241d4 --- /dev/null +++ b/zitadel/v2/helper/import.go @@ -0,0 +1,203 @@ +package helper + +import ( + "context" + "encoding/csv" + "encoding/json" + "errors" + "fmt" + "sort" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var ( + ImportOptionalOrgAttribute = NewImportAttribute(OrgIDVar, ConvertID, true) + emptyIDAttribute = NewImportAttribute(`""`, ConvertEmpty, false) + SemicolonPlaceholder = "__SEMICOLON__" +) + +func NewImportAttribute(key string, value ConvertStringFunc, optional bool) importAttribute { + return importAttribute{key: key, value: value, optional: optional} +} + +func ImportWithID(idVar string, attrs ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{NewImportAttribute(idVar, ConvertID, false)}, attrs...)...) +} + +func ImportWithOptionalOrg(attrs ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{ImportOptionalOrgAttribute}, attrs...)...) +} + +func ImportWithIDAndOptionalOrg(idVar string, attrs ...importAttribute) *schema.ResourceImporter { + return ImportWithID(idVar, append(attrs, ImportOptionalOrgAttribute)...) +} + +func ImportWithIDAndOptionalSecret(idVar, secretKey string) *schema.ResourceImporter { + return ImportWithID(idVar, importAttribute{key: secretKey, value: ConvertNonEmpty, optional: true}) +} + +func ImportWithIDAndOptionalOrgAndSecretV5(idVar, secretKey string) *schema.ResourceImporter { + return ImportWithIDAndOptionalOrg(idVar, importAttribute{key: secretKey, value: ConvertNonEmpty, optional: true}) +} + +func ImportWithEmptyID(attrs ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{emptyIDAttribute}, attrs...)...) +} + +type ConvertStringFunc func(string) (interface{}, error) + +type importAttribute struct { + key string + value ConvertStringFunc + optional bool +} + +type ImportAttributes []importAttribute + +// Less makes the attributes sortable by putting the optional attributes to the end +// and the org id to the beginning of the optional attributes +func (i ImportAttributes) Less(j, k int) bool { + left := (i)[j] + right := (i)[k] + if !left.optional && right.optional { + return true + } + if left.optional && right.optional && left.key == OrgIDVar { + return true + } + return false +} + +func (i ImportAttributes) Len() int { return len(i) } + +func (i ImportAttributes) Swap(j, k int) { (i)[j], (i)[k] = (i)[k], (i)[j] } + +func ImportWithAttributes(attrs ...importAttribute) *schema.ResourceImporter { + return &schema.ResourceImporter{ + StateContext: func(_ context.Context, data *schema.ResourceData, i interface{}) (ret []*schema.ResourceData, err error) { + return []*schema.ResourceData{data}, importWithAttributes(data, attrs...) + }, + } +} + +type importState interface { + Id() string + SetId(string) + Set(string, interface{}) error +} + +func importWithAttributes(state importState, attrs ...importAttribute) (err error) { + id := state.Id() + var ( + optionalKeys []string + requiredKeys []string + ) + sort.Sort(ImportAttributes(attrs)) + for i, attr := range attrs { + if i == 0 && attr.key == `""` { + continue + } + if attr.optional { + optionalKeys = append(optionalKeys, attr.key) + } else { + requiredKeys = append(requiredKeys, attr.key) + } + } + defer func() { + err = ImportIDValidationError(id, requiredKeys, optionalKeys, err) + }() + externalMinParts := len(requiredKeys) + internalMinParts := externalMinParts + externalMaxParts := len(requiredKeys) + len(optionalKeys) + internalMaxParts := len(attrs) + csvReader := csv.NewReader(strings.NewReader(id)) + csvReader.Comma = ':' + csvReader.LazyQuotes = true + parts, err := csvReader.Read() + if err != nil { + return fmt.Errorf("failed to parse id: %w", err) + } + // if we expect an empty id and have more than just the emptyIDAttribute, we ensure the first part is an empty key + if len(attrs) > 1 && attrs[0].key == emptyIDAttribute.key && parts[0] != "" { + parts = append([]string{""}, parts...) + internalMinParts++ + } + if len(parts) < internalMinParts || len(parts) > internalMaxParts || internalMinParts > 0 && len(id) == 0 { + return fmt.Errorf(`expected the number of semicolon separated parts to be between %d and %d, but got %d parts: "%s"`, externalMinParts, externalMaxParts, len(parts), strings.Join(parts, `", "`)) + } + for i, part := range parts { + part = strings.ReplaceAll(part, SemicolonPlaceholder, `:`) + attr := attrs[i] + // if the id is optional and not given, we use the emptyIDAttribute + if attr.optional && part == "" { + attr = emptyIDAttribute + } + val, err := attr.value(part) + if err != nil { + return fmt.Errorf("invalid value for %s: %w", attr.key, err) + } + if i == 0 { + state.SetId(val.(string)) + continue + } + if err := state.Set(attr.key, val); err != nil { + return fmt.Errorf("failed to set %s=%v: %w", attr.key, val, err) + } + } + return nil +} + +var _ ConvertStringFunc = ConvertID + +func ConvertID(id string) (interface{}, error) { + if !ZitadelGeneratedIdOnlyRegex.MatchString(id) { + return nil, fmt.Errorf(`id "%s" does not match regular expression %s`, id, ZitadelGeneratedIdOnlyRegex.String()) + } + return id, nil +} + +var _ ConvertStringFunc = ConvertJSON + +func ConvertJSON(importValue string) (interface{}, error) { + if err := json.Unmarshal([]byte(importValue), &struct{}{}); err != nil { + return nil, fmt.Errorf("value must be valid JSON: %w", err) + } + return importValue, nil +} + +var _ ConvertStringFunc = ConvertEmpty + +func ConvertEmpty(importValue string) (interface{}, error) { + if len(importValue) > 0 { + return nil, fmt.Errorf(`value must be empty, but got "%s"`, importValue) + } + return "imported", nil +} + +var _ ConvertStringFunc = ConvertNonEmpty + +func ConvertNonEmpty(importValue string) (interface{}, error) { + if len(importValue) == 0 { + return nil, errors.New("value must not be empty") + } + return importValue, nil +} + +func ImportIDValidationError(givenID string, requiredKeys, optionalKeys []string, err error) error { + if err == nil { + return nil + } + expectFormat := fmt.Sprintf("<") + if len(requiredKeys) > 0 { + expectFormat += fmt.Sprintf(":%s", strings.Join(requiredKeys, ":")) + } + if len(optionalKeys) > 0 { + expectFormat += fmt.Sprintf("[:%s]", strings.Join(optionalKeys, "][:")) + } + expectFormat = strings.Replace(expectFormat, "<:", "<", 1) + expectFormat = strings.Replace(expectFormat, "<[:", "<[", 1) + expectFormat += ">" + return fmt.Errorf(`failed to import id "%s" by format %s: %w`, givenID, expectFormat, err) +} diff --git a/zitadel/v2/helper/import_test.go b/zitadel/v2/helper/import_test.go new file mode 100644 index 00000000..acd3322e --- /dev/null +++ b/zitadel/v2/helper/import_test.go @@ -0,0 +1,293 @@ +package helper + +import ( + "fmt" + "reflect" + "strings" + "testing" +) + +func TestImportWithAttributes(t *testing.T) { + validID := "123456789012345678" + type args struct { + attrs []importAttribute + id string + } + type want struct { + attributes map[string]interface{} + expectErrorWithIDFormat string + expectErrorWithMinParts int + expectErrorWithMaxParts int + } + tests := []struct { + name string + args args + want want + }{{ + name: ` with '123...' works`, + args: args{ + attrs: []importAttribute{NewImportAttribute("id", ConvertID, false)}, + id: validID, + }, + want: want{ + attributes: map[string]interface{}{ + "id": validID, + }, + }, + }, { + name: ` with '' fails`, + args: args{ + attrs: []importAttribute{NewImportAttribute("id", ConvertID, false)}, + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 1, + expectErrorWithMaxParts: 1, + }, + }, { + name: ` with '123...:123...' works`, + args: args{ + attrs: []importAttribute{ + NewImportAttribute("id", ConvertID, false), + NewImportAttribute("required_id", ConvertID, false), + }, + id: concat(validID, validID), + }, + want: want{ + attributes: map[string]interface{}{ + "id": validID, + "required_id": validID, + }, + }, + }, { + name: ` with '123...' fails`, + args: args{ + attrs: []importAttribute{ + NewImportAttribute("id", ConvertID, false), + NewImportAttribute("required_id", ConvertID, false), + }, + id: validID, + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 2, + expectErrorWithMaxParts: 2, + }, + }, { + name: ` with '123...:123...:123...' works`, + args: args{ + attrs: []importAttribute{ + NewImportAttribute("id", ConvertID, false), + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: concat(validID, validID, validID), + }, + want: want{ + attributes: map[string]interface{}{ + "id": validID, + "required_id": validID, + "optional_id": validID, + }, + }, + }, { + name: ` with '123...:123...' works`, + args: args{ + attrs: []importAttribute{ + NewImportAttribute("id", ConvertID, false), + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: concat(validID, validID), + }, + want: want{ + attributes: map[string]interface{}{ + "id": validID, + "required_id": validID, + }, + }, + }, { + name: ` with '123...:123...:123...:123...' fails`, + args: args{ + attrs: []importAttribute{ + NewImportAttribute("id", ConvertID, false), + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: concat(validID, validID, validID, validID), + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 2, + expectErrorWithMaxParts: 3, + }, + }, { + name: `<> with '' works`, + args: args{ + attrs: []importAttribute{emptyIDAttribute}, + }, + want: want{ + attributes: map[string]interface{}{ + "id": "imported", + }, + }, + }, { + name: `<> with '123...' fails`, + args: args{ + attrs: []importAttribute{emptyIDAttribute}, + id: validID, + }, + want: want{ + expectErrorWithIDFormat: "<>", + expectErrorWithMinParts: -1, + expectErrorWithMaxParts: -1, + }, + }, { + name: `<[org_id]> with '123...' works`, + args: args{ + attrs: []importAttribute{ImportOptionalOrgAttribute}, + id: validID, + }, + want: want{ + attributes: map[string]interface{}{ + "id": validID, + "org_id": validID, + }, + }, + }, { + name: `<[org_id]> with '' works`, + args: args{ + attrs: []importAttribute{ImportOptionalOrgAttribute}, + }, + want: want{ + attributes: map[string]interface{}{ + "id": "imported", + }, + }, + }, { + name: `<[org_id]> with 'invalid id' fails`, + args: args{ + attrs: []importAttribute{ImportOptionalOrgAttribute}, + id: "invalid id", + }, + want: want{ + expectErrorWithIDFormat: "<[org_id]>", + expectErrorWithMinParts: -1, + expectErrorWithMaxParts: -1, + }, + }, { + name: ` with empty id and '123...:123...' works`, + args: args{ + attrs: []importAttribute{ + emptyIDAttribute, + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: concat(validID, validID), + }, + want: want{ + attributes: map[string]interface{}{ + "id": "imported", + "required_id": validID, + "optional_id": validID, + }, + }, + }, { + name: ` with empty id and '123...:123...:123...' fails`, + args: args{ + attrs: []importAttribute{ + emptyIDAttribute, + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: concat(validID, validID, validID), + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 1, + expectErrorWithMaxParts: 2, + }, + }, { + name: ` with empty id and '' fails`, + args: args{ + attrs: []importAttribute{ + emptyIDAttribute, + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 1, + expectErrorWithMaxParts: 2, + }, + }, { + name: ` with empty id and '123...' fails`, + args: args{ + attrs: []importAttribute{ + emptyIDAttribute, + NewImportAttribute("required_id", ConvertID, false), + NewImportAttribute("another_required_id", ConvertID, false), + NewImportAttribute("optional_id", ConvertID, true), + }, + id: validID, + }, + want: want{ + expectErrorWithIDFormat: "", + expectErrorWithMinParts: 2, + expectErrorWithMaxParts: 3, + }, + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + state := newMockState() + state.SetId(tt.args.id) + err := importWithAttributes(state, tt.args.attrs...) + wantAttributes := tt.want.attributes + if err != nil { + if tt.want.expectErrorWithIDFormat == "" { + t.Fatalf("importWithAttributes() error = %v, want %v", err, wantAttributes) + } + expectBetweenError := fmt.Sprintf("between %d and %d", tt.want.expectErrorWithMinParts, tt.want.expectErrorWithMaxParts) + if (tt.want.expectErrorWithMinParts > -1 || tt.want.expectErrorWithMaxParts > -1) && + !strings.Contains(err.Error(), expectBetweenError) { + t.Errorf(`expected error to contain "%s", got: %v`, expectBetweenError, err) + } + if !strings.Contains(err.Error(), tt.want.expectErrorWithIDFormat) { + t.Errorf("expected error to contain the expected format '%s', got: %v", tt.want.expectErrorWithIDFormat, err) + } + return + } + if tt.want.expectErrorWithIDFormat != "" { + t.Fatalf("expected error with format '%s', got state: %v", tt.want.expectErrorWithIDFormat, state) + } + if !reflect.DeepEqual(state, mockState(wantAttributes)) { + t.Errorf("importWithAttributes() = %v, want %v", state, wantAttributes) + } + }) + } +} + +func newMockState() mockState { return make(map[string]interface{}) } + +type mockState map[string]interface{} + +// SetId sets the ID of the state. +func (m mockState) SetId(id string) { + m["id"] = id +} + +// Id returns the ID of the state. +func (m mockState) Id() string { + return m["id"].(string) +} + +// Set sets the value of the given attribute. +func (m mockState) Set(key string, value interface{}) error { + m[key] = value + return nil +} + +func concat(attr ...string) string { + return strings.Join(attr, ":") +} diff --git a/zitadel/v2/helper/schema.go b/zitadel/v2/helper/schema.go new file mode 100644 index 00000000..c65583c2 --- /dev/null +++ b/zitadel/v2/helper/schema.go @@ -0,0 +1,43 @@ +package helper + +import ( + "fmt" + "regexp" + + "github.com/hashicorp/go-cty/cty" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +const ( + OrgIDVar = "org_id" +) + +var ( + // ZitadelGeneratedIdPattern matches IDs like 123456789012345678 + // ZITADEL IDs have 18 digits + ZitadelGeneratedIdPattern = `\d{18}` + ZitadelGeneratedIdOnlyRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ZitadelGeneratedIdPattern)) + + OrgIDResourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "ID of the organization", + ForceNew: true, + ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics { + _, err := ConvertID(i.(string)) + return diag.FromErr(err) + }, + } + + ResourceIDDatasourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "ID of the resource", + } + OrgIDDatasourceField = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "ID of the organization", + } +) diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/v2/helper/test_utils/import_id.go new file mode 100644 index 00000000..60ed40f9 --- /dev/null +++ b/zitadel/v2/helper/test_utils/import_id.go @@ -0,0 +1,57 @@ +package test_utils + +import ( + "fmt" + "regexp" + "strings" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +var ( + _ resource.ImportStateIdFunc = ImportNothing + ZitadelGeneratedIdPattern = `\d{18}` + ZitadelGeneratedIdOnlyRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ZitadelGeneratedIdPattern)) +) + +func ImportResourceId(frame BaseTestFrame) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + return frame.State(state).ID, nil + } +} + +func ImportOrgId(frame *OrgTestFrame) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + return frame.OrgID, nil + } +} + +func ImportStateAttribute(frame BaseTestFrame, attr string) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + primary := frame.State(state) + val, ok := primary.Attributes[attr] + if !ok { + return "", fmt.Errorf("attribute %s not found in attributes %+v", attr, primary.Attributes) + } + return fmt.Sprintf(`"%s"`, strings.ReplaceAll(val, ":", helper.SemicolonPlaceholder)), nil + } +} + +func ImportNothing(_ *terraform.State) (string, error) { return "", nil } + +func ChainImportStateIdFuncs(funcs ...resource.ImportStateIdFunc) resource.ImportStateIdFunc { + return func(state *terraform.State) (string, error) { + parts := make([]string, len(funcs)) + for i, f := range funcs { + part, err := f(state) + if err != nil { + return "", err + } + parts[i] = part + } + return strings.Join(parts, ":"), nil + } +} diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/v2/helper/test_utils/lifecyletest.go index 4d0b41da..928a3e24 100644 --- a/zitadel/v2/helper/test_utils/lifecyletest.go +++ b/zitadel/v2/helper/test_utils/lifecyletest.go @@ -2,6 +2,7 @@ package test_utils import ( "fmt" + "os" "regexp" "strings" "testing" @@ -15,19 +16,16 @@ func RunLifecyleTest[P comparable]( datasources []string, resourceFunc func(property P, secret string) string, exampleProperty, updatedProperty P, - exampleSecret, updatedSecret string, + secretAttribute, exampleSecret, updatedSecret string, allowNonEmptyPlan bool, checkRemoteProperty func(expect P) resource.TestCheckFunc, idPattern *regexp.Regexp, - checkDestroy, checkImportState resource.TestCheckFunc, + checkDestroy resource.TestCheckFunc, importStateIdFunc resource.ImportStateIdFunc, - wrongImportID, - secretAttribute string, + importStateVerifyIgnore ...string, ) { - var importStateVerifyIgnore []string exampleConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(exampleProperty, exampleSecret)) updatedPropertyConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(updatedProperty, exampleSecret)) - updatedSecretConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(updatedProperty, updatedSecret)) steps := []resource.TestStep{ { // Check first plan has a diff Config: exampleConfig, @@ -50,7 +48,18 @@ func RunLifecyleTest[P comparable]( Check: CheckAMinute(checkRemoteProperty(updatedProperty)), }, } + if importStateIdFunc != nil { + steps = append(steps, resource.TestStep{ // Expect importing works + Config: updatedPropertyConfig, + ResourceName: frame.TerraformName, + ImportState: true, + ImportStateIdFunc: importStateIdFunc, + ImportStateVerify: true, + ImportStateVerifyIgnore: importStateVerifyIgnore, + }) + } if secretAttribute != "" { + updatedSecretConfig := fmt.Sprintf("%s\n%s\n%s", frame.ProviderSnippet, strings.Join(datasources, "\n"), resourceFunc(updatedProperty, updatedSecret)) steps = append(steps, resource.TestStep{ // Check that secret has a diff Config: updatedSecretConfig, ExpectNonEmptyPlan: true, @@ -61,29 +70,11 @@ func RunLifecyleTest[P comparable]( }) importStateVerifyIgnore = []string{secretAttribute} } - if wrongImportID != "" { - steps = append(steps, resource.TestStep{ // Expect import error if secret is not given - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateId: wrongImportID, - ExpectError: regexp.MustCompile(wrongImportID), - }) - } - if checkImportState != nil { - steps = append(steps, resource.TestStep{ // Expect importing works - ResourceName: frame.TerraformName, - ImportState: true, - ImportStateIdFunc: importStateIdFunc, - ImportStateVerify: true, - ImportStateVerifyIgnore: importStateVerifyIgnore, - Check: checkImportState, - }) - } resource.ParallelTest(t, resource.TestCase{ CheckDestroy: CheckAMinute(checkDestroy), Steps: steps, ErrorCheck: func(err error) error { - if err != nil && allowNonEmptyPlan && strings.Contains(err.Error(), "After applying this test step and performing a `terraform refresh`, the plan was not empty") { + if err != nil && allowNonEmptyPlan && os.Getenv("CI") == "true" && strings.Contains(err.Error(), "After applying this test step and performing a `terraform refresh`, the plan was not empty") { t.Logf("Ignoring non-empty plan error because we can't guarantee consistency: %s", err.Error()) return nil } diff --git a/zitadel/v2/human_user/const.go b/zitadel/v2/human_user/const.go index db6abfe3..30273d26 100644 --- a/zitadel/v2/human_user/const.go +++ b/zitadel/v2/human_user/const.go @@ -2,7 +2,6 @@ package human_user const ( UserIDVar = "user_id" - orgIDVar = "org_id" userStateVar = "state" UserNameVar = "user_name" loginNamesVar = "login_names" diff --git a/zitadel/v2/human_user/datasource.go b/zitadel/v2/human_user/datasource.go index 977ae3f4..c3b81f75 100644 --- a/zitadel/v2/human_user/datasource.go +++ b/zitadel/v2/human_user/datasource.go @@ -2,6 +2,7 @@ package human_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", @@ -93,6 +94,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index 0caf125e..c5fc1745 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -109,7 +109,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -171,7 +171,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -187,7 +187,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn user := respUser.GetUser() set := map[string]interface{}{ - orgIDVar: user.GetDetails().GetResourceOwner(), + helper.OrgIDVar: user.GetDetails().GetResourceOwner(), userStateVar: user.GetState().String(), UserNameVar: user.GetUserName(), loginNamesVar: user.GetLoginNames(), diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index 389ce0bb..bc1a07d7 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -16,12 +16,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a human user situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, userStateVar: { Type: schema.TypeString, Computed: true, diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/v2/init_message_text/resource.go index b7b76639..626897eb 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/v2/init_message_text/resource.go @@ -19,7 +19,6 @@ import ( ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +207,7 @@ func (r *initMessageTextResource) Delete(ctx context.Context, req resource.Delet func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +217,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +237,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/label_policy/const.go b/zitadel/v2/label_policy/const.go index 0bf958bc..a2caf3a5 100644 --- a/zitadel/v2/label_policy/const.go +++ b/zitadel/v2/label_policy/const.go @@ -1,7 +1,6 @@ package label_policy const ( - orgIDVar = "org_id" primaryColorVar = "primary_color" hideLoginNameSuffixVar = "hide_login_name_suffix" warnColorVar = "warn_color" diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index da79a92a..a7434b1c 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -40,7 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -136,7 +136,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -202,7 +202,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go index b153d32e..50199608 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/v2/label_policy/resource.go @@ -2,18 +2,14 @@ package label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom label policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, primaryColorVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/lockout_policy/const.go b/zitadel/v2/lockout_policy/const.go index 675bc38a..e2b070a3 100644 --- a/zitadel/v2/lockout_policy/const.go +++ b/zitadel/v2/lockout_policy/const.go @@ -1,6 +1,5 @@ package lockout_policy const ( - orgIDVar = "org_id" maxPasswordAttemptsVar = "max_password_attempts" ) diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go index cf4d043d..9486a91c 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/v2/lockout_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -40,7 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -62,7 +62,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -86,7 +86,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -107,7 +107,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), maxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), } diff --git a/zitadel/v2/lockout_policy/resource.go b/zitadel/v2/lockout_policy/resource.go index ced801b9..cac21c73 100644 --- a/zitadel/v2/lockout_policy/resource.go +++ b/zitadel/v2/lockout_policy/resource.go @@ -2,19 +2,14 @@ package lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom lockout policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, maxPasswordAttemptsVar: { Type: schema.TypeInt, Required: true, diff --git a/zitadel/v2/login_policy/const.go b/zitadel/v2/login_policy/const.go index d8188bab..0ea4894f 100644 --- a/zitadel/v2/login_policy/const.go +++ b/zitadel/v2/login_policy/const.go @@ -1,7 +1,6 @@ package login_policy const ( - orgIDVar = "org_id" allowUsernamePasswordVar = "user_login" allowRegisterVar = "allow_register" allowExternalIDPVar = "allow_external_idp" diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index b37fb7b9..8ee7388f 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -24,7 +24,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -45,7 +45,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -181,7 +181,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -292,7 +292,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -313,7 +313,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), allowUsernamePasswordVar: policy.GetAllowUsernamePassword(), allowRegisterVar: policy.GetAllowRegister(), allowExternalIDPVar: policy.GetAllowExternalIdp(), diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index 9e4bedee..c5d1067a 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -2,18 +2,14 @@ package login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom login policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, allowUsernamePasswordVar: { Type: schema.TypeBool, Required: true, diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index b4dc0a42..5074ade5 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *loginTextsResource) Delete(ctx context.Context, req resource.DeleteRequ func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/machine_key/const.go b/zitadel/v2/machine_key/const.go index 9b255aa5..eb47a319 100644 --- a/zitadel/v2/machine_key/const.go +++ b/zitadel/v2/machine_key/const.go @@ -1,7 +1,6 @@ package machine_key const ( - orgIDVar = "org_id" userIDVar = "user_id" keyTypeVar = "key_type" keyDetailsVar = "key_details" diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go index 90359b15..0a16dd8e 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/v2/machine_key/funcs.go @@ -22,7 +22,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -45,7 +45,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -83,7 +83,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -106,7 +106,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ ExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), userIDVar: userID, - orgIDVar: orgID, + helper.OrgIDVar: orgID, } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index cccaf8c5..14cc03aa 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -13,12 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a machine key", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, userIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/machine_user/const.go b/zitadel/v2/machine_user/const.go index e8ae79a4..8233f9bc 100644 --- a/zitadel/v2/machine_user/const.go +++ b/zitadel/v2/machine_user/const.go @@ -6,7 +6,6 @@ import ( const ( UserIDVar = "user_id" - orgIDVar = "org_id" userStateVar = "state" UserNameVar = "user_name" loginNamesVar = "login_names" diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index c7005d3a..76ec140a 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -1,6 +1,9 @@ package machine_user -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -11,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", @@ -56,6 +59,5 @@ func GetDatasource() *schema.Resource { Description: "Access token type", }}, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/v2/machine_user/funcs.go index 07ee3261..55f6af52 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/v2/machine_user/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -70,7 +70,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -107,7 +107,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -123,7 +123,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn user := respUser.GetUser() set := map[string]interface{}{ - orgIDVar: user.GetDetails().GetResourceOwner(), + helper.OrgIDVar: user.GetDetails().GetResourceOwner(), userStateVar: user.GetState().String(), UserNameVar: user.GetUserName(), loginNamesVar: user.GetLoginNames(), diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 3d47e771..1aa5357f 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -13,12 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, userStateVar: { Type: schema.TypeString, Computed: true, diff --git a/zitadel/v2/notification_policy/const.go b/zitadel/v2/notification_policy/const.go index 2c300346..2576d012 100644 --- a/zitadel/v2/notification_policy/const.go +++ b/zitadel/v2/notification_policy/const.go @@ -1,6 +1,5 @@ package notification_policy const ( - orgIDVar = "org_id" passwordChangeVar = "password_change" ) diff --git a/zitadel/v2/notification_policy/funcs.go b/zitadel/v2/notification_policy/funcs.go index 4c74b497..17b840cc 100644 --- a/zitadel/v2/notification_policy/funcs.go +++ b/zitadel/v2/notification_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -39,11 +39,11 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) if d.HasChanges(passwordChangeVar) { _, err = client.UpdateCustomNotificationPolicy(ctx, &management.UpdateCustomNotificationPolicyRequest{ @@ -65,11 +65,11 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) _, err = client.AddCustomNotificationPolicy(ctx, &management.AddCustomNotificationPolicyRequest{ PasswordChange: d.Get(passwordChangeVar).(bool), @@ -89,7 +89,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -110,7 +110,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), passwordChangeVar: policy.GetPasswordChange(), } diff --git a/zitadel/v2/notification_policy/resource.go b/zitadel/v2/notification_policy/resource.go index c347f89a..9f2dd8ed 100644 --- a/zitadel/v2/notification_policy/resource.go +++ b/zitadel/v2/notification_policy/resource.go @@ -2,18 +2,14 @@ package notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom notification policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, passwordChangeVar: { Type: schema.TypeBool, Required: true, diff --git a/zitadel/v2/org/datasource.go b/zitadel/v2/org/datasource.go index a546ca2c..a6aca9b9 100644 --- a/zitadel/v2/org/datasource.go +++ b/zitadel/v2/org/datasource.go @@ -17,7 +17,11 @@ func GetDatasource() *schema.Resource { OrgIDVar: { Type: schema.TypeString, Required: true, - Description: "An organizations resource ID.", + Description: "ID of the organization", + ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics { + _, err := helper.ConvertID(i.(string)) + return diag.FromErr(err) + }, }, NameVar: { Type: schema.TypeString, diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index 5719e8de..ccd94425 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -3,6 +3,7 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing an Azure AD IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/v2/org_idp_azure_ad/funcs.go index 510d9345..fbe6c430 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/v2/org_idp_azure_ad/funcs.go @@ -11,7 +11,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -19,7 +18,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -48,7 +47,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -77,7 +76,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -94,7 +93,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetAzureAd() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: respIdp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: respIdp.GetDetails().GetResourceOwner(), idp_utils.NameVar: respIdp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index 859ec1ea..f595f86a 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -2,6 +2,7 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,7 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an Azure AD IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 984700b6..070e2d5e 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -3,6 +3,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -12,7 +13,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing a GitHub IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/v2/org_idp_github/funcs.go index 5b1fee50..b71f7178 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/v2/org_idp_github/funcs.go @@ -9,7 +9,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -17,7 +16,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -40,7 +39,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -63,7 +62,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -80,7 +79,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithub() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 2c436ad9..054b63c6 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -2,6 +2,7 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -11,7 +12,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index ab413b55..013e9db9 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -3,6 +3,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing a GitHub Enterprise IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/v2/org_idp_github_es/funcs.go index 841ec115..c859fd6d 100644 --- a/zitadel/v2/org_idp_github_es/funcs.go +++ b/zitadel/v2/org_idp_github_es/funcs.go @@ -10,7 +10,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -18,7 +17,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -44,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -70,7 +69,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -87,7 +86,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGithubEs() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index 97442e81..6975e319 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -2,6 +2,7 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,7 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitHub Enterprise IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index b30198c0..3a8bc6bc 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -3,6 +3,7 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -12,7 +13,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing a GitLab IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_gitlab/funcs.go b/zitadel/v2/org_idp_gitlab/funcs.go index db512a6e..1782421c 100644 --- a/zitadel/v2/org_idp_gitlab/funcs.go +++ b/zitadel/v2/org_idp_gitlab/funcs.go @@ -9,7 +9,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -17,7 +16,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -40,7 +39,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -63,7 +62,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -80,7 +79,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGitlab() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index f08745cb..fa41d9d0 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -2,6 +2,7 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -11,7 +12,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index ebe1c761..38c8d316 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -3,6 +3,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing a GitLab Self Hosted IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go index 24a18a84..1b7b9716 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go @@ -10,7 +10,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -18,7 +17,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -42,7 +41,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -66,7 +65,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -83,7 +82,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGitlabSelfHosted() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index a0733237..26842084 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -2,6 +2,7 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,7 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a GitLab Self Hosted IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index b4975069..a2ad061a 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -3,6 +3,7 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -12,7 +13,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing a Google IdP of the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, diff --git a/zitadel/v2/org_idp_google/funcs.go b/zitadel/v2/org_idp_google/funcs.go index 882bbd85..696063d5 100644 --- a/zitadel/v2/org_idp_google/funcs.go +++ b/zitadel/v2/org_idp_google/funcs.go @@ -9,7 +9,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -17,7 +16,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -40,7 +39,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -63,7 +62,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -80,7 +79,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn specificCfg := cfg.GetGoogle() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.ClientIDVar: specificCfg.GetClientId(), idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 40035b3a..1872d857 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -2,6 +2,7 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -11,7 +12,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a Google IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, diff --git a/zitadel/v2/org_idp_jwt/const.go b/zitadel/v2/org_idp_jwt/const.go index 02bccfdf..7410d1ad 100644 --- a/zitadel/v2/org_idp_jwt/const.go +++ b/zitadel/v2/org_idp_jwt/const.go @@ -2,7 +2,6 @@ package org_idp_jwt const ( idpIDVar = "idp_id" - orgIDVar = "org_id" nameVar = "name" stylingTypeVar = "styling_type" issuerVar = "issuer" diff --git a/zitadel/v2/org_idp_jwt/datasource.go b/zitadel/v2/org_idp_jwt/datasource.go index 5b607469..48ed201a 100644 --- a/zitadel/v2/org_idp_jwt/datasource.go +++ b/zitadel/v2/org_idp_jwt/datasource.go @@ -2,6 +2,7 @@ package org_idp_jwt import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", @@ -55,6 +56,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/org_idp_jwt/funcs.go b/zitadel/v2/org_idp_jwt/funcs.go index aaf54dfd..8bb49e4a 100644 --- a/zitadel/v2/org_idp_jwt/funcs.go +++ b/zitadel/v2/org_idp_jwt/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -71,7 +71,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -111,7 +111,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -128,7 +128,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp := resp.GetIdp() jwt := idp.GetJwtConfig() set := map[string]interface{}{ - orgIDVar: idp.GetDetails().ResourceOwner, + helper.OrgIDVar: idp.GetDetails().ResourceOwner, nameVar: idp.GetName(), stylingTypeVar: idp.GetStylingType().String(), JwtEndpointVar: jwt.GetJwtEndpoint(), diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index 2d20f85f..679c936e 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -14,12 +14,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a generic JWT IdP of the organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, nameVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go index 74fc981e..55e0a379 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -3,6 +3,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Description: "Datasource representing an LDAP IdP on the organization.", Schema: map[string]*schema.Schema{ idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDDatasourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, idp_utils.NameVar: idp_utils.NameDataSourceField, idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/v2/org_idp_ldap/funcs.go index d1d60607..f950ec0b 100644 --- a/zitadel/v2/org_idp_ldap/funcs.go +++ b/zitadel/v2/org_idp_ldap/funcs.go @@ -13,7 +13,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -21,7 +20,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -71,7 +70,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -121,7 +120,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, org_idp_utils.OrgIDVar)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } @@ -139,7 +138,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn attributesCfg := specificCfg.GetAttributes() generalCfg := cfg.GetOptions() set := map[string]interface{}{ - org_idp_utils.OrgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), idp_utils.NameVar: idp.GetName(), idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/v2/org_idp_ldap/resource.go index 40f2d2e1..68ea6160 100644 --- a/zitadel/v2/org_idp_ldap/resource.go +++ b/zitadel/v2/org_idp_ldap/resource.go @@ -2,6 +2,7 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" @@ -12,7 +13,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing an LDAP IdP on the organization.", Schema: map[string]*schema.Schema{ - org_idp_utils.OrgIDVar: org_idp_utils.OrgIDResourceField, + helper.OrgIDVar: helper.OrgIDResourceField, idp_utils.NameVar: idp_utils.NameResourceField, idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, diff --git a/zitadel/v2/org_idp_oidc/const.go b/zitadel/v2/org_idp_oidc/const.go index 7200ded4..f081d0bb 100644 --- a/zitadel/v2/org_idp_oidc/const.go +++ b/zitadel/v2/org_idp_oidc/const.go @@ -2,7 +2,6 @@ package org_idp_oidc const ( idpIDVar = "idp_id" - orgIDVar = "org_id" nameVar = "name" stylingTypeVar = "styling_type" clientIDVar = "client_id" diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go index dfd71212..f9d8b9b0 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -2,6 +2,7 @@ package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -13,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", @@ -70,6 +71,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index 34da65f0..839ce0c0 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -74,7 +74,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -117,7 +117,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -134,7 +134,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn idp := resp.GetIdp() oidc := idp.GetOidcConfig() set := map[string]interface{}{ - orgIDVar: idp.GetDetails().GetResourceOwner(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), nameVar: idp.GetName(), stylingTypeVar: idp.GetStylingType().String(), clientIDVar: oidc.GetClientId(), diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index 89c12ef0..0ba7abb1 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -14,12 +14,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a generic OIDC IdP on the organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, nameVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index ad825ead..93828379 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -18,7 +18,7 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -37,9 +37,9 @@ func ImportIDPWithOrg() schema.StateContextFunc { } parts := strings.SplitN(id, ":", 2) if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, OrgIDVar, idp_utils.IdpIDVar) + return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, helper.OrgIDVar, idp_utils.IdpIDVar) } - if err := data.Set(OrgIDVar, parts[0]); err != nil { + if err := data.Set(helper.OrgIDVar, parts[0]); err != nil { return nil, err } data.SetId(parts[1]) @@ -55,9 +55,9 @@ func ImportIDPWithOrgAndSecret(secretVar string) schema.StateContextFunc { } parts := strings.SplitN(id, ":", 3) if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s:%s", id, OrgIDVar, idp_utils.IdpIDVar, secretVar) + return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s:%s", id, helper.OrgIDVar, idp_utils.IdpIDVar, secretVar) } - if err := data.Set(OrgIDVar, parts[0]); err != nil { + if err := data.Set(helper.OrgIDVar, parts[0]); err != nil { return nil, err } data.SetId(parts[1]) diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index 3f424532..d91ebd13 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { @@ -42,7 +42,7 @@ func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { }, func(state *terraform.State) (string, error) { lastState := frame.State(state) - return fmt.Sprintf("%s:%s:%s", lastState.Attributes[org_idp_utils.OrgIDVar], lastState.ID, importedSecret), nil + return fmt.Sprintf("%s:%s:%s", lastState.Attributes[helper.OrgIDVar], lastState.ID, importedSecret), nil }, "123:456", secretAttribute, diff --git a/zitadel/v2/org_idp_utils/resource.go b/zitadel/v2/org_idp_utils/resource.go deleted file mode 100644 index aee87d06..00000000 --- a/zitadel/v2/org_idp_utils/resource.go +++ /dev/null @@ -1 +0,0 @@ -package org_idp_utils diff --git a/zitadel/v2/org_idp_utils/schema.go b/zitadel/v2/org_idp_utils/schema.go deleted file mode 100644 index 8623fd7f..00000000 --- a/zitadel/v2/org_idp_utils/schema.go +++ /dev/null @@ -1,21 +0,0 @@ -package org_idp_utils - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -const ( - OrgIDVar = "org_id" -) - -var ( - OrgIDResourceField = &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - } - OrgIDDatasourceField = &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - } -) diff --git a/zitadel/v2/org_member/const.go b/zitadel/v2/org_member/const.go index bbdc3261..1ccebfa2 100644 --- a/zitadel/v2/org_member/const.go +++ b/zitadel/v2/org_member/const.go @@ -1,7 +1,6 @@ package org_member const ( - orgIDVar = "org_id" userIDVar = "user_id" RolesVar = "roles" ) diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index f30f8306..fbc45e54 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -21,7 +21,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -43,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -66,7 +66,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -91,7 +91,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -118,9 +118,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { orgMember := resp.Result[0] set := map[string]interface{}{ - userIDVar: orgMember.GetUserId(), - orgIDVar: orgMember.GetDetails().GetResourceOwner(), - RolesVar: orgMember.GetRoles(), + userIDVar: orgMember.GetUserId(), + helper.OrgIDVar: orgMember.GetDetails().GetResourceOwner(), + RolesVar: orgMember.GetRoles(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/org_member/resource.go b/zitadel/v2/org_member/resource.go index e9aebad0..fd869fed 100644 --- a/zitadel/v2/org_member/resource.go +++ b/zitadel/v2/org_member/resource.go @@ -2,18 +2,14 @@ package org_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the membership of a user on an organization, defined with the given role.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "ID of the organization", - }, + helper.OrgIDVar: helper.OrgIDResourceField, userIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/v2/password_change_message_text/resource.go index 704db239..4716faff 100644 --- a/zitadel/v2/password_change_message_text/resource.go +++ b/zitadel/v2/password_change_message_text/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *passwordChangeMessageTextResource) Delete(ctx context.Context, req reso func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/password_complexity_policy/const.go b/zitadel/v2/password_complexity_policy/const.go index 6b1a38ec..b9547df3 100644 --- a/zitadel/v2/password_complexity_policy/const.go +++ b/zitadel/v2/password_complexity_policy/const.go @@ -1,7 +1,6 @@ package password_complexity_policy const ( - orgIDVar = "org_id" minLengthVar = "min_length" hasUppercaseVar = "has_uppercase" hasLowercaseVar = "has_lowercase" diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go index e4d5b0b4..a7be8897 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -40,7 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -67,7 +67,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -95,7 +95,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -116,7 +116,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), minLengthVar: policy.GetMinLength(), hasUppercaseVar: policy.GetHasUppercase(), hasLowercaseVar: policy.GetHasLowercase(), diff --git a/zitadel/v2/password_complexity_policy/resource.go b/zitadel/v2/password_complexity_policy/resource.go index e9152277..de1b9077 100644 --- a/zitadel/v2/password_complexity_policy/resource.go +++ b/zitadel/v2/password_complexity_policy/resource.go @@ -2,18 +2,14 @@ package password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom password complexity policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, minLengthVar: { Type: schema.TypeInt, Required: true, diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index 8740e163..80a2da1f 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *passwordResetMessageTextResource) Delete(ctx context.Context, req resou func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/v2/passwordless_registration_message_text/resource.go index 215495dd..b2429f87 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/v2/passwordless_registration_message_text/resource.go @@ -19,7 +19,6 @@ import ( ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +207,7 @@ func (r *passwordlessRegistrationMessageTextResource) Delete(ctx context.Context func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +217,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +237,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/pat/const.go b/zitadel/v2/pat/const.go index d7334d5d..0e63bec8 100644 --- a/zitadel/v2/pat/const.go +++ b/zitadel/v2/pat/const.go @@ -1,7 +1,6 @@ package pat const ( - orgIDVar = "org_id" userIDVar = "user_id" tokenVar = "token" ExpirationDateVar = "expiration_date" diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go index 02fd5c02..4ff8ff52 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/v2/pat/funcs.go @@ -21,7 +21,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -44,7 +44,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -80,7 +80,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -102,7 +102,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ ExpirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), userIDVar: userID, - orgIDVar: orgID, + helper.OrgIDVar: orgID, } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index d5b52f0e..ca2d6a93 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -2,18 +2,14 @@ package pat import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a personal access token of a user", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, userIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/privacy_policy/const.go b/zitadel/v2/privacy_policy/const.go index 10e390ce..524c1e02 100644 --- a/zitadel/v2/privacy_policy/const.go +++ b/zitadel/v2/privacy_policy/const.go @@ -1,7 +1,6 @@ package privacy_policy const ( - orgIDVar = "org_id" tosLinkVar = "tos_link" privacyLinkVar = "privacy_link" HelpLinkVar = "help_link" diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/v2/privacy_policy/funcs.go index 02b4aa89..65d2012c 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/v2/privacy_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -40,7 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -66,7 +66,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -93,7 +93,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -114,7 +114,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ - orgIDVar: policy.GetDetails().GetResourceOwner(), + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), tosLinkVar: policy.GetTosLink(), privacyLinkVar: policy.GetPrivacyLink(), HelpLinkVar: policy.GetHelpLink(), diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go index be732eed..c42edd0f 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/v2/privacy_policy/resource.go @@ -2,18 +2,14 @@ package privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the custom privacy policy of an organization.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Id for the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, tosLinkVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/project/const.go b/zitadel/v2/project/const.go index ca552f24..403e0ea9 100644 --- a/zitadel/v2/project/const.go +++ b/zitadel/v2/project/const.go @@ -6,7 +6,6 @@ const ( ProjectIDVar = "project_id" NameVar = "name" stateVar = "state" - orgIDVar = "org_id" roleAssertionVar = "project_role_assertion" roleCheckVar = "project_role_check" hasProjectCheckVar = "has_project_check" diff --git a/zitadel/v2/project/datasource.go b/zitadel/v2/project/datasource.go index 65323cc3..ee215bb0 100644 --- a/zitadel/v2/project/datasource.go +++ b/zitadel/v2/project/datasource.go @@ -2,6 +2,7 @@ package project import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { @@ -18,11 +19,7 @@ func GetDatasource() *schema.Resource { Computed: true, Description: "Name of the project", }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Organization in which the project is located", - }, + helper.OrgIDVar: helper.OrgIDResourceField, stateVar: { Type: schema.TypeString, Computed: true, @@ -50,6 +47,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/project/funcs.go b/zitadel/v2/project/funcs.go index 1ab5a1ac..ca869e27 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/v2/project/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -70,7 +70,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -98,7 +98,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -114,7 +114,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn project := resp.GetProject() set := map[string]interface{}{ - orgIDVar: project.GetDetails().GetResourceOwner(), + helper.OrgIDVar: project.GetDetails().GetResourceOwner(), stateVar: project.GetState().String(), NameVar: project.GetName(), roleAssertionVar: project.GetProjectRoleAssertion(), diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index eab7934e..894312da 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -13,16 +13,12 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the project, which can then be granted to different organizations or users directly, containing different applications.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDResourceField, NameVar: { Type: schema.TypeString, Required: true, Description: "Name of the project", }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "Organization in which the project is located", - }, stateVar: { Type: schema.TypeString, Computed: true, diff --git a/zitadel/v2/project_grant/const.go b/zitadel/v2/project_grant/const.go index 34bf5bc3..c146b079 100644 --- a/zitadel/v2/project_grant/const.go +++ b/zitadel/v2/project_grant/const.go @@ -1,7 +1,6 @@ package project_grant const ( - orgIDVar = "org_id" projectIDVar = "project_id" grantedOrgIDVar = "granted_org_id" RoleKeysVar = "role_keys" diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go index 025bc94b..03762a94 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/v2/project_grant/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -42,7 +42,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -66,7 +66,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -91,7 +91,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -110,7 +110,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn projectIDVar: projectGrant.GetProjectId(), grantedOrgIDVar: projectGrant.GetGrantedOrgId(), RoleKeysVar: projectGrant.GetGrantedRoleKeys(), - orgIDVar: projectGrant.GetDetails().GetResourceOwner(), + helper.OrgIDVar: projectGrant.GetDetails().GetResourceOwner(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/v2/project_grant/resource.go index 8d620135..82b1d587 100644 --- a/zitadel/v2/project_grant/resource.go +++ b/zitadel/v2/project_grant/resource.go @@ -2,12 +2,14 @@ package project_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, @@ -28,11 +30,6 @@ func GetResource() *schema.Resource { Optional: true, Description: "List of roles granted", }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - }, }, DeleteContext: delete, CreateContext: create, diff --git a/zitadel/v2/project_grant_member/const.go b/zitadel/v2/project_grant_member/const.go index f5f08567..77f74c30 100644 --- a/zitadel/v2/project_grant_member/const.go +++ b/zitadel/v2/project_grant_member/const.go @@ -1,7 +1,6 @@ package project_grant_member const ( - orgIDVar = "org_id" projectIDVar = "project_id" GrantIDVar = "grant_id" userIDVar = "user_id" diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index 43dc5407..548c4470 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -44,7 +44,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -69,7 +69,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -98,7 +98,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -129,11 +129,11 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { memberRes := resp.Result[0] set := map[string]interface{}{ - userIDVar: userID, - orgIDVar: org, - projectIDVar: projectID, - RolesVar: memberRes.GetRoles(), - GrantIDVar: grantID, + userIDVar: userID, + helper.OrgIDVar: org, + projectIDVar: projectID, + RolesVar: memberRes.GetRoles(), + GrantIDVar: grantID, } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/v2/project_grant_member/resource.go index c2e7a879..7a9cbb7e 100644 --- a/zitadel/v2/project_grant_member/resource.go +++ b/zitadel/v2/project_grant_member/resource.go @@ -2,18 +2,14 @@ package project_grant_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the membership of a user on an granted project, defined with the given role.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/project_member/const.go b/zitadel/v2/project_member/const.go index b844b48d..18ba11dd 100644 --- a/zitadel/v2/project_member/const.go +++ b/zitadel/v2/project_member/const.go @@ -1,7 +1,6 @@ package project_member const ( - orgIDVar = "org_id" projectIDVar = "project_id" userIDVar = "user_id" rolesVar = "roles" diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go index 5fa2308e..26e0c689 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/v2/project_member/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -43,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -94,7 +94,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - org := d.Get(orgIDVar).(string) + org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -123,10 +123,10 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { memberRes := resp.Result[0] set := map[string]interface{}{ - userIDVar: memberRes.GetUserId(), - orgIDVar: memberRes.GetDetails().GetResourceOwner(), - projectIDVar: projectID, - rolesVar: memberRes.GetRoles(), + userIDVar: memberRes.GetUserId(), + helper.OrgIDVar: memberRes.GetDetails().GetResourceOwner(), + projectIDVar: projectID, + rolesVar: memberRes.GetRoles(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/project_member/resource.go b/zitadel/v2/project_member/resource.go index 3968334d..38a4fde3 100644 --- a/zitadel/v2/project_member/resource.go +++ b/zitadel/v2/project_member/resource.go @@ -2,18 +2,14 @@ package project_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the membership of a user on an project, defined with the given role.", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/project_role/const.go b/zitadel/v2/project_role/const.go index a459a2fd..0d95e2ee 100644 --- a/zitadel/v2/project_role/const.go +++ b/zitadel/v2/project_role/const.go @@ -1,7 +1,6 @@ package project_role const ( - orgIDVar = "org_id" projectIDVar = "project_id" KeyVar = "role_key" displayNameVar = "display_name" diff --git a/zitadel/v2/project_role/datasource.go b/zitadel/v2/project_role/datasource.go index 9efd32ce..f3599c4a 100644 --- a/zitadel/v2/project_role/datasource.go +++ b/zitadel/v2/project_role/datasource.go @@ -1,6 +1,9 @@ package project_role -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" +) func GetDatasource() *schema.Resource { return &schema.Resource{ @@ -11,7 +14,7 @@ func GetDatasource() *schema.Resource { Required: true, Description: "ID of the project", }, - orgIDVar: { + helper.OrgIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the organization", @@ -33,6 +36,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/v2/project_role/funcs.go index 2f2d6de8..b0a445f4 100644 --- a/zitadel/v2/project_role/funcs.go +++ b/zitadel/v2/project_role/funcs.go @@ -21,7 +21,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -44,7 +44,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -70,7 +70,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -100,7 +100,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -127,11 +127,11 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn projectRole := resp.GetResult()[0] roleKey := projectRole.GetKey() set := map[string]interface{}{ - projectIDVar: projectID, - orgIDVar: orgID, - KeyVar: roleKey, - displayNameVar: projectRole.GetDisplayName(), - groupVar: projectRole.GetGroup(), + projectIDVar: projectID, + helper.OrgIDVar: orgID, + KeyVar: roleKey, + displayNameVar: projectRole.GetDisplayName(), + groupVar: projectRole.GetGroup(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go index 6f0cba5d..afffd5cc 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/v2/project_role/resource.go @@ -2,24 +2,20 @@ package project_role import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the project roles, which can be given as authorizations to users.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", ForceNew: true, }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, KeyVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/trigger_actions/const.go b/zitadel/v2/trigger_actions/const.go index 3c8f1a16..4023b0d5 100644 --- a/zitadel/v2/trigger_actions/const.go +++ b/zitadel/v2/trigger_actions/const.go @@ -1,7 +1,6 @@ package trigger_actions const ( - orgIDVar = "org_id" FlowTypeVar = "flow_type" TriggerTypeVar = "trigger_type" actionsVar = "action_ids" diff --git a/zitadel/v2/trigger_actions/datasource.go b/zitadel/v2/trigger_actions/datasource.go index 4dac245f..8d8a8b05 100644 --- a/zitadel/v2/trigger_actions/datasource.go +++ b/zitadel/v2/trigger_actions/datasource.go @@ -2,18 +2,14 @@ package trigger_actions import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Resource representing triggers, when actions get started", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, FlowTypeVar: { Type: schema.TypeString, Required: true, @@ -34,6 +30,5 @@ func GetDatasource() *schema.Resource { }, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, } } diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/v2/trigger_actions/funcs.go index 7e00360f..b8bfbc0d 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/v2/trigger_actions/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -46,7 +46,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -71,7 +71,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if !ok { return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) if err != nil { return diag.FromErr(err) @@ -99,7 +99,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if !ok { return diag.Errorf("failed to get client") } - orgID := d.Get(orgIDVar).(string) + orgID := d.Get(helper.OrgIDVar).(string) flowType := d.Get(FlowTypeVar).(string) triggerType := d.Get(TriggerTypeVar).(string) client, err := helper.GetManagementClient(clientinfo, orgID) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 125f59f3..9513e9a4 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -12,12 +12,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing triggers, when actions get started", Schema: map[string]*schema.Schema{ - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - ForceNew: true, - }, + helper.OrgIDVar: helper.OrgIDResourceField, FlowTypeVar: { Type: schema.TypeString, Required: true, diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go index 9f4f8487..7f4a7a0e 100644 --- a/zitadel/v2/user_grant/const.go +++ b/zitadel/v2/user_grant/const.go @@ -5,5 +5,4 @@ const ( projectGrantIDVar = "project_grant_id" userIDVar = "user_id" RoleKeysVar = "role_keys" - orgIDVar = "org_id" ) diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/v2/user_grant/funcs.go index 54d46e51..a4ea2fc8 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/v2/user_grant/funcs.go @@ -20,7 +20,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -43,7 +43,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -93,7 +93,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(orgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } @@ -133,9 +133,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(grants.GetResult()) == 1 { grant := grants.GetResult()[0] set := map[string]interface{}{ - userIDVar: grant.GetUserId(), - RoleKeysVar: grant.GetRoleKeys(), - orgIDVar: grant.GetDetails().GetResourceOwner(), + userIDVar: grant.GetUserId(), + RoleKeysVar: grant.GetRoleKeys(), + helper.OrgIDVar: grant.GetDetails().GetResourceOwner(), } if grant.GetProjectId() != "" { set[projectIDVar] = grant.GetProjectId() diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go index ca68b0d2..71daf324 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/v2/user_grant/resource.go @@ -2,12 +2,14 @@ package user_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the authorization given to a user directly, including the given roles.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDResourceField, projectIDVar: { Type: schema.TypeString, Optional: true, @@ -34,12 +36,6 @@ func GetResource() *schema.Resource { Optional: true, Description: "List of roles granted", }, - orgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization which owns the resource", - ForceNew: true, - }, }, DeleteContext: delete, CreateContext: create, diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index d4ac556b..4e344880 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *verifyEmailMessageTextResource) Delete(ctx context.Context, req resourc func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index 9d55766f..ed9f052d 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -15,11 +17,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( - orgIDVar = "org_id" LanguageVar = "language" ) @@ -208,7 +208,7 @@ func (r *verifyPhoneMessageTextResource) Delete(ctx context.Context, req resourc func setID(obj types.Object, orgID string, language string) { attrs := obj.Attributes() attrs["id"] = types.StringValue(orgID + "_" + language) - attrs[orgIDVar] = types.StringValue(orgID) + attrs[helper.OrgIDVar] = types.StringValue(orgID) attrs[LanguageVar] = types.StringValue(language) } @@ -218,12 +218,12 @@ func getID(ctx context.Context, obj types.Object) (string, string) { if len(parts) == 2 { return parts[0], parts[1] } - return helper.GetStringFromAttr(ctx, obj.Attributes(), orgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) + return helper.GetStringFromAttr(ctx, obj.Attributes(), helper.OrgIDVar), helper.GetStringFromAttr(ctx, obj.Attributes(), LanguageVar) } func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(plan.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(plan.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } @@ -238,7 +238,7 @@ func getPlanAttrs(ctx context.Context, plan tfsdk.Plan, diag diag.Diagnostics) ( func getStateAttrs(ctx context.Context, state tfsdk.State, diag diag.Diagnostics) (string, string) { var orgID string - diag.Append(state.GetAttribute(ctx, path.Root(orgIDVar), &orgID)...) + diag.Append(state.GetAttribute(ctx, path.Root(helper.OrgIDVar), &orgID)...) if diag.HasError() { return "", "" } From fc0582bb96119b34971c4b304781c5e111e63609 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 21 Aug 2023 22:52:34 +0200 Subject: [PATCH 239/260] fix: importing --- .../provider/resources/application_api.tf | 2 +- zitadel/v2/app_key/const.go | 1 + zitadel/v2/app_key/resource.go | 2 +- zitadel/v2/application_api/const.go | 6 +-- zitadel/v2/application_api/datasource.go | 8 +--- zitadel/v2/application_api/funcs.go | 12 +++--- zitadel/v2/application_api/resource.go | 13 ++++-- zitadel/v2/application_api/resource_test.go | 13 ++++-- zitadel/v2/application_oidc/const.go | 6 +-- zitadel/v2/application_oidc/datasource.go | 8 +--- zitadel/v2/application_oidc/funcs.go | 12 +++--- zitadel/v2/application_oidc/resource.go | 13 ++++-- zitadel/v2/application_oidc/resource_test.go | 13 ++++-- .../resource_test.go | 4 +- zitadel/v2/default_domain_policy/resource.go | 3 +- .../v2/default_domain_policy/resource_test.go | 7 ++-- .../resource_test.go | 4 +- zitadel/v2/default_label_policy/resource.go | 3 +- .../v2/default_label_policy/resource_test.go | 7 ++-- zitadel/v2/default_lockout_policy/resource.go | 3 +- .../default_lockout_policy/resource_test.go | 3 +- zitadel/v2/default_login_policy/resource.go | 3 +- .../v2/default_login_policy/resource_test.go | 3 +- .../v2/default_login_texts/resource_test.go | 4 +- .../default_notification_policy/resource.go | 3 +- .../resource_test.go | 3 +- .../v2/default_oidc_settings/resource_test.go | 3 +- .../resource_test.go | 4 +- .../resource.go | 3 +- .../resource_test.go | 3 +- .../resource_test.go | 4 +- .../resource_test.go | 4 +- zitadel/v2/default_privacy_policy/resource.go | 3 +- .../default_privacy_policy/resource_test.go | 3 +- .../resource_test.go | 4 +- .../resource_test.go | 4 +- zitadel/v2/domain/resource.go | 5 ++- .../resource_test.go | 4 +- zitadel/v2/domain_policy/resource.go | 2 +- zitadel/v2/domain_policy/resource_test.go | 3 +- zitadel/v2/helper/import.go | 41 ++++++++++++++----- zitadel/v2/helper/test_utils/checks.go | 4 -- zitadel/v2/helper/test_utils/import_id.go | 7 +++- zitadel/v2/human_user/resource.go | 2 +- zitadel/v2/human_user/resource_test.go | 3 +- zitadel/v2/idp_azure_ad/datasource.go | 3 +- zitadel/v2/idp_azure_ad/resource.go | 3 +- zitadel/v2/idp_github/datasource.go | 4 +- zitadel/v2/idp_github/resource.go | 5 ++- zitadel/v2/idp_github_es/datasource.go | 4 +- zitadel/v2/idp_github_es/resource.go | 4 +- zitadel/v2/idp_gitlab/datasource.go | 4 +- zitadel/v2/idp_gitlab/resource.go | 4 +- .../v2/idp_gitlab_self_hosted/datasource.go | 4 +- zitadel/v2/idp_gitlab_self_hosted/resource.go | 4 +- zitadel/v2/idp_google/datasource.go | 4 +- zitadel/v2/idp_google/resource.go | 3 +- .../idp_utils/idp_test_utils/lifecyletest.go | 3 +- zitadel/v2/init_message_text/resource_test.go | 4 +- zitadel/v2/instance_member/resource.go | 3 +- zitadel/v2/instance_member/resource_test.go | 3 +- zitadel/v2/label_policy/resource.go | 2 +- zitadel/v2/label_policy/resource_test.go | 3 +- zitadel/v2/lockout_policy/resource.go | 2 +- zitadel/v2/lockout_policy/resource_test.go | 3 +- zitadel/v2/login_policy/resource.go | 2 +- zitadel/v2/login_policy/resource_test.go | 3 +- zitadel/v2/machine_key/const.go | 1 + zitadel/v2/machine_key/resource.go | 6 ++- zitadel/v2/machine_key/resource_test.go | 3 +- zitadel/v2/machine_user/resource.go | 2 +- zitadel/v2/machine_user/resource_test.go | 3 +- zitadel/v2/notification_policy/resource.go | 2 +- .../v2/notification_policy/resource_test.go | 3 +- zitadel/v2/org/resource.go | 3 +- zitadel/v2/org/resource_test.go | 3 +- zitadel/v2/org_idp_azure_ad/datasource.go | 3 +- zitadel/v2/org_idp_azure_ad/resource.go | 4 +- zitadel/v2/org_idp_github/datasource.go | 5 +-- zitadel/v2/org_idp_github/resource.go | 4 +- zitadel/v2/org_idp_github_es/datasource.go | 5 +-- zitadel/v2/org_idp_github_es/resource.go | 4 +- zitadel/v2/org_idp_gitlab/datasource.go | 5 +-- zitadel/v2/org_idp_gitlab/resource.go | 4 +- .../org_idp_gitlab_self_hosted/datasource.go | 5 +-- .../v2/org_idp_gitlab_self_hosted/resource.go | 4 +- zitadel/v2/org_idp_google/datasource.go | 5 +-- zitadel/v2/org_idp_google/resource.go | 4 +- zitadel/v2/org_idp_jwt/resource_test.go | 3 +- zitadel/v2/org_idp_ldap/datasource.go | 5 +-- zitadel/v2/org_idp_oidc/resource_test.go | 3 +- .../org_idp_test_utils/lifecyletest.go | 2 +- zitadel/v2/org_member/resource.go | 2 +- zitadel/v2/org_member/resource_test.go | 3 +- .../resource_test.go | 2 +- .../v2/password_complexity_policy/resource.go | 2 +- .../resource_test.go | 3 +- .../resource_test.go | 2 +- .../resource_test.go | 4 +- zitadel/v2/pat/const.go | 1 + zitadel/v2/pat/resource.go | 6 ++- zitadel/v2/pat/resource_test.go | 3 +- zitadel/v2/privacy_policy/resource.go | 2 +- zitadel/v2/privacy_policy/resource_test.go | 3 +- zitadel/v2/project/resource.go | 2 +- zitadel/v2/project/resource_test.go | 3 +- zitadel/v2/project_grant/resource.go | 5 ++- zitadel/v2/project_grant/resource_test.go | 3 +- zitadel/v2/project_grant_member/resource.go | 7 +++- .../v2/project_grant_member/resource_test.go | 3 +- zitadel/v2/project_member/resource.go | 6 ++- zitadel/v2/project_member/resource_test.go | 3 +- zitadel/v2/project_role/resource.go | 6 ++- zitadel/v2/project_role/resource_test.go | 3 +- zitadel/v2/sms_provider_twilio/const.go | 1 + zitadel/v2/sms_provider_twilio/resource.go | 3 +- .../v2/sms_provider_twilio/resource_test.go | 3 +- zitadel/v2/smtp_config/resource.go | 3 +- zitadel/v2/smtp_config/resource_test.go | 3 +- zitadel/v2/trigger_actions/resource.go | 6 ++- zitadel/v2/trigger_actions/resource_test.go | 2 +- zitadel/v2/user_grant/const.go | 1 + zitadel/v2/user_grant/resource.go | 2 +- zitadel/v2/user_grant/resource_test.go | 3 +- .../resource_test.go | 4 +- .../resource_test.go | 4 +- 126 files changed, 326 insertions(+), 213 deletions(-) diff --git a/examples/provider/resources/application_api.tf b/examples/provider/resources/application_api.tf index 33b66a57..37a837c9 100644 --- a/examples/provider/resources/application_api.tf +++ b/examples/provider/resources/application_api.tf @@ -2,5 +2,5 @@ resource "zitadel_application_api" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id name = "applicationapi" - auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" + auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" } diff --git a/zitadel/v2/app_key/const.go b/zitadel/v2/app_key/const.go index 0d4246fa..7d39b524 100644 --- a/zitadel/v2/app_key/const.go +++ b/zitadel/v2/app_key/const.go @@ -1,6 +1,7 @@ package app_key const ( + keyIDVar = "key_id" ProjectIDVar = "project_id" AppIDVar = "app_id" keyTypeVar = "key_type" diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/app_key/resource.go index 3301922b..12ad31e0 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/app_key/resource.go @@ -52,7 +52,7 @@ func GetResource() *schema.Resource { CreateContext: create, ReadContext: read, Importer: helper.ImportWithIDAndOptionalOrg( - "id", + keyIDVar, helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), helper.NewImportAttribute(AppIDVar, helper.ConvertID, false), helper.NewImportAttribute(KeyDetailsVar, helper.ConvertJSON, true), diff --git a/zitadel/v2/application_api/const.go b/zitadel/v2/application_api/const.go index 737d100d..c1c211a4 100644 --- a/zitadel/v2/application_api/const.go +++ b/zitadel/v2/application_api/const.go @@ -2,9 +2,9 @@ package application_api const ( AppIDVar = "app_id" - projectIDVar = "project_id" + ProjectIDVar = "project_id" NameVar = "name" authMethodTypeVar = "auth_method_type" - clientID = "client_id" - clientSecret = "client_secret" + ClientIDVar = "client_id" + ClientSecretVar = "client_secret" ) diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/v2/application_api/datasource.go index a8ed45a3..d289a713 100644 --- a/zitadel/v2/application_api/datasource.go +++ b/zitadel/v2/application_api/datasource.go @@ -14,12 +14,8 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - helper.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - }, - projectIDVar: { + helper.OrgIDVar: helper.OrgIDDatasourceField, + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/v2/application_api/funcs.go index 07b037bd..63b9e3f5 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/v2/application_api/funcs.go @@ -26,7 +26,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveApp(ctx, &management.RemoveAppRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), AppId: d.Id(), }) if err != nil { @@ -48,7 +48,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) if d.HasChange(NameVar) { _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ ProjectId: projectID, @@ -87,14 +87,14 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.AddAPIApp(ctx, &management.AddAPIAppRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), Name: d.Get(NameVar).(string), AuthMethodType: app.APIAuthMethodType(app.APIAuthMethodType_value[(d.Get(authMethodTypeVar).(string))]), }) set := map[string]interface{}{ - clientID: resp.GetClientId(), - clientSecret: resp.GetClientSecret(), + ClientIDVar: resp.GetClientId(), + ClientSecretVar: resp.GetClientSecret(), } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -121,7 +121,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, AppIDVar)}) + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(ProjectIDVar).(string), AppId: helper.GetID(d, AppIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil diff --git a/zitadel/v2/application_api/resource.go b/zitadel/v2/application_api/resource.go index 51fc1eca..aa70a290 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/v2/application_api/resource.go @@ -14,7 +14,7 @@ func GetResource() *schema.Resource { Description: "Resource representing an API application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", @@ -34,13 +34,13 @@ func GetResource() *schema.Resource { }, Default: app.APIAuthMethodType_name[0], }, - clientID: { + ClientIDVar: { Type: schema.TypeString, Computed: true, Description: "generated ID for this config", Sensitive: true, }, - clientSecret: { + ClientSecretVar: { Type: schema.TypeString, Computed: true, Description: "generated secret for this config", @@ -51,6 +51,11 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + AppIDVar, + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ClientIDVar, helper.ConvertNonEmpty, true), + helper.NewImportAttribute(ClientSecretVar, helper.ConvertNonEmpty, true), + ), } } diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/v2/application_api/resource_test.go index cf5059f0..f5183113 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/v2/application_api/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) @@ -24,12 +25,18 @@ func TestAccAppAPI(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedproperty", - "", "", + "", "", "", false, checkRemoteProperty(frame, projectID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_api.ProjectIDVar), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_api.ClientIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_api.ClientSecretVar), + ), ) } diff --git a/zitadel/v2/application_oidc/const.go b/zitadel/v2/application_oidc/const.go index bd2fd899..f06e41b0 100644 --- a/zitadel/v2/application_oidc/const.go +++ b/zitadel/v2/application_oidc/const.go @@ -2,7 +2,7 @@ package application_oidc const ( appIDVar = "app_id" - projectIDVar = "project_id" + ProjectIDVar = "project_id" NameVar = "name" redirectURIsVar = "redirect_uris" responseTypesVar = "response_types" @@ -18,6 +18,6 @@ const ( idTokenUserinfoAssertionVar = "id_token_userinfo_assertion" clockSkewVar = "clock_skew" additionalOriginsVar = "additional_origins" - clientID = "client_id" - clientSecret = "client_secret" + ClientIDVar = "client_id" + ClientSecretVar = "client_secret" ) diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/v2/application_oidc/datasource.go index 414ab118..dc4a94eb 100644 --- a/zitadel/v2/application_oidc/datasource.go +++ b/zitadel/v2/application_oidc/datasource.go @@ -14,12 +14,8 @@ func GetDatasource() *schema.Resource { Required: true, Description: "The ID of this resource.", }, - helper.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "orgID of the application", - }, - projectIDVar: { + helper.OrgIDVar: helper.OrgIDDatasourceField, + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/v2/application_oidc/funcs.go index a421effb..d3ed6972 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/v2/application_oidc/funcs.go @@ -28,7 +28,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveApp(ctx, &management.RemoveAppRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), AppId: d.Id(), }) if err != nil { @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) if d.HasChange(NameVar) { _, err = client.UpdateApp(ctx, &management.UpdateAppRequest{ @@ -143,7 +143,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.AddOIDCApp(ctx, &management.AddOIDCAppRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), Name: d.Get(NameVar).(string), RedirectUris: interfaceToStringSlice(d.Get(redirectURIsVar)), ResponseTypes: respTypes, @@ -162,8 +162,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia }) set := map[string]interface{}{ - clientID: resp.GetClientId(), - clientSecret: resp.GetClientSecret(), + ClientIDVar: resp.GetClientId(), + ClientSecretVar: resp.GetClientSecret(), } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -191,7 +191,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(projectIDVar).(string), AppId: helper.GetID(d, appIDVar)}) + resp, err := client.GetAppByID(ctx, &management.GetAppByIDRequest{ProjectId: d.Get(ProjectIDVar).(string), AppId: helper.GetID(d, appIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/v2/application_oidc/resource.go index d4e0d3a6..e48047c6 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/v2/application_oidc/resource.go @@ -14,7 +14,7 @@ func GetResource() *schema.Resource { Description: "Resource representing an OIDC application belonging to a project, with all configuration possibilities.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", @@ -133,13 +133,13 @@ func GetResource() *schema.Resource { Optional: true, Description: "Additional origins", }, - clientID: { + ClientIDVar: { Type: schema.TypeString, Computed: true, Description: "generated ID for this config", Sensitive: true, }, - clientSecret: { + ClientSecretVar: { Type: schema.TypeString, Computed: true, Description: "generated secret for this config", @@ -150,6 +150,11 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + appIDVar, + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ClientIDVar, helper.ConvertNonEmpty, true), + helper.NewImportAttribute(ClientSecretVar, helper.ConvertNonEmpty, true), + ), } } diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/v2/application_oidc/resource_test.go index e8952a2b..1440f895 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/v2/application_oidc/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) @@ -24,12 +25,18 @@ func TestAccAppOIDC(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedproperty", - "", "", + "", "", "", false, checkRemoteProperty(frame, projectID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_oidc.ProjectIDVar), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_oidc.ClientIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_oidc.ClientSecretVar), + ), ) } diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/v2/default_domain_claimed_message_text/resource_test.go index f69363dc..57caa00c 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/default_domain_claimed_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultDomainClaimedMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Domain has been claimed"), - nil, nil, "", "", + nil, // Import not supported ) } diff --git a/zitadel/v2/default_domain_policy/resource.go b/zitadel/v2/default_domain_policy/resource.go index 63fc5cf8..7b3e84dc 100644 --- a/zitadel/v2/default_domain_policy/resource.go +++ b/zitadel/v2/default_domain_policy/resource.go @@ -2,6 +2,7 @@ package default_domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -28,6 +29,6 @@ func GetResource() *schema.Resource { CreateContext: update, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/v2/default_domain_policy/resource_test.go index 3fa577b5..386b3685 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/v2/default_domain_policy/resource_test.go @@ -11,6 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -27,12 +28,12 @@ func TestAccDefaultDomainPolicy(t *testing.T) { return strings.Replace(resourceExample, strconv.FormatBool(exampleProperty), strconv.FormatBool(property), 1) }, exampleProperty, !exampleProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/v2/default_init_message_text/resource_test.go index 4caf3d2c..10b198ba 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/v2/default_init_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultInitMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, language), regexp.MustCompile(fmt.Sprintf(`^%s$`, language)), // When deleted, the default should be returned checkRemoteProperty(frame, language)("ZITADEL - Initialize User"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/v2/default_label_policy/resource.go index 83544003..94a28c5c 100644 --- a/zitadel/v2/default_label_policy/resource.go +++ b/zitadel/v2/default_label_policy/resource.go @@ -2,6 +2,7 @@ package default_label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -143,6 +144,6 @@ func GetResource() *schema.Resource { CreateContext: update, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 393500c3..4bcb1323 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -14,6 +14,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -35,12 +36,12 @@ func TestAccDefaultLabelPolicy(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "#5469d3", - "", "", + "", "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/v2/default_lockout_policy/resource.go index 3f5fd210..a840b77b 100644 --- a/zitadel/v2/default_lockout_policy/resource.go +++ b/zitadel/v2/default_lockout_policy/resource.go @@ -2,6 +2,7 @@ package default_lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -18,6 +19,6 @@ func GetResource() *schema.Resource { CreateContext: update, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index abb3e595..fbea972f 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -29,7 +30,7 @@ func TestAccDefaultLockoutPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index 08cc45aa..e1ff2b2a 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -2,6 +2,7 @@ package default_login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -117,6 +118,6 @@ func GetResource() *schema.Resource { UpdateContext: update, DeleteContext: delete, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index fe3e50b8..855b7ab2 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" @@ -29,7 +30,7 @@ func TestAccDefaultLoginPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/v2/default_login_texts/resource_test.go index 3dc8f58d..f9ca5647 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/v2/default_login_texts/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultLoginTexts(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtext", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)(""), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_notification_policy/resource.go b/zitadel/v2/default_notification_policy/resource.go index a9c7dd5b..71d71d3a 100644 --- a/zitadel/v2/default_notification_policy/resource.go +++ b/zitadel/v2/default_notification_policy/resource.go @@ -2,6 +2,7 @@ package default_notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -18,6 +19,6 @@ func GetResource() *schema.Resource { CreateContext: update, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 38c0c024..5612c156 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -26,7 +27,7 @@ func TestAccDefaultNotificationPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 736f9cca..4702b91f 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -25,7 +26,7 @@ func TestAccDefaultOIDCSettings(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/v2/default_password_change_message_text/resource_test.go index 872eb32b..8d149e49 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/v2/default_password_change_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultPasswordChangeMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Password of user has changed"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_password_complexity_policy/resource.go b/zitadel/v2/default_password_complexity_policy/resource.go index 55ade57f..19045018 100644 --- a/zitadel/v2/default_password_complexity_policy/resource.go +++ b/zitadel/v2/default_password_complexity_policy/resource.go @@ -2,6 +2,7 @@ package default_password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -38,6 +39,6 @@ func GetResource() *schema.Resource { ReadContext: read, CreateContext: update, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 60606d94..2219e1a3 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -29,7 +30,7 @@ func TestAccDefaultPasswordComplexityPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/v2/default_password_reset_message_text/resource_test.go index a446f661..cfe61bb6 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/v2/default_password_reset_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultPassswordResetMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Reset password"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go index 493f53b9..fb54b4e2 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/default_passwordless_registration_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultPasswordlessRegistrationMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Add Passwordless Login"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/v2/default_privacy_policy/resource.go index 6b927158..2fbb0760 100644 --- a/zitadel/v2/default_privacy_policy/resource.go +++ b/zitadel/v2/default_privacy_policy/resource.go @@ -2,6 +2,7 @@ package default_privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -33,6 +34,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: read, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index 7d87b564..e0e6f9ef 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -25,7 +26,7 @@ func TestAccDefaultPrivacyPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", "", ) diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/v2/default_verify_email_message_text/resource_test.go index 109b6dc4..b8ef00ec 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/v2/default_verify_email_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultVerifyEmailMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Verify email"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/v2/default_verify_phone_message_text/resource_test.go index 16f1e6ad..c04a2879 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/v2/default_verify_phone_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDefaultVerifyPhoneMessageText(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Verify phone"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index cfe4501f..fc56c82c 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -37,6 +37,9 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithAttributes( + helper.NewImportAttribute(NameVar, helper.ConvertNonEmpty, false), + helper.ImportOptionalOrgAttribute, + ), } } diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/v2/domain_claimed_message_text/resource_test.go index e3b4962b..d120648e 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/v2/domain_claimed_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccDomainClaimedMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("Zitadel - Domain has been claimed"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/v2/domain_policy/resource.go index 1366a318..84934fda 100644 --- a/zitadel/v2/domain_policy/resource.go +++ b/zitadel/v2/domain_policy/resource.go @@ -30,6 +30,6 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index b8e107e4..846fcb1a 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -11,6 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -31,7 +32,7 @@ func TestAccDomainPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*otherFrame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*otherFrame)(false), nil, nil, "", "", ) diff --git a/zitadel/v2/helper/import.go b/zitadel/v2/helper/import.go index b5f241d4..6d6863c1 100644 --- a/zitadel/v2/helper/import.go +++ b/zitadel/v2/helper/import.go @@ -22,28 +22,41 @@ func NewImportAttribute(key string, value ConvertStringFunc, optional bool) impo return importAttribute{key: key, value: value, optional: optional} } -func ImportWithID(idVar string, attrs ...importAttribute) *schema.ResourceImporter { - return ImportWithAttributes(append([]importAttribute{NewImportAttribute(idVar, ConvertID, false)}, attrs...)...) +// ImportWithID is a convenience function that calls ImportWithAttributes. +// It returns a ResourceImporter that expects a ZITADEL ID number at the first import string position along with other given attributes. +// idVar is only relevant for the error message, the resources SetID function is called with first argument ID +func ImportWithID(idVar string, attributes ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{NewImportAttribute(idVar, ConvertID, false)}, attributes...)...) } -func ImportWithOptionalOrg(attrs ...importAttribute) *schema.ResourceImporter { - return ImportWithAttributes(append([]importAttribute{ImportOptionalOrgAttribute}, attrs...)...) +// ImportWithOptionalOrg is a convenience function that calls ImportWithAttributes. +// It returns a ResourceImporter that accepts an optional organization id along with other given attributes +func ImportWithOptionalOrg(attributes ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{ImportOptionalOrgAttribute}, attributes...)...) } -func ImportWithIDAndOptionalOrg(idVar string, attrs ...importAttribute) *schema.ResourceImporter { - return ImportWithID(idVar, append(attrs, ImportOptionalOrgAttribute)...) +// ImportWithIDAndOptionalOrg is a convenience function that calls ImportWithID +// and passes an optional attribute for the org ID along with the other given attributes. +func ImportWithIDAndOptionalOrg(idVar string, attributes ...importAttribute) *schema.ResourceImporter { + return ImportWithID(idVar, append(attributes, ImportOptionalOrgAttribute)...) } +// ImportWithIDAndOptionalSecret is a convenience function that calls ImportWithID +// and passes an optional attribute for the secret var at secretKey. func ImportWithIDAndOptionalSecret(idVar, secretKey string) *schema.ResourceImporter { return ImportWithID(idVar, importAttribute{key: secretKey, value: ConvertNonEmpty, optional: true}) } -func ImportWithIDAndOptionalOrgAndSecretV5(idVar, secretKey string) *schema.ResourceImporter { +// ImportWithIDAndOptionalOrgAndSecret is a convenience function that calls ImportWithIDAndOptionalOrg +// and passes an optional attribute for the secret var at secretKey. +func ImportWithIDAndOptionalOrgAndSecret(idVar, secretKey string) *schema.ResourceImporter { return ImportWithIDAndOptionalOrg(idVar, importAttribute{key: secretKey, value: ConvertNonEmpty, optional: true}) } -func ImportWithEmptyID(attrs ...importAttribute) *schema.ResourceImporter { - return ImportWithAttributes(append([]importAttribute{emptyIDAttribute}, attrs...)...) +// ImportWithEmptyID returns a ResourceImporter that does not use the first import string position value +// for the states SetID call. It uses a dummy value, instead. +func ImportWithEmptyID(attributes ...importAttribute) *schema.ResourceImporter { + return ImportWithAttributes(append([]importAttribute{emptyIDAttribute}, attributes...)...) } type ConvertStringFunc func(string) (interface{}, error) @@ -88,6 +101,8 @@ type importState interface { Set(string, interface{}) error } +// importWithAttributes imports a resources state that is needed to query the remote resource +// as well as state that is not readable from the ZITADEL API func importWithAttributes(state importState, attrs ...importAttribute) (err error) { id := state.Id() var ( @@ -128,10 +143,10 @@ func importWithAttributes(state importState, attrs ...importAttribute) (err erro return fmt.Errorf(`expected the number of semicolon separated parts to be between %d and %d, but got %d parts: "%s"`, externalMinParts, externalMaxParts, len(parts), strings.Join(parts, `", "`)) } for i, part := range parts { - part = strings.ReplaceAll(part, SemicolonPlaceholder, `:`) + part = strings.ReplaceAll(part, SemicolonPlaceholder, ":") attr := attrs[i] // if the id is optional and not given, we use the emptyIDAttribute - if attr.optional && part == "" { + if i == 0 && attr.optional && part == "" { attr = emptyIDAttribute } val, err := attr.value(part) @@ -141,6 +156,9 @@ func importWithAttributes(state importState, attrs ...importAttribute) (err erro if i == 0 { state.SetId(val.(string)) continue + } + if attr.optional && val == nil { + } if err := state.Set(attr.key, val); err != nil { return fmt.Errorf("failed to set %s=%v: %w", attr.key, val, err) @@ -185,6 +203,7 @@ func ConvertNonEmpty(importValue string) (interface{}, error) { return importValue, nil } +// ImportIDValidationError wraps err with a help message about the expected format if it is not nil func ImportIDValidationError(givenID string, requiredKeys, optionalKeys []string, err error) error { if err == nil { return nil diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/v2/helper/test_utils/checks.go index 719ff898..4838f01d 100644 --- a/zitadel/v2/helper/test_utils/checks.go +++ b/zitadel/v2/helper/test_utils/checks.go @@ -12,10 +12,6 @@ import ( "google.golang.org/grpc/status" ) -// ZITADEL IDs have thirteen digits -// TODO: This is not true. The IDs have 18 digits. -var ZITADEL_GENERATED_ID_REGEX = regexp.MustCompile(`\d{13}`) - func CheckStateHasIDSet(frame BaseTestFrame, idPattern *regexp.Regexp) resource.TestCheckFunc { return func(state *terraform.State) error { return resource.TestMatchResourceAttr(frame.TerraformName, "id", idPattern)(state) diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/v2/helper/test_utils/import_id.go index 60ed40f9..4329f382 100644 --- a/zitadel/v2/helper/test_utils/import_id.go +++ b/zitadel/v2/helper/test_utils/import_id.go @@ -36,12 +36,17 @@ func ImportStateAttribute(frame BaseTestFrame, attr string) resource.ImportState if !ok { return "", fmt.Errorf("attribute %s not found in attributes %+v", attr, primary.Attributes) } - return fmt.Sprintf(`"%s"`, strings.ReplaceAll(val, ":", helper.SemicolonPlaceholder)), nil + if val != "" { + val = fmt.Sprintf(`"%s"`, strings.ReplaceAll(val, ":", helper.SemicolonPlaceholder)) + } + return val, nil } } func ImportNothing(_ *terraform.State) (string, error) { return "", nil } +// ChainImportStateIdFuncs returns a function that composes an ID that has exactly the same +// length of semicolon separated parts as the passed number of funcs func ChainImportStateIdFuncs(funcs ...resource.ImportStateIdFunc) resource.ImportStateIdFunc { return func(state *terraform.State) (string, error) { parts := make([]string, len(funcs)) diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index bc1a07d7..9faaad8d 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -141,6 +141,6 @@ func GetResource() *schema.Resource { return diff.SetNew(preferredLanguageVar, defaultPreferredLanguage) }), ), - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(UserIDVar, initialPasswordVar), } } diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index fc0ccedb..4fd9bb58 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" ) @@ -29,7 +30,7 @@ func TestAccHumanUser(t *testing.T) { "", "", false, checkRemoteProperty(frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go index 1f37f050..b0aa9ac3 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -3,6 +3,7 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -24,6 +25,6 @@ func GetDatasource() *schema.Resource { EmailVerifiedVar: EmailVerifiedDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/v2/idp_azure_ad/resource.go index 9b310a85..5f4475fe 100644 --- a/zitadel/v2/idp_azure_ad/resource.go +++ b/zitadel/v2/idp_azure_ad/resource.go @@ -2,6 +2,7 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -26,6 +27,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go index ddf3cb0e..2ec4097d 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/v2/idp_github/datasource.go @@ -21,6 +21,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index 94535392..afdca922 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -2,6 +2,7 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -23,6 +24,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go index d133e853..ee51657b 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/v2/idp_github_es/datasource.go @@ -24,6 +24,6 @@ func GetDatasource() *schema.Resource { UserEndpointVar: UserEndpointDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/v2/idp_github_es/resource.go index c2bf6e76..69b3b6ba 100644 --- a/zitadel/v2/idp_github_es/resource.go +++ b/zitadel/v2/idp_github_es/resource.go @@ -26,6 +26,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go index 3df2dda6..37af57fb 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -21,6 +21,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/v2/idp_gitlab/resource.go index c3e2b0bc..b5eecc05 100644 --- a/zitadel/v2/idp_gitlab/resource.go +++ b/zitadel/v2/idp_gitlab/resource.go @@ -23,6 +23,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go index d0779838..3cdc1153 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -22,6 +22,6 @@ func GetDatasource() *schema.Resource { IssuerVar: IssuerDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/v2/idp_gitlab_self_hosted/resource.go index aa313368..fe0790aa 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource.go @@ -24,6 +24,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go index 0cc78258..d074e048 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/v2/idp_google/datasource.go @@ -21,6 +21,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/v2/idp_google/resource.go index 048a88bf..dc64494e 100644 --- a/zitadel/v2/idp_google/resource.go +++ b/zitadel/v2/idp_google/resource.go @@ -2,6 +2,7 @@ package idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -23,6 +24,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(idp_utils.ClientSecretVar)}, + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index 0293b4d1..eac33695 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -29,7 +30,7 @@ func RunInstanceIDPLifecyleTest(t *testing.T, resourceName, secretAttribute stri exampleSecret, "an_updated_secret", false, CheckCreationAllowed(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, CheckDestroy(*frame), func(state *terraform.State) error { // Check the secret is imported correctly diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/v2/init_message_text/resource_test.go index 8d523789..f1ab0d14 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/v2/init_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccInitMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("Zitadel - Initialize User"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/v2/instance_member/resource.go index aa19b4dc..3d083563 100644 --- a/zitadel/v2/instance_member/resource.go +++ b/zitadel/v2/instance_member/resource.go @@ -2,6 +2,7 @@ package instance_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -27,6 +28,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithID(userIDVar), } } diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index 5dea5231..a92e27b9 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" @@ -28,7 +29,7 @@ func TestAccInstanceMember(t *testing.T) { "", "", true, checkRemoteProperty(*frame, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go index 50199608..99eb060b 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/v2/label_policy/resource.go @@ -145,6 +145,6 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index 4c0b762a..05809165 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -37,7 +38,7 @@ func TestAccLabelPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(exampleProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/lockout_policy/resource.go b/zitadel/v2/lockout_policy/resource.go index cac21c73..bf113092 100644 --- a/zitadel/v2/lockout_policy/resource.go +++ b/zitadel/v2/lockout_policy/resource.go @@ -20,6 +20,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index 07c3589e..37fc94c0 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -28,7 +29,7 @@ func TestAccLockoutPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(0), nil, nil, "", "", ) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index c5d1067a..fca3886a 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -119,6 +119,6 @@ func GetResource() *schema.Resource { UpdateContext: update, DeleteContext: delete, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index 0fab648c..df56530c 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" @@ -29,7 +30,7 @@ func TestAccLoginPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(""), nil, nil, "", "", ) diff --git a/zitadel/v2/machine_key/const.go b/zitadel/v2/machine_key/const.go index eb47a319..2909735b 100644 --- a/zitadel/v2/machine_key/const.go +++ b/zitadel/v2/machine_key/const.go @@ -1,6 +1,7 @@ package machine_key const ( + keyIDVar = "key_id" userIDVar = "user_id" keyTypeVar = "key_type" keyDetailsVar = "key_details" diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index 14cc03aa..1112564d 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -46,6 +46,10 @@ func GetResource() *schema.Resource { DeleteContext: delete, CreateContext: create, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + keyIDVar, + helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + helper.NewImportAttribute(keyDetailsVar, helper.ConvertJSON, true), + ), } } diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index 218e158e..a7598926 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" @@ -27,7 +28,7 @@ func TestAccMachineKey(t *testing.T) { "", "", false, checkRemoteProperty(*frame, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index 1aa5357f..a669c028 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -65,6 +65,6 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg(helper.ResourceIDVar), } } diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go index b7c7b995..27557cbc 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/v2/machine_user/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" ) @@ -28,7 +29,7 @@ func TestAccMachineUser(t *testing.T) { "", "", false, checkRemoteProperty(frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/notification_policy/resource.go b/zitadel/v2/notification_policy/resource.go index 9f2dd8ed..c66e1d7d 100644 --- a/zitadel/v2/notification_policy/resource.go +++ b/zitadel/v2/notification_policy/resource.go @@ -20,6 +20,6 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: delete, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index d8c11d93..aba0a64c 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -26,7 +27,7 @@ func TestAccNotificationPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(true), nil, nil, "", "", ) diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go index f3a385ab..dc7fd00f 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/v2/org/resource.go @@ -2,6 +2,7 @@ package org import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -28,6 +29,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: get, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithID(OrgIDVar), } } diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index 24b16c06..7c583378 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" ) @@ -24,7 +25,7 @@ func TestAccOrg(t *testing.T) { "", "", false, checkRemoteProperty(frame, idFromState(frame)), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, idFromState(frame)), updatedProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index ccd94425..bb0366c8 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -6,7 +6,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -28,6 +27,6 @@ func GetDatasource() *schema.Resource { idp_azure_ad.EmailVerifiedVar: idp_azure_ad.EmailVerifiedDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index f595f86a..52b1d6a2 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -30,6 +30,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 070e2d5e..20181fac 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -5,7 +5,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -24,6 +23,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index 054b63c6..be860170 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -26,6 +26,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index 013e9db9..b850bbf8 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -6,7 +6,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -28,6 +27,6 @@ func GetDatasource() *schema.Resource { idp_github_es.UserEndpointVar: idp_github_es.UserEndpointDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index 6975e319..76bdb9a1 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -30,6 +30,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index 3a8bc6bc..f2dd41d1 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -5,7 +5,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -24,6 +23,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index fa41d9d0..ad547f79 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -26,6 +26,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index 38c8d316..2c084aef 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -6,7 +6,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -26,6 +25,6 @@ func GetDatasource() *schema.Resource { idp_gitlab_self_hosted.IssuerVar: idp_gitlab_self_hosted.IssuerDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index 26842084..caf02f68 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -28,6 +28,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index a2ad061a..a954c610 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -5,7 +5,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -24,6 +23,6 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 1872d857..2d7f11b1 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -26,6 +26,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go index 2c07d87c..69f385fd 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" ) @@ -29,7 +30,7 @@ func TestAccOrgIDPJWT(t *testing.T) { "", "", true, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go index 55e0a379..7ecc027a 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -6,7 +6,6 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetDatasource() *schema.Resource { @@ -46,6 +45,6 @@ func GetDatasource() *schema.Resource { idp_ldap.ProfileAttributeVar: idp_ldap.ProfileAttributeDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_utils.ClientSecretVar)}, - } + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), +} } diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go index 642048c7..af6d6579 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" ) @@ -30,7 +31,7 @@ func TestAccOrgIDPJWT(t *testing.T) { "", "", true, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index d91ebd13..b66cf101 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -30,7 +30,7 @@ func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { exampleSecret, "an_updated_secret", false, CheckCreationAllowed(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, CheckDestroy(*frame), func(state *terraform.State) error { // Check the secretAttribute is imported correctly diff --git a/zitadel/v2/org_member/resource.go b/zitadel/v2/org_member/resource.go index fd869fed..dde43c72 100644 --- a/zitadel/v2/org_member/resource.go +++ b/zitadel/v2/org_member/resource.go @@ -29,6 +29,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg(userIDVar), } } diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index 9ccfd01b..20e98478 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" @@ -29,7 +30,7 @@ func TestAccOrgMember(t *testing.T) { "", "", true, checkRemoteProperty(*frame, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 2ccb48b1..3ea05c6e 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -31,7 +31,7 @@ func TestAccPasswordChangeMessageText(t *testing.T) { regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Password of user has changed"), - nil, nil, "", "", + nil, nil, "", "", "", ) } diff --git a/zitadel/v2/password_complexity_policy/resource.go b/zitadel/v2/password_complexity_policy/resource.go index de1b9077..2903252d 100644 --- a/zitadel/v2/password_complexity_policy/resource.go +++ b/zitadel/v2/password_complexity_policy/resource.go @@ -40,6 +40,6 @@ func GetResource() *schema.Resource { ReadContext: read, CreateContext: create, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index f9b78d32..5bdcdc48 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" ) @@ -29,7 +30,7 @@ func TestAccPasswordComplexityPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(exampleProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index 57d0bfde..6579e1c5 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -31,7 +31,7 @@ func TestAccPasswordResetMessageText(t *testing.T) { regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("Zitadel - Reset password"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/v2/passwordless_registration_message_text/resource_test.go index 7ddd2da4..9d9c504a 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/v2/passwordless_registration_message_text/resource_test.go @@ -25,13 +25,13 @@ func TestAccPasswordlessRegistrationMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Add Passwordless Login"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/pat/const.go b/zitadel/v2/pat/const.go index 0e63bec8..a576a3fe 100644 --- a/zitadel/v2/pat/const.go +++ b/zitadel/v2/pat/const.go @@ -1,6 +1,7 @@ package pat const ( + tokenIDVar = "token_id" userIDVar = "user_id" tokenVar = "token" ExpirationDateVar = "expiration_date" diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index ca2d6a93..0b4cfaef 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -32,6 +32,10 @@ func GetResource() *schema.Resource { DeleteContext: delete, CreateContext: create, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + tokenIDVar, + helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + helper.NewImportAttribute(tokenVar, helper.ConvertNonEmpty, true), + ), } } diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index 3be50f4e..e968b229 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" @@ -28,7 +29,7 @@ func TestAccPersonalAccessToken(t *testing.T) { "", "", false, checkRemoteProperty(*frame, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go index c42edd0f..52e2f722 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/v2/privacy_policy/resource.go @@ -35,6 +35,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: read, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithOptionalOrg(), } } diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index 4eca409e..210d3d60 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" ) @@ -25,7 +26,7 @@ func TestAccPrivacyPolicy(t *testing.T) { "", "", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(""), nil, nil, "", "", ) diff --git a/zitadel/v2/project/resource.go b/zitadel/v2/project/resource.go index 894312da..a1110f36 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/v2/project/resource.go @@ -57,6 +57,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg(ProjectIDVar), } } diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go index 5366797d..d5206bb9 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/v2/project/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" ) @@ -26,7 +27,7 @@ func TestAccProject(t *testing.T) { "", "", false, checkRemoteProperty(frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/v2/project_grant/resource.go index 82b1d587..b17a1aff 100644 --- a/zitadel/v2/project_grant/resource.go +++ b/zitadel/v2/project_grant/resource.go @@ -35,6 +35,9 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg( + "", + helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + ), } } diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 4f4ecf3e..1a6babd7 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" @@ -32,7 +33,7 @@ func TestAccProjectGrant(t *testing.T) { "", "", false, checkRemoteProperty(*frame, projectID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/v2/project_grant_member/resource.go index 7a9cbb7e..b4f1fce7 100644 --- a/zitadel/v2/project_grant_member/resource.go +++ b/zitadel/v2/project_grant_member/resource.go @@ -41,6 +41,11 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID( + helper.ImportOptionalOrgAttribute, + helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(GrantIDVar, helper.ConvertID, false), + helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + ), } } diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index d346d420..590ee29e 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -10,6 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" @@ -37,7 +38,7 @@ func TestAccProjectGrantMember(t *testing.T) { "", "", true, checkRemoteProperty(*frame, projectID, grantID, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, grantID, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/project_member/resource.go b/zitadel/v2/project_member/resource.go index 38a4fde3..54842151 100644 --- a/zitadel/v2/project_member/resource.go +++ b/zitadel/v2/project_member/resource.go @@ -35,6 +35,10 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID( + helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + helper.ImportOptionalOrgAttribute, + ), } } diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go index d16a43fa..c7e2da5a 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/v2/project_member/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" @@ -30,7 +31,7 @@ func TestAccProjectMember(t *testing.T) { "", "", true, checkRemoteProperty(*frame, projectID, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go index afffd5cc..cfd60b79 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/v2/project_role/resource.go @@ -37,6 +37,10 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID( + helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(KeyVar, helper.ConvertNonEmpty, false), + helper.ImportOptionalOrgAttribute, + ), } } diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index 7d9fdcce..e59806b5 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -9,6 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" @@ -28,7 +29,7 @@ func TestAccProjectRole(t *testing.T) { "", "", true, checkRemoteProperty(*frame, projectID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/sms_provider_twilio/const.go b/zitadel/v2/sms_provider_twilio/const.go index 2bf42fd6..faf544ed 100644 --- a/zitadel/v2/sms_provider_twilio/const.go +++ b/zitadel/v2/sms_provider_twilio/const.go @@ -1,6 +1,7 @@ package sms_provider_twilio const ( + providerIDVar = "provider_id" sidVar = "sid" TokenVar = "token" SenderNumberVar = "sender_number" diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go index 7b0bc4e5..20d70162 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -2,6 +2,7 @@ package sms_provider_twilio import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -29,6 +30,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: read, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalSecret(providerIDVar, TokenVar), } } diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index af41bf73..b53835e4 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" ) @@ -26,7 +27,7 @@ func TestAccSMSProviderTwilio(t *testing.T) { exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", sms_provider_twilio.TokenVar, ) diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index f6e2dae4..ecac8659 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -2,6 +2,7 @@ package smtp_config import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -44,6 +45,6 @@ func GetResource() *schema.Resource { DeleteContext: delete, ReadContext: read, UpdateContext: update, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID(helper.NewImportAttribute(PasswordVar, helper.ConvertNonEmpty, true)), } } diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index 681b49a2..fdabf7e2 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" ) @@ -35,7 +36,7 @@ func TestAccSMTPConfig(t *testing.T) { exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, nil, nil, "", smtp_config.PasswordVar, ) diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/v2/trigger_actions/resource.go index 9513e9a4..20107129 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/v2/trigger_actions/resource.go @@ -44,7 +44,11 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithEmptyID( + helper.NewImportAttribute(FlowTypeVar, helper.ConvertNonEmpty, false), + helper.NewImportAttribute(TriggerTypeVar, helper.ConvertNonEmpty, false), + helper.ImportOptionalOrgAttribute, + ), } } diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 20d82bf8..36fad075 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -30,7 +30,7 @@ func TestAccTriggerActions(t *testing.T) { "", "", false, checkRemoteProperty(*frame, flowType), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), exampleProperty), nil, nil, "", "", ) diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go index 7f4a7a0e..a170e567 100644 --- a/zitadel/v2/user_grant/const.go +++ b/zitadel/v2/user_grant/const.go @@ -1,6 +1,7 @@ package user_grant const ( + grantIDVar = "grant_id" projectIDVar = "project_id" projectGrantIDVar = "project_grant_id" userIDVar = "user_id" diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go index 71daf324..bb5cc8f8 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/v2/user_grant/resource.go @@ -41,6 +41,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: schema.ImportStatePassthroughContext}, + Importer: helper.ImportWithIDAndOptionalOrg(grantIDVar, helper.NewImportAttribute(userIDVar, helper.ConvertID, false)), } } diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index 63c80da4..88624ab4 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" @@ -32,7 +33,7 @@ func TestAccUserGrant(t *testing.T) { "", "", true, checkRemoteProperty(*frame, userID), - test_utils.ZITADEL_GENERATED_ID_REGEX, + helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), nil, nil, "", "", ) diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/v2/verify_email_message_text/resource_test.go index ea4ee0f6..9ad71f60 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/v2/verify_email_message_text/resource_test.go @@ -25,13 +25,13 @@ func TestAccVerifyEmailMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("Zitadel - Verify email"), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/v2/verify_phone_message_text/resource_test.go index 880d4319..1e053154 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/v2/verify_phone_message_text/resource_test.go @@ -24,13 +24,13 @@ func TestAccVerifyPhoneMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtitle", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("Zitadel - Verify phone"), - nil, nil, "", "", + nil, ) } From 00666098fbe4f834ecae1788c17af431f72ee199 Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 22 Aug 2023 11:24:16 +0200 Subject: [PATCH 240/260] fix: merge back alpha --- go.sum | 1 + 1 file changed, 1 insertion(+) diff --git a/go.sum b/go.sum index 86f85649..81fcde63 100644 --- a/go.sum +++ b/go.sum @@ -30,6 +30,7 @@ github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= From 1e88f008f7df453d9c4414fdeff6f4000146879d Mon Sep 17 00:00:00 2001 From: Stefan Benz Date: Tue, 22 Aug 2023 11:40:53 +0200 Subject: [PATCH 241/260] fix: merge back alpha --- go.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.sum b/go.sum index 81fcde63..aa84c1fe 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= From 4f2d277cc408e09ca1ff3a7fc496ac19a44368f0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 22 Aug 2023 12:45:55 +0200 Subject: [PATCH 242/260] query user grant by id --- signal-desktop-keyring.gpg | Bin 0 -> 2223 bytes zitadel/v2/user_grant/funcs.go | 84 +++++++++++---------------------- 2 files changed, 27 insertions(+), 57 deletions(-) create mode 100644 signal-desktop-keyring.gpg diff --git a/signal-desktop-keyring.gpg b/signal-desktop-keyring.gpg new file mode 100644 index 0000000000000000000000000000000000000000..b5e68a0406c738a31fff4c4de4352399168f47e8 GIT binary patch literal 2223 zcmV;g2vGN#0u2OM(o>8@%6k}|}?l=%0SOu3ZEv`h(5}P#jS~+r;ni_t? zNrY}n3T$7un?2=;`~jag0jB9PBsd%;D!g%b>g1aPJsnB_zNv@#Fe&JRHV?d@SSo$G zE|9Kz$n@BA*o^WS6BXQjFQP&vrbcKpABq|fn`as*3957C<)#ZtY!dXhm}|^BLOzmj z3D<7a)N-*mDtrKvN{26^rZjd|%{;?=k4_68$XqC4Vy5EVBg(M^TBR_A2?3-B{hbyu-z z`(BqDmG2_lBBYy=;9s2YN29S#xq(t@O@O2#%Mkibv-h|F=KDkXd&>zz&^r!XSu75R zxhTF#4VE>_vMjyO{!&EJpix;;bnH^$rUT7izb)%h{& zpqVsRbL8kTCMb1Ld2on&XX>a=?Hijoo_GjW{u2zd4OL2yaWWyDMR?!zBgV8@m3sM) z>C?dM47Un`rvtRDHObYOKTANPRJLcbY=b7b(Qete|J9O)!>SXe6G6j12p8WmDPFcp zxXIB0%=!ihx|aYE0RRECF;8%1ZXj1^X>)L8av)QAb97~Gb09o(b#QQRa&$mSkmbwQ$LenA^WjruSBy1}5gDmquCEazRgY!GTe2D=Ks| zLHj`OCoX_e4j$$H{Uw0bPxP~Py%Q{{ojr50Yf~GGeiV7O2<>5et8Jd_3Sp%0$!vE6 z_};Q&(|Q&~0GOL38c85yI}H494iT_XORzqA4gNLM5f&1f>^|or>z`aRlQBgkQlnTb zFRHzjPbRgeE7oins}Imc8BOs9l3@)~Ie<$Xj4|$s9%;D(SvY#~UPFCU<~+Ne)>2qS zb)_MuNJ2|Q(rwAdA{3fz5})ZVLiC7M_t76)92$CZ4&aS;>Sxwz63lI6z;3B7^ktlo zcI~nlGy(=r-YlS_xdIIYSmjD50T2MJ#3I#DPSm>_1dP_@PLzbo$`cQ&BXeoiKlg%& zf;oevumk&0DkKPH!I`l(LH0!33l0c%}P9Zejg5#BZLFfWB1;NduI zfH?6HjBtsAZ5J1B#)FQwiEkd>RJ#cPb8eYb32*2zsN>lQ9P3j{w;Xe_%NL9ygvRFf z9}tiMi(a1K?JZ9C8@@rJ2v#RwT_Q>yoI*7H{M>TLB0rp7Rtcn7lj!#niMFs(<_8k9 zyqX!0SYnR#L|o*gnqC3o>m-`3`(mmeTeJ|B8?(k08FHnahmtlcAmHYavR76nV8aML zR#DMv*t1<$D<8rt;Erq(}ece{1J#N0A zI`)jQ>kCJg>oBiXSpCN59PbI}o%tnGAz=qhIi%UGey64H*f?@{Yqm2i$K9_SvnyOG z=NrHDxEz$k-69YQzIK-e4mFO*o#uT8bcdFDPZj}Fa=z>6PYJgeZodAR6Tyn2@u(Up>$XF`v$!j z5CEPnT5`5dcLJvFXG|+m@mybu+f%yha+GTp*tl_+A8V%c_|slt+46=SPT zG|D0gX{~au(j>xY$(%P_hy2-{{kJ*)a*5+X!}Mr_h0hE%TyEHjq`-#2+3RT>hUp0B zXw+hDu<^v%Fh)V3j0jj7W-eTs4j9NYncicRZZEPMB9y;<**2F4z`?_6>p$y@VL3%< zcK|{SbhQqE2$eCY4JD#}YM$gV%nmMsHW)uRnr7_{XQp*VcOH6+9{nb7S7Wha`Y#B= zxabO(VS}w;q1VZT``MKTQt0kH*j&_yT?6_SP{in1Mmt%}2F-{kFz=b{DV*<`|4MLl zC#wN5*0!*Uz{7{Fv5QJ1$`U!vxBmEmsMp2ON}F!a+lfv1&t<4Va~lZSFTIB~ZYkGBoc`@pRbsr9j51ybf^eY#`=ji15(t-5X*X zTFRH!Ev4GKxOS4ZQScdXRetue3^J#dnWuHwm literal 0 HcmV?d00001 diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/v2/user_grant/funcs.go index a4ea2fc8..9587ced1 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/v2/user_grant/funcs.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -27,7 +26,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.RemoveUserGrant(ctx, &management.RemoveUserGrantRequest{ GrantId: d.Id(), - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete usergrant: %v", err) @@ -50,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateUserGrant(ctx, &management.UpdateUserGrantRequest{ GrantId: d.Id(), - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { @@ -73,7 +72,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } resp, err := client.AddUserGrant(ctx, &management.AddUserGrantRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), ProjectGrantId: d.Get(projectGrantIDVar).(string), ProjectId: d.Get(projectIDVar).(string), RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), @@ -87,71 +86,42 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - projectID := d.Get(projectIDVar) - projectGrantID := d.Get(projectGrantIDVar) - - queries := []*user.UserGrantQuery{ - {Query: &user.UserGrantQuery_UserIdQuery{ - UserIdQuery: &user.UserGrantUserIDQuery{ - UserId: d.Get(userIDVar).(string), - }, - }}, - } - if projectID != nil { - queries = append(queries, &user.UserGrantQuery{Query: &user.UserGrantQuery_ProjectIdQuery{ - ProjectIdQuery: &user.UserGrantProjectIDQuery{ - ProjectId: projectID.(string), - }, - }}, - ) - } - if projectGrantID != nil { - queries = append(queries, &user.UserGrantQuery{Query: &user.UserGrantQuery_ProjectGrantIdQuery{ - ProjectGrantIdQuery: &user.UserGrantProjectGrantIDQuery{ - ProjectGrantId: projectGrantID.(string), - }, - }}, - ) - } - grants, err := client.ListUserGrants(ctx, &management.ListUserGrantRequest{ - Queries: queries, + resp, err := client.GetUserGrantByID(ctx, &management.GetUserGrantByIDRequest{ + GrantId: helper.GetID(d, grantIDVar), + UserId: d.Get(UserIDVar).(string), }) + if err != nil && helper.IgnoreIfNotFoundError(err) == nil { + d.SetId("") + return nil + } if err != nil { - return diag.Errorf("failed to list usergrants") + return diag.Errorf("failed to get user grant") } - - if len(grants.GetResult()) == 1 { - grant := grants.GetResult()[0] - set := map[string]interface{}{ - userIDVar: grant.GetUserId(), - RoleKeysVar: grant.GetRoleKeys(), - helper.OrgIDVar: grant.GetDetails().GetResourceOwner(), - } - if grant.GetProjectId() != "" { - set[projectIDVar] = grant.GetProjectId() - } - if grant.GetProjectGrantId() != "" { - set[projectGrantIDVar] = grant.GetProjectGrantId() - } - for k, v := range set { - if err := d.Set(k, v); err != nil { - return diag.Errorf("failed to set %s of usergrant: %v", k, err) - } + grant := resp.GetUserGrant() + set := map[string]interface{}{ + UserIDVar: grant.GetUserId(), + RoleKeysVar: grant.GetRoleKeys(), + helper.OrgIDVar: grant.GetDetails().GetResourceOwner(), + } + if grant.GetProjectId() != "" { + set[projectIDVar] = grant.GetProjectId() + } + if grant.GetProjectGrantId() != "" { + set[projectGrantIDVar] = grant.GetProjectGrantId() + } + for k, v := range set { + if err := d.Set(k, v); err != nil { + return diag.Errorf("failed to set %s of usergrant: %v", k, err) } - d.SetId(grant.GetId()) - return nil } - - d.SetId("") + d.SetId(grant.GetId()) return nil } From 31247672aadad5f21775f286ea8f88fff2762b0a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 22 Aug 2023 12:46:32 +0200 Subject: [PATCH 243/260] fix tests --- examples/provider/resources/domain_policy.tf | 4 +- examples/provider/resources/org_idp_oidc.tf | 4 +- zitadel/v2/action/datasource.go | 1 + zitadel/v2/action/resource.go | 1 + zitadel/v2/app_key/resource_test.go | 3 +- zitadel/v2/application_api/datasource.go | 1 + zitadel/v2/application_oidc/datasource.go | 1 + zitadel/v2/default_domain_policy/resource.go | 1 + zitadel/v2/default_label_policy/const.go | 22 +++---- zitadel/v2/default_label_policy/funcs.go | 32 +++++----- zitadel/v2/default_label_policy/resource.go | 23 +++---- .../v2/default_label_policy/resource_test.go | 11 ++++ zitadel/v2/default_lockout_policy/resource.go | 1 + .../default_lockout_policy/resource_test.go | 4 +- zitadel/v2/default_login_policy/resource.go | 1 + .../v2/default_login_policy/resource_test.go | 4 +- .../default_notification_policy/resource.go | 1 + .../resource_test.go | 4 +- zitadel/v2/default_oidc_settings/resource.go | 3 + .../v2/default_oidc_settings/resource_test.go | 4 +- .../resource.go | 1 + .../resource_test.go | 4 +- zitadel/v2/default_privacy_policy/resource.go | 1 + .../default_privacy_policy/resource_test.go | 4 +- zitadel/v2/domain/resource.go | 1 + zitadel/v2/domain/resource_test.go | 7 ++- .../domain_claimed_message_text/resource.go | 3 +- zitadel/v2/domain_policy/funcs.go | 8 +-- zitadel/v2/domain_policy/resource.go | 1 + zitadel/v2/domain_policy/resource_test.go | 4 +- zitadel/v2/helper/import.go | 12 ++-- zitadel/v2/helper/import_test.go | 3 +- zitadel/v2/helper/test_utils/import_id.go | 4 +- zitadel/v2/human_user/const.go | 2 +- zitadel/v2/human_user/datasource.go | 1 + zitadel/v2/human_user/funcs.go | 2 +- zitadel/v2/human_user/resource.go | 4 +- zitadel/v2/human_user/resource_test.go | 8 ++- zitadel/v2/idp_azure_ad/datasource.go | 2 - zitadel/v2/idp_azure_ad/resource.go | 2 +- zitadel/v2/idp_github/datasource.go | 3 +- zitadel/v2/idp_github/resource.go | 4 +- zitadel/v2/idp_github_es/datasource.go | 3 +- zitadel/v2/idp_github_es/resource.go | 3 +- zitadel/v2/idp_gitlab/datasource.go | 3 +- zitadel/v2/idp_gitlab/resource.go | 3 +- .../v2/idp_gitlab_self_hosted/datasource.go | 3 +- zitadel/v2/idp_gitlab_self_hosted/resource.go | 3 +- zitadel/v2/idp_google/datasource.go | 3 +- zitadel/v2/idp_google/resource.go | 2 +- zitadel/v2/idp_ldap/datasource.go | 1 - zitadel/v2/idp_ldap/resource.go | 3 +- zitadel/v2/idp_utils/funcs.go | 20 ------ .../idp_utils/idp_test_utils/lifecyletest.go | 24 ++------ zitadel/v2/instance_member/const.go | 2 +- zitadel/v2/instance_member/funcs.go | 10 +-- zitadel/v2/instance_member/resource.go | 5 +- zitadel/v2/instance_member/resource_test.go | 7 ++- zitadel/v2/label_policy/const.go | 22 +++---- zitadel/v2/label_policy/funcs.go | 61 ++++++++++--------- zitadel/v2/label_policy/resource.go | 23 +++---- zitadel/v2/label_policy/resource_test.go | 16 ++++- zitadel/v2/lockout_policy/funcs.go | 21 ++----- zitadel/v2/lockout_policy/resource.go | 1 + zitadel/v2/lockout_policy/resource_test.go | 4 +- zitadel/v2/login_policy/funcs.go | 17 +----- zitadel/v2/login_policy/resource.go | 1 + zitadel/v2/login_policy/resource_test.go | 4 +- zitadel/v2/login_texts/resource.go | 3 +- zitadel/v2/login_texts/resource_test.go | 4 +- zitadel/v2/machine_key/const.go | 4 +- zitadel/v2/machine_key/funcs.go | 11 ++-- zitadel/v2/machine_key/resource.go | 8 +-- zitadel/v2/machine_key/resource_test.go | 9 ++- zitadel/v2/machine_user/datasource.go | 7 +-- zitadel/v2/machine_user/resource.go | 2 +- zitadel/v2/machine_user/resource_test.go | 7 ++- zitadel/v2/notification_policy/funcs.go | 21 ++----- zitadel/v2/notification_policy/resource.go | 1 + .../v2/notification_policy/resource_test.go | 4 +- zitadel/v2/org/resource.go | 1 + zitadel/v2/org/resource_test.go | 4 +- zitadel/v2/org_idp_azure_ad/datasource.go | 1 - zitadel/v2/org_idp_azure_ad/resource.go | 4 +- zitadel/v2/org_idp_github/datasource.go | 3 +- zitadel/v2/org_idp_github/resource.go | 4 +- zitadel/v2/org_idp_github_es/datasource.go | 3 +- zitadel/v2/org_idp_github_es/resource.go | 4 +- zitadel/v2/org_idp_gitlab/datasource.go | 3 +- zitadel/v2/org_idp_gitlab/resource.go | 4 +- .../org_idp_gitlab_self_hosted/datasource.go | 3 +- .../v2/org_idp_gitlab_self_hosted/resource.go | 4 +- zitadel/v2/org_idp_google/datasource.go | 3 +- zitadel/v2/org_idp_google/resource.go | 4 +- zitadel/v2/org_idp_jwt/datasource.go | 1 + zitadel/v2/org_idp_jwt/resource.go | 4 +- zitadel/v2/org_idp_jwt/resource_test.go | 7 ++- zitadel/v2/org_idp_ldap/datasource.go | 3 +- zitadel/v2/org_idp_ldap/resource.go | 4 +- zitadel/v2/org_idp_ldap/resource_test.go | 1 - zitadel/v2/org_idp_oidc/datasource.go | 1 + zitadel/v2/org_idp_oidc/resource.go | 4 +- zitadel/v2/org_idp_oidc/resource_test.go | 17 +++--- zitadel/v2/org_idp_utils/funcs.go | 42 ------------- .../org_idp_test_utils/lifecyletest.go | 25 ++------ zitadel/v2/org_member/const.go | 2 +- zitadel/v2/org_member/funcs.go | 10 +-- zitadel/v2/org_member/resource.go | 8 ++- zitadel/v2/org_member/resource_test.go | 10 ++- .../password_change_message_text/resource.go | 3 +- .../resource_test.go | 4 +- .../v2/password_complexity_policy/funcs.go | 20 +----- .../v2/password_complexity_policy/resource.go | 1 + .../resource_test.go | 4 +- .../password_reset_message_text/resource.go | 3 +- .../resource_test.go | 2 +- zitadel/v2/pat/const.go | 4 +- zitadel/v2/pat/funcs.go | 10 +-- zitadel/v2/pat/resource.go | 9 +-- zitadel/v2/pat/resource_test.go | 9 ++- zitadel/v2/privacy_policy/resource.go | 1 + zitadel/v2/privacy_policy/resource_test.go | 4 +- zitadel/v2/project/datasource.go | 1 + zitadel/v2/project/resource_test.go | 7 ++- zitadel/v2/project_grant/const.go | 2 +- zitadel/v2/project_grant/funcs.go | 10 +-- zitadel/v2/project_grant/resource.go | 5 +- zitadel/v2/project_grant/resource_test.go | 8 ++- zitadel/v2/project_grant_member/const.go | 4 +- zitadel/v2/project_grant_member/funcs.go | 20 +++--- zitadel/v2/project_grant_member/resource.go | 9 +-- .../v2/project_grant_member/resource_test.go | 18 +++++- zitadel/v2/project_member/const.go | 4 +- zitadel/v2/project_member/funcs.go | 20 +++--- zitadel/v2/project_member/resource.go | 9 +-- zitadel/v2/project_member/resource_test.go | 12 +++- zitadel/v2/project_role/const.go | 2 +- zitadel/v2/project_role/datasource.go | 3 +- zitadel/v2/project_role/funcs.go | 10 +-- zitadel/v2/project_role/resource.go | 5 +- zitadel/v2/project_role/resource_test.go | 14 +++-- zitadel/v2/sms_provider_twilio/resource.go | 1 + .../v2/sms_provider_twilio/resource_test.go | 7 ++- zitadel/v2/smtp_config/resource.go | 1 + zitadel/v2/smtp_config/resource_test.go | 4 +- zitadel/v2/trigger_actions/datasource.go | 1 + zitadel/v2/trigger_actions/resource_test.go | 14 +++-- zitadel/v2/user_grant/const.go | 2 +- zitadel/v2/user_grant/resource.go | 5 +- zitadel/v2/user_grant/resource_test.go | 8 ++- .../v2/verify_email_message_text/resource.go | 3 +- .../v2/verify_phone_message_text/resource.go | 3 +- 152 files changed, 499 insertions(+), 524 deletions(-) diff --git a/examples/provider/resources/domain_policy.tf b/examples/provider/resources/domain_policy.tf index 1ce6bbe8..a75590ac 100644 --- a/examples/provider/resources/domain_policy.tf +++ b/examples/provider/resources/domain_policy.tf @@ -1,6 +1,6 @@ resource "zitadel_domain_policy" "default" { org_id = data.zitadel_org.default.id - user_login_must_be_domain = true - validate_org_domains = false + user_login_must_be_domain = false + validate_org_domains = true smtp_sender_address_matches_instance_domain = true } diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index 24c531ea..3b63e4b2 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -2,8 +2,8 @@ resource "zitadel_org_idp_oidc" "default" { org_id = data.zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" - client_id = "google" - client_secret = "google_secret" + client_id = "a_client_id" + client_secret = "a_client_secret" issuer = "https://google.com" scopes = ["openid", "profile", "email"] display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" diff --git a/zitadel/v2/action/datasource.go b/zitadel/v2/action/datasource.go index d983b403..e1eda5ca 100644 --- a/zitadel/v2/action/datasource.go +++ b/zitadel/v2/action/datasource.go @@ -2,6 +2,7 @@ package action import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/action/resource.go b/zitadel/v2/action/resource.go index 221462df..5e7cd698 100644 --- a/zitadel/v2/action/resource.go +++ b/zitadel/v2/action/resource.go @@ -2,6 +2,7 @@ package action import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/app_key/resource_test.go index 240e081a..002781d1 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/app_key/resource_test.go @@ -4,14 +4,13 @@ import ( "fmt" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api/application_api_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" ) diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/v2/application_api/datasource.go index d289a713..bec0f92e 100644 --- a/zitadel/v2/application_api/datasource.go +++ b/zitadel/v2/application_api/datasource.go @@ -2,6 +2,7 @@ package application_api import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/v2/application_oidc/datasource.go index dc4a94eb..b6c4f3f9 100644 --- a/zitadel/v2/application_oidc/datasource.go +++ b/zitadel/v2/application_oidc/datasource.go @@ -2,6 +2,7 @@ package application_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_domain_policy/resource.go b/zitadel/v2/default_domain_policy/resource.go index 7b3e84dc..4671b49c 100644 --- a/zitadel/v2/default_domain_policy/resource.go +++ b/zitadel/v2/default_domain_policy/resource.go @@ -2,6 +2,7 @@ package default_domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_label_policy/const.go b/zitadel/v2/default_label_policy/const.go index c070ae67..6b9d8b1d 100644 --- a/zitadel/v2/default_label_policy/const.go +++ b/zitadel/v2/default_label_policy/const.go @@ -11,22 +11,22 @@ const ( warnColorDarkVar = "warn_color_dark" fontColorDarkVar = "font_color_dark" disableWatermarkVar = "disable_watermark" - logoPathVar = "logo_path" - logoHashVar = "logo_hash" + LogoPathVar = "logo_path" + LogoHashVar = "logo_hash" logoURLVar = "logo_url" - iconPathVar = "icon_path" - iconHashVar = "icon_hash" + IconPathVar = "icon_path" + IconHashVar = "icon_hash" iconURLVar = "icon_url" - logoDarkPathVar = "logo_dark_path" - logoDarkHashVar = "logo_dark_hash" + LogoDarkPathVar = "logo_dark_path" + LogoDarkHashVar = "logo_dark_hash" logoURLDarkVar = "logo_url_dark" - iconDarkPathVar = "icon_dark_path" - iconDarkHashVar = "icon_dark_hash" + IconDarkPathVar = "icon_dark_path" + IconDarkHashVar = "icon_dark_hash" iconURLDarkVar = "icon_url_dark" - fontPathVar = "font_path" - fontHashVar = "font_hash" + FontPathVar = "font_path" + FontHashVar = "font_hash" fontURLVar = "font_url" - setActiveVar = "set_active" + SetActiveVar = "set_active" ) const ( diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/v2/default_label_policy/funcs.go index 83920419..3bd7a164 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/v2/default_label_policy/funcs.go @@ -70,28 +70,28 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } d.SetId(id) - if d.HasChanges(logoHashVar, logoPathVar) { - if err := helper.InstanceFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string)); err != nil { + if d.HasChanges(LogoHashVar, LogoPathVar) { + if err := helper.InstanceFormFilePost(clientinfo, logoURL, d.Get(LogoPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } - if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { - if err := helper.InstanceFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string)); err != nil { + if d.HasChanges(LogoDarkHashVar, LogoDarkPathVar) { + if err := helper.InstanceFormFilePost(clientinfo, logoDarkURL, d.Get(LogoDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } - if d.HasChanges(iconHashVar, iconPathVar) { - if err := helper.InstanceFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string)); err != nil { + if d.HasChanges(IconHashVar, IconPathVar) { + if err := helper.InstanceFormFilePost(clientinfo, iconURL, d.Get(IconPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } - if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { - if err := helper.InstanceFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string)); err != nil { + if d.HasChanges(IconDarkHashVar, IconDarkPathVar) { + if err := helper.InstanceFormFilePost(clientinfo, iconDarkURL, d.Get(IconDarkPathVar).(string)); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } - if d.HasChanges(fontHashVar, fontPathVar) { - if err := helper.InstanceFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string)); err != nil { + if d.HasChanges(FontHashVar, FontPathVar) { + if err := helper.InstanceFormFilePost(clientinfo, fontURL, d.Get(FontPathVar).(string)); err != nil { return diag.Errorf("failed to upload font: %v", err) } } @@ -107,13 +107,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia warnColorDarkVar, fontColorDarkVar, disableWatermarkVar, - logoHashVar, - logoDarkHashVar, - iconHashVar, - iconDarkHashVar, - fontHashVar, + LogoHashVar, + LogoDarkHashVar, + IconHashVar, + IconDarkHashVar, + FontHashVar, ) { - if d.Get(setActiveVar).(bool) { + if d.Get(SetActiveVar).(bool) { if _, err := client.ActivateLabelPolicy(ctx, &admin.ActivateLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate default label policy: %v", err) } diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/v2/default_label_policy/resource.go index 94a28c5c..ede42ca8 100644 --- a/zitadel/v2/default_label_policy/resource.go +++ b/zitadel/v2/default_label_policy/resource.go @@ -2,6 +2,7 @@ package default_label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -59,12 +60,12 @@ func GetResource() *schema.Resource { Required: true, Description: "disable watermark", }, - logoPathVar: { + LogoPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - logoHashVar: { + LogoHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -74,12 +75,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - iconPathVar: { + IconPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - iconHashVar: { + IconHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -89,12 +90,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - logoDarkPathVar: { + LogoDarkPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - logoDarkHashVar: { + LogoDarkHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -104,12 +105,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - iconDarkPathVar: { + IconDarkPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - iconDarkHashVar: { + IconDarkHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -119,12 +120,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - fontPathVar: { + FontPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - fontHashVar: { + FontHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -134,7 +135,7 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - setActiveVar: { + SetActiveVar: { Type: schema.TypeBool, Optional: true, Description: "set the label policy active after creating/updating", diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/v2/default_label_policy/resource_test.go index 4bcb1323..11402748 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/v2/default_label_policy/resource_test.go @@ -42,6 +42,17 @@ func TestAccDefaultLabelPolicy(t *testing.T) { helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, test_utils.ImportNothing, + default_label_policy.SetActiveVar, + default_label_policy.LogoHashVar, + default_label_policy.LogoPathVar, + default_label_policy.LogoDarkHashVar, + default_label_policy.LogoDarkPathVar, + default_label_policy.IconHashVar, + default_label_policy.IconPathVar, + default_label_policy.IconDarkHashVar, + default_label_policy.IconDarkPathVar, + default_label_policy.FontHashVar, + default_label_policy.FontPathVar, ) } diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/v2/default_lockout_policy/resource.go index a840b77b..0b296ae6 100644 --- a/zitadel/v2/default_lockout_policy/resource.go +++ b/zitadel/v2/default_lockout_policy/resource.go @@ -2,6 +2,7 @@ package default_lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/v2/default_lockout_policy/resource_test.go index fbea972f..a66eafcf 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/v2/default_lockout_policy/resource_test.go @@ -27,12 +27,12 @@ func TestAccDefaultLockoutPolicy(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, 10, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/v2/default_login_policy/resource.go index e1ff2b2a..efc85f13 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/v2/default_login_policy/resource.go @@ -2,6 +2,7 @@ package default_login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/v2/default_login_policy/resource_test.go index 855b7ab2..f955c639 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/v2/default_login_policy/resource_test.go @@ -27,12 +27,12 @@ func TestAccDefaultLoginPolicy(t *testing.T) { []string{azureADDep, googleDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "localhost:9090", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_notification_policy/resource.go b/zitadel/v2/default_notification_policy/resource.go index 71d71d3a..091499be 100644 --- a/zitadel/v2/default_notification_policy/resource.go +++ b/zitadel/v2/default_notification_policy/resource.go @@ -2,6 +2,7 @@ package default_notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/v2/default_notification_policy/resource_test.go index 5612c156..5ac1c180 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/v2/default_notification_policy/resource_test.go @@ -24,12 +24,12 @@ func TestAccDefaultNotificationPolicy(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_oidc_settings/resource.go b/zitadel/v2/default_oidc_settings/resource.go index d533c32e..73fa27f2 100644 --- a/zitadel/v2/default_oidc_settings/resource.go +++ b/zitadel/v2/default_oidc_settings/resource.go @@ -2,6 +2,8 @@ package default_oidc_settings import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) func GetResource() *schema.Resource { @@ -33,5 +35,6 @@ func GetResource() *schema.Resource { UpdateContext: update, DeleteContext: delete, ReadContext: read, + Importer: helper.ImportWithEmptyID(), } } diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/v2/default_oidc_settings/resource_test.go index 4702b91f..a164a537 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/v2/default_oidc_settings/resource_test.go @@ -23,12 +23,12 @@ func TestAccDefaultOIDCSettings(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "456h0m0s", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_password_complexity_policy/resource.go b/zitadel/v2/default_password_complexity_policy/resource.go index 19045018..dbf7d213 100644 --- a/zitadel/v2/default_password_complexity_policy/resource.go +++ b/zitadel/v2/default_password_complexity_policy/resource.go @@ -2,6 +2,7 @@ package default_password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/v2/default_password_complexity_policy/resource_test.go index 2219e1a3..c1244a16 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/v2/default_password_complexity_policy/resource_test.go @@ -27,12 +27,12 @@ func TestAccDefaultPasswordComplexityPolicy(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, 10, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/v2/default_privacy_policy/resource.go index 2fbb0760..ef95f1b6 100644 --- a/zitadel/v2/default_privacy_policy/resource.go +++ b/zitadel/v2/default_privacy_policy/resource.go @@ -2,6 +2,7 @@ package default_privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/v2/default_privacy_policy/resource_test.go index e0e6f9ef..0ddd0873 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/v2/default_privacy_policy/resource_test.go @@ -23,12 +23,12 @@ func TestAccDefaultPrivacyPolicy(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "http://example.com/acctest", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", "", + test_utils.ImportNothing, ) } diff --git a/zitadel/v2/domain/resource.go b/zitadel/v2/domain/resource.go index fc56c82c..8a4e774f 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/v2/domain/resource.go @@ -2,6 +2,7 @@ package domain import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/v2/domain/resource_test.go index 8fb62b3a..42e11e5e 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/v2/domain/resource_test.go @@ -25,12 +25,15 @@ func TestAccDomain(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(frame), regexp.MustCompile(fmt.Sprintf(`^%s$|^%s$`, exampleProperty, updatedProperty)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/v2/domain_claimed_message_text/resource.go index b060632c..6a542c57 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/v2/domain_claimed_message_text/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/v2/domain_policy/funcs.go index 60cdf8a2..174fd1bd 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/v2/domain_policy/funcs.go @@ -47,8 +47,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - org := d.Get(helper.OrgIDVar).(string) - + org := helper.GetID(d, helper.OrgIDVar) _, err = client.UpdateCustomDomainPolicy(ctx, &admin.UpdateCustomDomainPolicyRequest{ OrgId: org, UserLoginMustBeDomain: d.Get(UserLoginMustBeDomainVar).(bool), @@ -74,8 +73,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia if err != nil { return diag.FromErr(err) } - org := d.Get(helper.OrgIDVar).(string) - + org := helper.GetID(d, helper.OrgIDVar) _, err = client.AddCustomDomainPolicy(ctx, &admin.AddCustomDomainPolicyRequest{ OrgId: org, UserLoginMustBeDomain: d.Get(UserLoginMustBeDomainVar).(bool), @@ -97,7 +95,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/v2/domain_policy/resource.go index 84934fda..c0f85026 100644 --- a/zitadel/v2/domain_policy/resource.go +++ b/zitadel/v2/domain_policy/resource.go @@ -2,6 +2,7 @@ package domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/v2/domain_policy/resource_test.go index 846fcb1a..6f62c58c 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/v2/domain_policy/resource_test.go @@ -29,12 +29,12 @@ func TestAccDomainPolicy(t *testing.T) { return strings.Replace(resourceExample, strconv.FormatBool(exampleProperty), strconv.FormatBool(property), 1) }, exampleProperty, !exampleProperty, - "", "", + "", "", "", false, checkRemoteProperty(*otherFrame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*otherFrame)(false), - nil, nil, "", "", + test_utils.ImportOrgId(otherFrame), ) } diff --git a/zitadel/v2/helper/import.go b/zitadel/v2/helper/import.go index 6d6863c1..4ff96c21 100644 --- a/zitadel/v2/helper/import.go +++ b/zitadel/v2/helper/import.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "io" "sort" "strings" @@ -131,15 +132,15 @@ func importWithAttributes(state importState, attrs ...importAttribute) (err erro csvReader.Comma = ':' csvReader.LazyQuotes = true parts, err := csvReader.Read() - if err != nil { + if err != nil && err != io.EOF { return fmt.Errorf("failed to parse id: %w", err) } - // if we expect an empty id and have more than just the emptyIDAttribute, we ensure the first part is an empty key - if len(attrs) > 1 && attrs[0].key == emptyIDAttribute.key && parts[0] != "" { + // if we expect an empty id and have more than just the emptyIDAttribute, we prepend an empty part to the ID + if len(attrs) > 0 && attrs[0].key == emptyIDAttribute.key || attrs[0].optional && len(parts) == 0 { parts = append([]string{""}, parts...) internalMinParts++ } - if len(parts) < internalMinParts || len(parts) > internalMaxParts || internalMinParts > 0 && len(id) == 0 { + if len(parts) < internalMinParts || len(parts) > internalMaxParts { return fmt.Errorf(`expected the number of semicolon separated parts to be between %d and %d, but got %d parts: "%s"`, externalMinParts, externalMaxParts, len(parts), strings.Join(parts, `", "`)) } for i, part := range parts { @@ -156,9 +157,6 @@ func importWithAttributes(state importState, attrs ...importAttribute) (err erro if i == 0 { state.SetId(val.(string)) continue - } - if attr.optional && val == nil { - } if err := state.Set(attr.key, val); err != nil { return fmt.Errorf("failed to set %s=%v: %w", attr.key, val, err) diff --git a/zitadel/v2/helper/import_test.go b/zitadel/v2/helper/import_test.go index acd3322e..06b280a1 100644 --- a/zitadel/v2/helper/import_test.go +++ b/zitadel/v2/helper/import_test.go @@ -150,8 +150,7 @@ func TestImportWithAttributes(t *testing.T) { }, want: want{ attributes: map[string]interface{}{ - "id": validID, - "org_id": validID, + "id": validID, }, }, }, { diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/v2/helper/test_utils/import_id.go index 4329f382..8ed19631 100644 --- a/zitadel/v2/helper/test_utils/import_id.go +++ b/zitadel/v2/helper/test_utils/import_id.go @@ -5,10 +5,10 @@ import ( "regexp" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) var ( diff --git a/zitadel/v2/human_user/const.go b/zitadel/v2/human_user/const.go index 30273d26..5d73bce0 100644 --- a/zitadel/v2/human_user/const.go +++ b/zitadel/v2/human_user/const.go @@ -20,7 +20,7 @@ const ( isPhoneVerifiedVar = "is_phone_verified" phoneVar = "phone" - initialPasswordVar = "initial_password" + InitialPasswordVar = "initial_password" defaultGenderString = "GENDER_UNSPECIFIED" defaultPreferredLanguage = "und" diff --git a/zitadel/v2/human_user/datasource.go b/zitadel/v2/human_user/datasource.go index c3b81f75..f9b7542b 100644 --- a/zitadel/v2/human_user/datasource.go +++ b/zitadel/v2/human_user/datasource.go @@ -2,6 +2,7 @@ package human_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/v2/human_user/funcs.go index c5fc1745..24690e87 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/v2/human_user/funcs.go @@ -58,7 +58,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia PreferredLanguage: d.Get(preferredLanguageVar).(string), NickName: d.Get(nickNameVar).(string), }, - InitialPassword: d.Get(initialPasswordVar).(string), + InitialPassword: d.Get(InitialPasswordVar).(string), } if displayname, ok := d.GetOk(DisplayNameVar); ok { diff --git a/zitadel/v2/human_user/resource.go b/zitadel/v2/human_user/resource.go index 9faaad8d..5d76f5da 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/v2/human_user/resource.go @@ -103,7 +103,7 @@ func GetResource() *schema.Resource { Optional: true, Description: "Is the phone verified of the user", }, - initialPasswordVar: { + InitialPasswordVar: { Type: schema.TypeString, Optional: true, Description: "Initially set password for the user, not changeable after creation", @@ -141,6 +141,6 @@ func GetResource() *schema.Resource { return diff.SetNew(preferredLanguageVar, defaultPreferredLanguage) }), ), - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(UserIDVar, initialPasswordVar), + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(UserIDVar, InitialPasswordVar), } } diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/v2/human_user/resource_test.go index 4fd9bb58..22065383 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/v2/human_user/resource_test.go @@ -27,12 +27,16 @@ func TestAccHumanUser(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, human_user.InitialPasswordVar), + ), ) } diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/v2/idp_azure_ad/datasource.go index b0aa9ac3..7cf221be 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/v2/idp_azure_ad/datasource.go @@ -3,7 +3,6 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -25,6 +24,5 @@ func GetDatasource() *schema.Resource { EmailVerifiedVar: EmailVerifiedDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/v2/idp_azure_ad/resource.go index 5f4475fe..75fe369f 100644 --- a/zitadel/v2/idp_azure_ad/resource.go +++ b/zitadel/v2/idp_azure_ad/resource.go @@ -2,8 +2,8 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/v2/idp_github/datasource.go index 2ec4097d..6f2f0136 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/v2/idp_github/datasource.go @@ -21,6 +21,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/v2/idp_github/resource.go index afdca922..80e17809 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/v2/idp_github/resource.go @@ -2,8 +2,8 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -25,5 +25,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/v2/idp_github_es/datasource.go index ee51657b..ffae1adf 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/v2/idp_github_es/datasource.go @@ -24,6 +24,5 @@ func GetDatasource() *schema.Resource { UserEndpointVar: UserEndpointDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/v2/idp_github_es/resource.go index 69b3b6ba..fbcebda5 100644 --- a/zitadel/v2/idp_github_es/resource.go +++ b/zitadel/v2/idp_github_es/resource.go @@ -3,6 +3,7 @@ package idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -27,5 +28,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/v2/idp_gitlab/datasource.go index 37af57fb..33025a18 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/v2/idp_gitlab/datasource.go @@ -21,6 +21,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/v2/idp_gitlab/resource.go index b5eecc05..aa20f995 100644 --- a/zitadel/v2/idp_gitlab/resource.go +++ b/zitadel/v2/idp_gitlab/resource.go @@ -3,6 +3,7 @@ package idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -24,5 +25,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/v2/idp_gitlab_self_hosted/datasource.go index 3cdc1153..241ac9eb 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/datasource.go @@ -22,6 +22,5 @@ func GetDatasource() *schema.Resource { IssuerVar: IssuerDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/v2/idp_gitlab_self_hosted/resource.go index fe0790aa..f058a93a 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/idp_gitlab_self_hosted/resource.go @@ -3,6 +3,7 @@ package idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -25,5 +26,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/v2/idp_google/datasource.go index d074e048..2cb293f1 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/v2/idp_google/datasource.go @@ -21,6 +21,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/v2/idp_google/resource.go index dc64494e..f26d37e0 100644 --- a/zitadel/v2/idp_google/resource.go +++ b/zitadel/v2/idp_google/resource.go @@ -2,8 +2,8 @@ package idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) diff --git a/zitadel/v2/idp_ldap/datasource.go b/zitadel/v2/idp_ldap/datasource.go index 49a5d577..db08001e 100644 --- a/zitadel/v2/idp_ldap/datasource.go +++ b/zitadel/v2/idp_ldap/datasource.go @@ -42,6 +42,5 @@ func GetDatasource() *schema.Resource { ProfileAttributeVar: ProfileAttributeDataSourceField, }, ReadContext: read, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(BindPasswordVar)}, } } diff --git a/zitadel/v2/idp_ldap/resource.go b/zitadel/v2/idp_ldap/resource.go index 734c351c..404a5de0 100644 --- a/zitadel/v2/idp_ldap/resource.go +++ b/zitadel/v2/idp_ldap/resource.go @@ -3,6 +3,7 @@ package idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) @@ -44,6 +45,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: idp_utils.ImportIDPWithSecret(BindPasswordVar)}, + Importer: helper.ImportWithIDAndOptionalSecret(idp_utils.IdpIDVar, BindPasswordVar), } } diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/v2/idp_utils/funcs.go index 901637c7..6f8d50c1 100644 --- a/zitadel/v2/idp_utils/funcs.go +++ b/zitadel/v2/idp_utils/funcs.go @@ -2,8 +2,6 @@ package idp_utils import ( "context" - "fmt" - "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -29,24 +27,6 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return nil } -func ImportIDPWithSecret(secretVar string) schema.StateContextFunc { - return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", IdpIDVar) - } - parts := strings.SplitN(id, ":", 2) - if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, IdpIDVar, secretVar) - } - data.SetId(parts[0]) - if err := data.Set(secretVar, parts[1]); err != nil { - return nil, err - } - return []*schema.ResourceData{data}, nil - } -} - func StringValue(d *schema.ResourceData, attributeVar string) string { return d.Get(attributeVar).(string) } diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go index eac33695..0ee39b53 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go @@ -1,19 +1,15 @@ package idp_test_utils import ( - "fmt" "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func RunInstanceIDPLifecyleTest(t *testing.T, resourceName, secretAttribute string) { - const importedSecret = "an_imported_secret" frame := test_utils.NewInstanceTestFrame(t, resourceName) resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) nameProperty := test_utils.AttributeValue(t, idp_utils.NameVar, exampleAttributes).AsString() @@ -27,24 +23,14 @@ func RunInstanceIDPLifecyleTest(t *testing.T, resourceName, secretAttribute stri nil, test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), true, false, - exampleSecret, "an_updated_secret", + secretAttribute, exampleSecret, "an_updated_secret", false, CheckCreationAllowed(*frame), helper.ZitadelGeneratedIdOnlyRegex, CheckDestroy(*frame), - func(state *terraform.State) error { - // Check the secret is imported correctly - actual := frame.State(state).Attributes[secretAttribute] - if actual != importedSecret { - return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) - } - return nil - }, - func(state *terraform.State) (string, error) { - lastState := frame.State(state) - return fmt.Sprintf("%s:%s", lastState.ID, importedSecret), nil - }, - "12345", - secretAttribute, + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, secretAttribute), + ), ) } diff --git a/zitadel/v2/instance_member/const.go b/zitadel/v2/instance_member/const.go index a3a282f5..325a92c8 100644 --- a/zitadel/v2/instance_member/const.go +++ b/zitadel/v2/instance_member/const.go @@ -1,6 +1,6 @@ package instance_member const ( - userIDVar = "user_id" + UserIDVar = "user_id" RolesVar = "roles" ) diff --git a/zitadel/v2/instance_member/funcs.go b/zitadel/v2/instance_member/funcs.go index 13c4ea6c..a5f1efb2 100644 --- a/zitadel/v2/instance_member/funcs.go +++ b/zitadel/v2/instance_member/funcs.go @@ -27,7 +27,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveIAMMember(ctx, &admin.RemoveIAMMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete instance member: %v", err) @@ -49,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateIAMMember(ctx, &admin.UpdateIAMMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { @@ -71,7 +71,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.AddIAMMember(ctx, &admin.AddIAMMemberRequest{ UserId: userID, Roles: helper.GetOkSetToStringSlice(d, RolesVar), @@ -96,7 +96,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.ListIAMMembers(ctx, &admin.ListIAMMembersRequest{ Queries: []*member.SearchQuery{{ Query: &member.SearchQuery_UserIdQuery{ @@ -117,7 +117,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { member := resp.Result[0] set := map[string]interface{}{ - userIDVar: member.GetUserId(), + UserIDVar: member.GetUserId(), RolesVar: member.GetRoles(), } for k, v := range set { diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/v2/instance_member/resource.go index 3d083563..e0eda8a3 100644 --- a/zitadel/v2/instance_member/resource.go +++ b/zitadel/v2/instance_member/resource.go @@ -2,6 +2,7 @@ package instance_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -9,7 +10,7 @@ func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing the membership of a user on an instance, defined with the given role.", Schema: map[string]*schema.Schema{ - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -28,6 +29,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: helper.ImportWithID(userIDVar), + Importer: helper.ImportWithEmptyID(helper.NewImportAttribute(UserIDVar, helper.ConvertID, false)), } } diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/v2/instance_member/resource_test.go index a92e27b9..4e9da677 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/v2/instance_member/resource_test.go @@ -2,6 +2,7 @@ package instance_member_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -26,12 +27,12 @@ func TestAccInstanceMember(t *testing.T) { []string{frame.AsOrgDefaultDependency, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "IAM_OWNER_VIEWER", - "", "", + "", "", "", true, checkRemoteProperty(*frame, userID), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf("^%s_%s$", helper.ZitadelGeneratedIdPattern, helper.ZitadelGeneratedIdPattern)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), - nil, nil, "", "", + test_utils.ImportStateAttribute(frame.BaseTestFrame, instance_member.UserIDVar), ) } diff --git a/zitadel/v2/label_policy/const.go b/zitadel/v2/label_policy/const.go index a2caf3a5..5de7cafb 100644 --- a/zitadel/v2/label_policy/const.go +++ b/zitadel/v2/label_policy/const.go @@ -11,22 +11,22 @@ const ( warnColorDarkVar = "warn_color_dark" fontColorDarkVar = "font_color_dark" disableWatermarkVar = "disable_watermark" - logoPathVar = "logo_path" - logoHashVar = "logo_hash" + LogoPathVar = "logo_path" + LogoHashVar = "logo_hash" logoURLVar = "logo_url" - iconPathVar = "icon_path" - iconHashVar = "icon_hash" + IconPathVar = "icon_path" + IconHashVar = "icon_hash" iconURLVar = "icon_url" - logoDarkPathVar = "logo_dark_path" - logoDarkHashVar = "logo_dark_hash" + LogoDarkPathVar = "logo_dark_path" + LogoDarkHashVar = "logo_dark_hash" logoURLDarkVar = "logo_url_dark" - iconDarkPathVar = "icon_dark_path" - iconDarkHashVar = "icon_dark_hash" + IconDarkPathVar = "icon_dark_path" + IconDarkHashVar = "icon_dark_hash" iconURLDarkVar = "icon_url_dark" - fontPathVar = "font_path" - fontHashVar = "font_hash" + FontPathVar = "font_path" + FontHashVar = "font_hash" fontURLVar = "font_url" - setActiveVar = "set_active" + SetActiveVar = "set_active" ) const ( diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/v2/label_policy/funcs.go index a7434b1c..f35d1fa0 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/v2/label_policy/funcs.go @@ -19,7 +19,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -40,7 +40,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -76,28 +76,28 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia d.SetId(resp.Details.ResourceOwner) } - if d.HasChanges(logoHashVar, logoPathVar) { - if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string), org); err != nil { + if d.HasChanges(LogoHashVar, LogoPathVar) { + if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(LogoPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } - if d.HasChanges(logoDarkHashVar, logoDarkPathVar) { - if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string), org); err != nil { + if d.HasChanges(LogoDarkHashVar, LogoDarkPathVar) { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(LogoDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } - if d.HasChanges(iconHashVar, iconPathVar) { - if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string), org); err != nil { + if d.HasChanges(IconHashVar, IconPathVar) { + if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(IconPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } - if d.HasChanges(iconDarkHashVar, iconDarkPathVar) { - if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string), org); err != nil { + if d.HasChanges(IconDarkHashVar, IconDarkPathVar) { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(IconDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } - if d.HasChanges(fontHashVar, fontPathVar) { - if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string), org); err != nil { + if d.HasChanges(FontHashVar, FontPathVar) { + if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(FontPathVar).(string), org); err != nil { return diag.Errorf("failed to upload font: %v", err) } } @@ -113,13 +113,13 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia warnColorDarkVar, fontColorDarkVar, disableWatermarkVar, - logoHashVar, - logoDarkHashVar, - iconHashVar, - iconDarkHashVar, - fontHashVar, + LogoHashVar, + LogoDarkHashVar, + IconHashVar, + IconDarkHashVar, + FontHashVar, ) { - if d.Get(setActiveVar).(bool) { + if d.Get(SetActiveVar).(bool) { if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate label policy: %v", err) } @@ -159,33 +159,33 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } d.SetId(org) - if d.Get(logoHashVar) != "" && d.Get(logoPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(logoPathVar).(string), org); err != nil { + if d.Get(LogoHashVar) != "" && d.Get(LogoPathVar) != "" { + if err := helper.OrgFormFilePost(clientinfo, logoURL, d.Get(LogoPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo: %v", err) } } - if d.Get(logoDarkHashVar) != "" && d.Get(logoDarkPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(logoDarkPathVar).(string), org); err != nil { + if d.Get(LogoDarkHashVar) != "" && d.Get(LogoDarkPathVar) != "" { + if err := helper.OrgFormFilePost(clientinfo, logoDarkURL, d.Get(LogoDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload logo dark: %v", err) } } - if d.Get(iconHashVar) != "" && d.Get(iconPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(iconPathVar).(string), org); err != nil { + if d.Get(IconHashVar) != "" && d.Get(IconPathVar) != "" { + if err := helper.OrgFormFilePost(clientinfo, iconURL, d.Get(IconPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon: %v", err) } } - if d.Get(iconDarkHashVar) != "" && d.Get(iconDarkPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(iconDarkPathVar).(string), org); err != nil { + if d.Get(IconDarkHashVar) != "" && d.Get(IconDarkPathVar) != "" { + if err := helper.OrgFormFilePost(clientinfo, iconDarkURL, d.Get(IconDarkPathVar).(string), org); err != nil { return diag.Errorf("failed to upload icon dark: %v", err) } } - if d.Get(fontHashVar) != "" && d.Get(fontPathVar) != "" { - if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(fontPathVar).(string), org); err != nil { + if d.Get(FontHashVar) != "" && d.Get(FontPathVar) != "" { + if err := helper.OrgFormFilePost(clientinfo, fontURL, d.Get(FontPathVar).(string), org); err != nil { return diag.Errorf("failed to upload font: %v", err) } } - if d.Get(setActiveVar).(bool) { + if d.Get(SetActiveVar).(bool) { if _, err := client.ActivateCustomLabelPolicy(ctx, &management.ActivateCustomLabelPolicyRequest{}); err != nil { return diag.Errorf("failed to activate label policy: %v", err) } @@ -202,7 +202,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -223,6 +223,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return nil } set := map[string]interface{}{ + helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), primaryColorVar: policy.GetPrimaryColor(), hideLoginNameSuffixVar: policy.GetHideLoginNameSuffix(), warnColorVar: policy.GetWarnColor(), diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/v2/label_policy/resource.go index 99eb060b..f6b0f2fc 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/v2/label_policy/resource.go @@ -2,6 +2,7 @@ package label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -60,12 +61,12 @@ func GetResource() *schema.Resource { Required: true, Description: "disable watermark", }, - logoPathVar: { + LogoPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - logoHashVar: { + LogoHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -75,12 +76,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - iconPathVar: { + IconPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - iconHashVar: { + IconHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -90,12 +91,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - logoDarkPathVar: { + LogoDarkPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - logoDarkHashVar: { + LogoDarkHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -105,12 +106,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - iconDarkPathVar: { + IconDarkPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - iconDarkHashVar: { + IconDarkHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -120,12 +121,12 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - fontPathVar: { + FontPathVar: { Type: schema.TypeString, Optional: true, Description: "", }, - fontHashVar: { + FontHashVar: { Type: schema.TypeString, Optional: true, Description: "", @@ -135,7 +136,7 @@ func GetResource() *schema.Resource { Computed: true, Description: "", }, - setActiveVar: { + SetActiveVar: { Type: schema.TypeBool, Optional: true, Description: "set the label policy active after creating/updating", diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/v2/label_policy/resource_test.go index 05809165..f51ae599 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/v2/label_policy/resource_test.go @@ -15,6 +15,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" ) func TestAccLabelPolicy(t *testing.T) { @@ -35,12 +36,23 @@ func TestAccLabelPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "#5469d3", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(exampleProperty), - nil, nil, "", "", + test_utils.ImportOrgId(frame), + label_policy.SetActiveVar, + label_policy.LogoHashVar, + label_policy.LogoPathVar, + label_policy.LogoDarkHashVar, + label_policy.LogoDarkPathVar, + label_policy.IconHashVar, + label_policy.IconPathVar, + label_policy.IconDarkHashVar, + label_policy.IconDarkPathVar, + label_policy.FontHashVar, + label_policy.FontPathVar, ) } diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/v2/lockout_policy/funcs.go index 9486a91c..12ce128f 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/v2/lockout_policy/funcs.go @@ -13,18 +13,15 @@ import ( func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.ResetLockoutPolicyToDefault(ctx, &management.ResetLockoutPolicyToDefaultRequest{}) if err != nil { return diag.Errorf("failed to reset lockout policy: %v", err) @@ -34,17 +31,15 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) + org := helper.GetID(d, helper.OrgIDVar) + client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.UpdateCustomLockoutPolicy(ctx, &management.UpdateCustomLockoutPolicyRequest{ MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), }) @@ -56,18 +51,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.AddCustomLockoutPolicy(ctx, &management.AddCustomLockoutPolicyRequest{ MaxPasswordAttempts: uint32(d.Get(maxPasswordAttemptsVar).(int)), }) @@ -80,18 +72,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - resp, err := client.GetLockoutPolicy(ctx, &management.GetLockoutPolicyRequest{}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") @@ -100,7 +89,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { return diag.Errorf("failed to get lockout policy") } - policy := resp.Policy if policy.GetIsDefault() == true { d.SetId("") @@ -110,7 +98,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), maxPasswordAttemptsVar: policy.GetMaxPasswordAttempts(), } - for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of lockout policy: %v", k, err) diff --git a/zitadel/v2/lockout_policy/resource.go b/zitadel/v2/lockout_policy/resource.go index bf113092..5c25fb9a 100644 --- a/zitadel/v2/lockout_policy/resource.go +++ b/zitadel/v2/lockout_policy/resource.go @@ -2,6 +2,7 @@ package lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/v2/lockout_policy/resource_test.go index 37fc94c0..dc919f71 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/v2/lockout_policy/resource_test.go @@ -26,12 +26,12 @@ func TestAccLockoutPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, 10, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(0), - nil, nil, "", "", + test_utils.ImportOrgId(frame), ) } diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/v2/login_policy/funcs.go index 8ee7388f..ca57e4bb 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/v2/login_policy/funcs.go @@ -18,18 +18,15 @@ import ( func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.ResetLoginPolicyToDefault(ctx, &management.ResetLoginPolicyToDefaultRequest{}) if err != nil { return diag.Errorf("failed to reset login policy: %v", err) @@ -45,7 +42,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) @@ -286,18 +283,15 @@ func getIDPOwnerType(ctx context.Context, client *mgmtclient.Client, id string) func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - resp, err := client.GetLoginPolicy(ctx, &management.GetLoginPolicyRequest{}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") @@ -306,7 +300,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { return diag.Errorf("failed to get login policy") } - policy := resp.Policy if policy.GetIsDefault() == true { d.SetId("") @@ -331,7 +324,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn disableLoginWithEmail: policy.GetDisableLoginWithEmail(), disableLoginWithPhone: policy.GetDisableLoginWithPhone(), } - respSecond, err := client.ListLoginPolicySecondFactors(ctx, &management.ListLoginPolicySecondFactorsRequest{}) if err != nil { return diag.Errorf("failed to get login policy secondfactors: %v", err) @@ -343,7 +335,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set[secondFactorsVar] = factors } - respMulti, err := client.ListLoginPolicyMultiFactors(ctx, &management.ListLoginPolicyMultiFactorsRequest{}) if err != nil { return diag.Errorf("failed to get login policy multifactors: %v", err) @@ -355,7 +346,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set[multiFactorsVar] = factors } - respIDPs, err := client.ListLoginPolicyIDPs(ctx, &management.ListLoginPolicyIDPsRequest{}) if err != nil { return diag.Errorf("failed to get login policy idps: %v", err) @@ -367,7 +357,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } set[idpsVar] = idps } - for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of login policy: %v", k, err) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index fca3886a..23009577 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -2,6 +2,7 @@ package login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/v2/login_policy/resource_test.go index df56530c..7f63d693 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/v2/login_policy/resource_test.go @@ -27,12 +27,12 @@ func TestAccLoginPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency, azureADDep, googleDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "localhost:9090", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(""), - nil, nil, "", "", + test_utils.ImportOrgId(frame), ) } diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/v2/login_texts/resource.go index 5074ade5..28af04a8 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/v2/login_texts/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/v2/login_texts/resource_test.go index 08a1a409..394ba86d 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/v2/login_texts/resource_test.go @@ -24,13 +24,13 @@ func TestAccLoginTexts(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedtext", - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)(""), - nil, nil, "", "", + nil, ) } diff --git a/zitadel/v2/machine_key/const.go b/zitadel/v2/machine_key/const.go index 2909735b..6d1d2bdf 100644 --- a/zitadel/v2/machine_key/const.go +++ b/zitadel/v2/machine_key/const.go @@ -2,8 +2,8 @@ package machine_key const ( keyIDVar = "key_id" - userIDVar = "user_id" + UserIDVar = "user_id" keyTypeVar = "key_type" - keyDetailsVar = "key_details" + KeyDetailsVar = "key_details" ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/v2/machine_key/funcs.go index 0a16dd8e..5d7e59a9 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/v2/machine_key/funcs.go @@ -28,7 +28,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveMachineKey(ctx, &management.RemoveMachineKeyRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), KeyId: d.Id(), }) if err != nil { @@ -53,7 +53,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia keyType := d.Get(keyTypeVar).(string) req := &management.AddMachineKeyRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), Type: authn.KeyType(authn.KeyType_value[keyType]), } @@ -70,7 +70,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } d.SetId(resp.GetKeyId()) - if err := d.Set(keyDetailsVar, string(resp.GetKeyDetails())); err != nil { + if err := d.Set(KeyDetailsVar, string(resp.GetKeyDetails())); err != nil { return diag.FromErr(err) } return nil @@ -89,7 +89,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.GetMachineKeyByIDs(ctx, &management.GetMachineKeyByIDsRequest{ UserId: userID, KeyId: d.Id(), @@ -105,8 +105,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn d.SetId(resp.GetKey().GetId()) set := map[string]interface{}{ ExpirationDateVar: resp.GetKey().GetExpirationDate().AsTime().Format(time.RFC3339), - userIDVar: userID, + UserIDVar: userID, helper.OrgIDVar: orgID, + keyTypeVar: resp.GetKey().GetType().String(), } for k, v := range set { if err := d.Set(k, v); err != nil { diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/v2/machine_key/resource.go index 1112564d..69ebddef 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/v2/machine_key/resource.go @@ -14,7 +14,7 @@ func GetResource() *schema.Resource { Description: "Resource representing a machine key", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -36,7 +36,7 @@ func GetResource() *schema.Resource { ForceNew: true, Computed: true, }, - keyDetailsVar: { + KeyDetailsVar: { Type: schema.TypeString, Computed: true, Description: "Value of the machine key", @@ -48,8 +48,8 @@ func GetResource() *schema.Resource { ReadContext: read, Importer: helper.ImportWithIDAndOptionalOrg( keyIDVar, - helper.NewImportAttribute(userIDVar, helper.ConvertID, false), - helper.NewImportAttribute(keyDetailsVar, helper.ConvertJSON, true), + helper.NewImportAttribute(UserIDVar, helper.ConvertID, false), + helper.NewImportAttribute(KeyDetailsVar, helper.ConvertJSON, true), ), } } diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/v2/machine_key/resource_test.go index a7598926..5eac0251 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/v2/machine_key/resource_test.go @@ -25,12 +25,17 @@ func TestAccMachineKey(t *testing.T) { []string{frame.AsOrgDefaultDependency, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "2051-01-01T00:00:00Z", - "", "", + "", "", "", false, checkRemoteProperty(*frame, userID), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, machine_key.UserIDVar), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, machine_key.KeyDetailsVar), + ), ) } diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/v2/machine_user/datasource.go index 76ec140a..709085b5 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/v2/machine_user/datasource.go @@ -2,6 +2,7 @@ package machine_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -9,16 +10,12 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a serviceaccount situated under an organization, which then can be authorized through memberships or direct grants on other resources.", Schema: map[string]*schema.Schema{ + helper.OrgIDVar: helper.OrgIDDatasourceField, UserIDVar: { Type: schema.TypeString, Required: true, Description: "The ID of this resource.", }, - helper.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, userStateVar: { Type: schema.TypeString, Computed: true, diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/v2/machine_user/resource.go index a669c028..29e0329c 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/v2/machine_user/resource.go @@ -65,6 +65,6 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: delete, UpdateContext: update, - Importer: helper.ImportWithIDAndOptionalOrg(helper.ResourceIDVar), + Importer: helper.ImportWithIDAndOptionalOrg(UserIDVar), } } diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/v2/machine_user/resource_test.go index 27557cbc..40e3a94e 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/v2/machine_user/resource_test.go @@ -26,12 +26,15 @@ func TestAccMachineUser(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "updatedproperty", - "", "", + "", "", "", false, checkRemoteProperty(frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/notification_policy/funcs.go b/zitadel/v2/notification_policy/funcs.go index 17b840cc..847d9bb2 100644 --- a/zitadel/v2/notification_policy/funcs.go +++ b/zitadel/v2/notification_policy/funcs.go @@ -13,17 +13,15 @@ import ( func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) + org := helper.GetID(d, helper.OrgIDVar) + client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.ResetNotificationPolicyToDefault(ctx, &management.ResetNotificationPolicyToDefaultRequest{}) if err != nil { return diag.Errorf("failed to reset notification policy: %v", err) @@ -33,18 +31,15 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - org := d.Get(helper.OrgIDVar).(string) - + org := helper.GetID(d, helper.OrgIDVar) if d.HasChanges(passwordChangeVar) { _, err = client.UpdateCustomNotificationPolicy(ctx, &management.UpdateCustomNotificationPolicyRequest{ PasswordChange: d.Get(passwordChangeVar).(bool), @@ -59,18 +54,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } org := d.Get(helper.OrgIDVar).(string) - _, err = client.AddCustomNotificationPolicy(ctx, &management.AddCustomNotificationPolicyRequest{ PasswordChange: d.Get(passwordChangeVar).(bool), }) @@ -83,18 +75,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - resp, err := client.GetNotificationPolicy(ctx, &management.GetNotificationPolicyRequest{}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") @@ -103,7 +92,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { return diag.Errorf("failed to get notification policy") } - policy := resp.Policy if policy.GetIsDefault() == true { d.SetId("") @@ -113,7 +101,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn helper.OrgIDVar: policy.GetDetails().GetResourceOwner(), passwordChangeVar: policy.GetPasswordChange(), } - for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of notification: %v", k, err) diff --git a/zitadel/v2/notification_policy/resource.go b/zitadel/v2/notification_policy/resource.go index c66e1d7d..e3db8751 100644 --- a/zitadel/v2/notification_policy/resource.go +++ b/zitadel/v2/notification_policy/resource.go @@ -2,6 +2,7 @@ package notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/v2/notification_policy/resource_test.go index aba0a64c..edc49f75 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/v2/notification_policy/resource_test.go @@ -24,12 +24,12 @@ func TestAccNotificationPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(true), - nil, nil, "", "", + test_utils.ImportOrgId(frame), ) } diff --git a/zitadel/v2/org/resource.go b/zitadel/v2/org/resource.go index dc7fd00f..ebc42e4b 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/v2/org/resource.go @@ -2,6 +2,7 @@ package org import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/org/resource_test.go b/zitadel/v2/org/resource_test.go index 7c583378..ed86b11b 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/v2/org/resource_test.go @@ -22,12 +22,12 @@ func TestAccOrg(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), initialProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(frame, idFromState(frame)), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, idFromState(frame)), updatedProperty), - nil, nil, "", "", + test_utils.ImportResourceId(frame.BaseTestFrame), ) } diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/v2/org_idp_azure_ad/datasource.go index bb0366c8..58b67aaa 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/v2/org_idp_azure_ad/datasource.go @@ -27,6 +27,5 @@ func GetDatasource() *schema.Resource { idp_azure_ad.EmailVerifiedVar: idp_azure_ad.EmailVerifiedDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/v2/org_idp_azure_ad/resource.go index 52b1d6a2..2039676c 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/v2/org_idp_azure_ad/resource.go @@ -2,8 +2,8 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -31,5 +31,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/v2/org_idp_github/datasource.go index 20181fac..a4d0411a 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/v2/org_idp_github/datasource.go @@ -23,6 +23,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/v2/org_idp_github/resource.go index be860170..3fe1bda7 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/v2/org_idp_github/resource.go @@ -2,8 +2,8 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -27,5 +27,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/v2/org_idp_github_es/datasource.go index b850bbf8..df95536b 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/v2/org_idp_github_es/datasource.go @@ -27,6 +27,5 @@ func GetDatasource() *schema.Resource { idp_github_es.UserEndpointVar: idp_github_es.UserEndpointDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/v2/org_idp_github_es/resource.go index 76bdb9a1..4e7a863b 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/v2/org_idp_github_es/resource.go @@ -2,8 +2,8 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -31,5 +31,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/v2/org_idp_gitlab/datasource.go index f2dd41d1..1ebd258f 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/v2/org_idp_gitlab/datasource.go @@ -23,6 +23,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/v2/org_idp_gitlab/resource.go index ad547f79..e996bba4 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/v2/org_idp_gitlab/resource.go @@ -2,8 +2,8 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -27,5 +27,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go index 2c084aef..aa652cf2 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go @@ -25,6 +25,5 @@ func GetDatasource() *schema.Resource { idp_gitlab_self_hosted.IssuerVar: idp_gitlab_self_hosted.IssuerDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go index caf02f68..97cbad62 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/v2/org_idp_gitlab_self_hosted/resource.go @@ -2,8 +2,8 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -29,5 +29,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/v2/org_idp_google/datasource.go index a954c610..223dcd8d 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/v2/org_idp_google/datasource.go @@ -23,6 +23,5 @@ func GetDatasource() *schema.Resource { idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/v2/org_idp_google/resource.go index 2d7f11b1..a2679001 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/v2/org_idp_google/resource.go @@ -2,8 +2,8 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) @@ -27,5 +27,5 @@ func GetResource() *schema.Resource { CreateContext: create, DeleteContext: org_idp_utils.Delete, Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_jwt/datasource.go b/zitadel/v2/org_idp_jwt/datasource.go index 48ed201a..a0d18746 100644 --- a/zitadel/v2/org_idp_jwt/datasource.go +++ b/zitadel/v2/org_idp_jwt/datasource.go @@ -2,6 +2,7 @@ package org_idp_jwt import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/v2/org_idp_jwt/resource.go index 679c936e..a64f662c 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/v2/org_idp_jwt/resource.go @@ -7,7 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func GetResource() *schema.Resource { @@ -58,6 +58,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrg()}, + Importer: helper.ImportWithIDAndOptionalOrg(idp_utils.IdpIDVar), } } diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/v2/org_idp_jwt/resource_test.go index 69f385fd..78d8e643 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/v2/org_idp_jwt/resource_test.go @@ -27,12 +27,15 @@ func TestAccOrgIDPJWT(t *testing.T) { return strings.Replace(resourceExample, exampleProperty, configProperty, 1) }, exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/v2/org_idp_ldap/datasource.go index 7ecc027a..d7ccb66d 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/v2/org_idp_ldap/datasource.go @@ -45,6 +45,5 @@ func GetDatasource() *schema.Resource { idp_ldap.ProfileAttributeVar: idp_ldap.ProfileAttributeDataSourceField, }, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), -} + } } diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/v2/org_idp_ldap/resource.go index 68ea6160..cec7e2b7 100644 --- a/zitadel/v2/org_idp_ldap/resource.go +++ b/zitadel/v2/org_idp_ldap/resource.go @@ -2,8 +2,8 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" @@ -48,6 +48,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: org_idp_utils.Delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(idp_ldap.BindPasswordVar)}, + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_ldap.BindPasswordVar), } } diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/v2/org_idp_ldap/resource_test.go index 28b82610..bb53d30a 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/v2/org_idp_ldap/resource_test.go @@ -9,5 +9,4 @@ import ( func TestAccOrgIdPLDAP(t *testing.T) { org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_ldap", idp_ldap.BindPasswordVar) - } diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go index f9d8b9b0..2dd5333c 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -2,6 +2,7 @@ package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index 0ba7abb1..cc7c0b3e 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -7,7 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func GetResource() *schema.Resource { @@ -73,6 +73,6 @@ func GetResource() *schema.Resource { UpdateContext: update, CreateContext: create, DeleteContext: delete, - Importer: &schema.ResourceImporter{StateContext: org_idp_utils.ImportIDPWithOrgAndSecret(clientSecretVar)}, + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, clientSecretVar), } } diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go index af6d6579..7cc440b6 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -2,7 +2,6 @@ package org_idp_oidc_test import ( "fmt" - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -12,28 +11,32 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" ) -func TestAccOrgIDPJWT(t *testing.T) { +func TestAccOrgIDPOIDC(t *testing.T) { frame := test_utils.NewOrgTestFrame(t, "zitadel_org_idp_oidc") resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) exampleProperty := test_utils.AttributeValue(t, org_idp_oidc.DisplayNameMappingVar, exampleAttributes).AsString() updatedProperty := idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL.String() + exampleSecret := test_utils.AttributeValue(t, idp_utils.ClientSecretVar, exampleAttributes).AsString() test_utils.RunLifecyleTest( t, frame.BaseTestFrame, []string{frame.AsOrgDefaultDependency}, - func(configProperty, _ string) string { - return strings.Replace(resourceExample, exampleProperty, configProperty, 1) - }, + test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), exampleProperty, updatedProperty, - "", "", + idp_utils.ClientSecretVar, exampleSecret, "an updated secret", true, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, idp_utils.ClientSecretVar), + ), ) } diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/v2/org_idp_utils/funcs.go index 93828379..b3484da4 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/v2/org_idp_utils/funcs.go @@ -2,15 +2,12 @@ package org_idp_utils import ( "context" - "fmt" - "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -28,42 +25,3 @@ func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } return nil } - -func ImportIDPWithOrg() schema.StateContextFunc { - return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) - } - parts := strings.SplitN(id, ":", 2) - if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s", id, helper.OrgIDVar, idp_utils.IdpIDVar) - } - if err := data.Set(helper.OrgIDVar, parts[0]); err != nil { - return nil, err - } - data.SetId(parts[1]) - return []*schema.ResourceData{data}, nil - } -} - -func ImportIDPWithOrgAndSecret(secretVar string) schema.StateContextFunc { - return func(ctx context.Context, data *schema.ResourceData, i interface{}) ([]*schema.ResourceData, error) { - id := data.Id() - if id == "" { - return nil, fmt.Errorf("%s is not set", idp_utils.IdpIDVar) - } - parts := strings.SplitN(id, ":", 3) - if len(parts) != 3 || parts[0] == "" || parts[1] == "" || parts[2] == "" { - return nil, fmt.Errorf("unexpected format of ID (%s), expected %s:%s:%s", id, helper.OrgIDVar, idp_utils.IdpIDVar, secretVar) - } - if err := data.Set(helper.OrgIDVar, parts[0]); err != nil { - return nil, err - } - data.SetId(parts[1]) - if err := data.Set(secretVar, parts[2]); err != nil { - return nil, err - } - return []*schema.ResourceData{data}, nil - } -} diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go index b66cf101..6a68759d 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -1,19 +1,15 @@ package org_idp_test_utils import ( - "fmt" "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { - const importedSecret = "an_imported_secret" frame := test_utils.NewOrgTestFrame(t, resourceName) resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) nameProperty := test_utils.AttributeValue(t, idp_utils.NameVar, exampleAttributes).AsString() @@ -27,24 +23,15 @@ func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), true, false, - exampleSecret, "an_updated_secret", + secretAttribute, exampleSecret, "an_updated_secret", false, CheckCreationAllowed(*frame), helper.ZitadelGeneratedIdOnlyRegex, CheckDestroy(*frame), - func(state *terraform.State) error { - // Check the secretAttribute is imported correctly - actual := frame.State(state).Attributes[secretAttribute] - if actual != importedSecret { - return fmt.Errorf("expected %s to be %s, but got %s", secretAttribute, importedSecret, actual) - } - return nil - }, - func(state *terraform.State) (string, error) { - lastState := frame.State(state) - return fmt.Sprintf("%s:%s:%s", lastState.Attributes[helper.OrgIDVar], lastState.ID, importedSecret), nil - }, - "123:456", - secretAttribute, + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, secretAttribute), + ), ) } diff --git a/zitadel/v2/org_member/const.go b/zitadel/v2/org_member/const.go index 1ccebfa2..18e909f8 100644 --- a/zitadel/v2/org_member/const.go +++ b/zitadel/v2/org_member/const.go @@ -1,6 +1,6 @@ package org_member const ( - userIDVar = "user_id" + UserIDVar = "user_id" RolesVar = "roles" ) diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/v2/org_member/funcs.go index fbc45e54..3de26ba2 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/v2/org_member/funcs.go @@ -27,7 +27,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveOrgMember(ctx, &management.RemoveOrgMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete orgmember: %v", err) @@ -49,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateOrgMember(ctx, &management.UpdateOrgMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), Roles: helper.GetOkSetToStringSlice(d, RolesVar), }) if err != nil { @@ -72,7 +72,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) _, err = client.AddOrgMember(ctx, &management.AddOrgMemberRequest{ UserId: userID, Roles: helper.GetOkSetToStringSlice(d, RolesVar), @@ -97,7 +97,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.ListOrgMembers(ctx, &management.ListOrgMembersRequest{ Queries: []*member.SearchQuery{{ Query: &member.SearchQuery_UserIdQuery{ @@ -118,7 +118,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { orgMember := resp.Result[0] set := map[string]interface{}{ - userIDVar: orgMember.GetUserId(), + UserIDVar: orgMember.GetUserId(), helper.OrgIDVar: orgMember.GetDetails().GetResourceOwner(), RolesVar: orgMember.GetRoles(), } diff --git a/zitadel/v2/org_member/resource.go b/zitadel/v2/org_member/resource.go index dde43c72..a52377f3 100644 --- a/zitadel/v2/org_member/resource.go +++ b/zitadel/v2/org_member/resource.go @@ -2,6 +2,7 @@ package org_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,7 +11,7 @@ func GetResource() *schema.Resource { Description: "Resource representing the membership of a user on an organization, defined with the given role.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -29,6 +30,9 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrg(userIDVar), + Importer: helper.ImportWithEmptyID( + helper.NewImportAttribute(UserIDVar, helper.ConvertID, false), + helper.ImportOptionalOrgAttribute, + ), } } diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/v2/org_member/resource_test.go index 20e98478..1e3cb880 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/v2/org_member/resource_test.go @@ -2,6 +2,7 @@ package org_member_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -27,12 +28,15 @@ func TestAccOrgMember(t *testing.T) { []string{frame.AsOrgDefaultDependency, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(*frame, userID), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf("^%s_%s$", helper.ZitadelGeneratedIdPattern, helper.ZitadelGeneratedIdPattern)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportStateAttribute(frame.BaseTestFrame, org_member.UserIDVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/v2/password_change_message_text/resource.go index 4716faff..ee8d3619 100644 --- a/zitadel/v2/password_change_message_text/resource.go +++ b/zitadel/v2/password_change_message_text/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/v2/password_change_message_text/resource_test.go index 3ea05c6e..3ceb9bd2 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/v2/password_change_message_text/resource_test.go @@ -25,13 +25,13 @@ func TestAccPasswordChangeMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), // When deleted, the default should be returned checkRemoteProperty(frame, exampleLanguage)("ZITADEL - Password of user has changed"), - nil, nil, "", "", "", + nil, ) } diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/v2/password_complexity_policy/funcs.go index a7be8897..d5cf7a71 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/v2/password_complexity_policy/funcs.go @@ -13,18 +13,15 @@ import ( func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.ResetPasswordComplexityPolicyToDefault(ctx, &management.ResetPasswordComplexityPolicyToDefaultRequest{}) if err != nil { return diag.Errorf("failed to reset password complexity policy: %v", err) @@ -34,18 +31,15 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.UpdateCustomPasswordComplexityPolicy(ctx, &management.UpdateCustomPasswordComplexityPolicyRequest{ MinLength: uint64(d.Get(minLengthVar).(int)), HasUppercase: d.Get(hasUppercaseVar).(bool), @@ -61,18 +55,15 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - org := d.Get(helper.OrgIDVar).(string) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - _, err = client.AddCustomPasswordComplexityPolicy(ctx, &management.AddCustomPasswordComplexityPolicyRequest{ MinLength: uint64(d.Get(minLengthVar).(int)), HasUppercase: d.Get(hasUppercaseVar).(bool), @@ -89,18 +80,15 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - org := d.Get(helper.OrgIDVar).(string) + org := helper.GetID(d, helper.OrgIDVar) client, err := helper.GetManagementClient(clientinfo, org) if err != nil { return diag.FromErr(err) } - resp, err := client.GetPasswordComplexityPolicy(ctx, &management.GetPasswordComplexityPolicyRequest{}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") @@ -109,7 +97,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if err != nil { return diag.Errorf("failed to get password complexity policy") } - policy := resp.Policy if policy.GetIsDefault() == true { d.SetId("") @@ -123,7 +110,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn hasNumberVar: policy.GetHasNumber(), hasSymbolVar: policy.GetHasSymbol(), } - for k, v := range set { if err := d.Set(k, v); err != nil { return diag.Errorf("failed to set %s of password complexity policy: %v", k, err) diff --git a/zitadel/v2/password_complexity_policy/resource.go b/zitadel/v2/password_complexity_policy/resource.go index 2903252d..0737a724 100644 --- a/zitadel/v2/password_complexity_policy/resource.go +++ b/zitadel/v2/password_complexity_policy/resource.go @@ -2,6 +2,7 @@ package password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/v2/password_complexity_policy/resource_test.go index 5bdcdc48..596a975c 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/v2/password_complexity_policy/resource_test.go @@ -27,12 +27,12 @@ func TestAccPasswordComplexityPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(exampleProperty), - nil, nil, "", "", + test_utils.ImportOrgId(frame), ) } diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/v2/password_reset_message_text/resource.go index 80a2da1f..a6084d0d 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/v2/password_reset_message_text/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/v2/password_reset_message_text/resource_test.go index 6579e1c5..ff0d5b85 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/v2/password_reset_message_text/resource_test.go @@ -25,7 +25,7 @@ func TestAccPasswordResetMessageText(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(frame, exampleLanguage), regexp.MustCompile(fmt.Sprintf(`^\d{18}_%s$`, exampleLanguage)), diff --git a/zitadel/v2/pat/const.go b/zitadel/v2/pat/const.go index a576a3fe..e637b49a 100644 --- a/zitadel/v2/pat/const.go +++ b/zitadel/v2/pat/const.go @@ -2,7 +2,7 @@ package pat const ( tokenIDVar = "token_id" - userIDVar = "user_id" - tokenVar = "token" + UserIDVar = "user_id" + TokenVar = "token" ExpirationDateVar = "expiration_date" ) diff --git a/zitadel/v2/pat/funcs.go b/zitadel/v2/pat/funcs.go index 4ff8ff52..0868a1b5 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/v2/pat/funcs.go @@ -27,7 +27,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemovePersonalAccessToken(ctx, &management.RemovePersonalAccessTokenRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), TokenId: d.Id(), }) if err != nil { @@ -51,7 +51,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } req := &management.AddPersonalAccessTokenRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), } if expiration, ok := d.GetOk(ExpirationDateVar); ok { t, err := time.Parse(time.RFC3339, expiration.(string)) @@ -66,7 +66,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - if err := d.Set(tokenVar, resp.GetToken()); err != nil { + if err := d.Set(TokenVar, resp.GetToken()); err != nil { return diag.FromErr(err) } d.SetId(resp.GetTokenId()) @@ -86,7 +86,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.GetPersonalAccessTokenByIDs(ctx, &management.GetPersonalAccessTokenByIDsRequest{ UserId: userID, TokenId: d.Id(), @@ -101,7 +101,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn set := map[string]interface{}{ ExpirationDateVar: resp.GetToken().GetExpirationDate().AsTime().Format(time.RFC3339), - userIDVar: userID, + UserIDVar: userID, helper.OrgIDVar: orgID, } for k, v := range set { diff --git a/zitadel/v2/pat/resource.go b/zitadel/v2/pat/resource.go index 0b4cfaef..20247ba9 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/v2/pat/resource.go @@ -2,6 +2,7 @@ package pat import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,13 +11,13 @@ func GetResource() *schema.Resource { Description: "Resource representing a personal access token of a user", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", ForceNew: true, }, - tokenVar: { + TokenVar: { Type: schema.TypeString, Computed: true, Description: "Value of the token", @@ -34,8 +35,8 @@ func GetResource() *schema.Resource { ReadContext: read, Importer: helper.ImportWithIDAndOptionalOrg( tokenIDVar, - helper.NewImportAttribute(userIDVar, helper.ConvertID, false), - helper.NewImportAttribute(tokenVar, helper.ConvertNonEmpty, true), + helper.NewImportAttribute(UserIDVar, helper.ConvertID, false), + helper.NewImportAttribute(TokenVar, helper.ConvertNonEmpty, true), ), } } diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/v2/pat/resource_test.go index e968b229..f13725fc 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/v2/pat/resource_test.go @@ -26,12 +26,17 @@ func TestAccPersonalAccessToken(t *testing.T) { []string{frame.AsOrgDefaultDependency, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame, userID), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, pat.UserIDVar), + test_utils.ImportOrgId(frame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, pat.TokenVar), + ), ) } diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/v2/privacy_policy/resource.go index 52e2f722..ffe7a67b 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/v2/privacy_policy/resource.go @@ -2,6 +2,7 @@ package privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/v2/privacy_policy/resource_test.go index 210d3d60..f8cf18bf 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/v2/privacy_policy/resource_test.go @@ -23,12 +23,12 @@ func TestAccPrivacyPolicy(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "http://example.com/acctest", - "", "", + "", "", "", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, checkRemoteProperty(*frame)(""), - nil, nil, "", "", + test_utils.ImportOrgId(frame), ) } diff --git a/zitadel/v2/project/datasource.go b/zitadel/v2/project/datasource.go index ee215bb0..a2dc974d 100644 --- a/zitadel/v2/project/datasource.go +++ b/zitadel/v2/project/datasource.go @@ -2,6 +2,7 @@ package project import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/project/resource_test.go b/zitadel/v2/project/resource_test.go index d5206bb9..c5b7d8f2 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/v2/project/resource_test.go @@ -24,12 +24,15 @@ func TestAccProject(t *testing.T) { []string{frame.AsOrgDefaultDependency}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame), updatedProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/project_grant/const.go b/zitadel/v2/project_grant/const.go index c146b079..48a55dc4 100644 --- a/zitadel/v2/project_grant/const.go +++ b/zitadel/v2/project_grant/const.go @@ -1,7 +1,7 @@ package project_grant const ( - projectIDVar = "project_id" + ProjectIDVar = "project_id" grantedOrgIDVar = "granted_org_id" RoleKeysVar = "role_keys" ) diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/v2/project_grant/funcs.go index 03762a94..c673b068 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/v2/project_grant/funcs.go @@ -26,7 +26,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.RemoveProjectGrant(ctx, &management.RemoveProjectGrantRequest{ GrantId: d.Id(), - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete projectgrant: %v", err) @@ -49,7 +49,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia _, err = client.UpdateProjectGrant(ctx, &management.UpdateProjectGrantRequest{ GrantId: d.Id(), - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { @@ -73,7 +73,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia resp, err := client.AddProjectGrant(ctx, &management.AddProjectGrantRequest{ GrantedOrgId: d.Get(grantedOrgIDVar).(string), - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), RoleKeys: helper.GetOkSetToStringSlice(d, RoleKeysVar), }) if err != nil { @@ -96,7 +96,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - resp, err := client.GetProjectGrantByID(ctx, &management.GetProjectGrantByIDRequest{ProjectId: d.Get(projectIDVar).(string), GrantId: d.Id()}) + resp, err := client.GetProjectGrantByID(ctx, &management.GetProjectGrantByIDRequest{ProjectId: d.Get(ProjectIDVar).(string), GrantId: d.Id()}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil @@ -107,7 +107,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn projectGrant := resp.GetProjectGrant() set := map[string]interface{}{ - projectIDVar: projectGrant.GetProjectId(), + ProjectIDVar: projectGrant.GetProjectId(), grantedOrgIDVar: projectGrant.GetGrantedOrgId(), RoleKeysVar: projectGrant.GetGrantedRoleKeys(), helper.OrgIDVar: projectGrant.GetDetails().GetResourceOwner(), diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/v2/project_grant/resource.go index b17a1aff..654e543d 100644 --- a/zitadel/v2/project_grant/resource.go +++ b/zitadel/v2/project_grant/resource.go @@ -2,6 +2,7 @@ package project_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,7 +11,7 @@ func GetResource() *schema.Resource { Description: "Resource representing the grant of a project to a different organization, also containing the available roles which can be given to the members of the projectgrant.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", @@ -37,7 +38,7 @@ func GetResource() *schema.Resource { ReadContext: read, Importer: helper.ImportWithIDAndOptionalOrg( "", - helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), ), } } diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/v2/project_grant/resource_test.go index 1a6babd7..4cb2727f 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/v2/project_grant/resource_test.go @@ -30,12 +30,16 @@ func TestAccProjectGrant(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep, grantedOrgDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", false, checkRemoteProperty(*frame, projectID), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_grant.ProjectIDVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/project_grant_member/const.go b/zitadel/v2/project_grant_member/const.go index 77f74c30..ba48b0bb 100644 --- a/zitadel/v2/project_grant_member/const.go +++ b/zitadel/v2/project_grant_member/const.go @@ -1,8 +1,8 @@ package project_grant_member const ( - projectIDVar = "project_id" + ProjectIDVar = "project_id" GrantIDVar = "grant_id" - userIDVar = "user_id" + UserIDVar = "user_id" RolesVar = "roles" ) diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/v2/project_grant_member/funcs.go index 548c4470..16e62d04 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/v2/project_grant_member/funcs.go @@ -26,8 +26,8 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveProjectGrantMember(ctx, &management.RemoveProjectGrantMemberRequest{ - UserId: d.Get(userIDVar).(string), - ProjectId: d.Get(projectIDVar).(string), + UserId: d.Get(UserIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), GrantId: d.Get(GrantIDVar).(string), }) if err != nil { @@ -50,9 +50,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateProjectGrantMember(ctx, &management.UpdateProjectGrantMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), Roles: helper.GetOkSetToStringSlice(d, RolesVar), - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), GrantId: d.Get(GrantIDVar).(string), }) if err != nil { @@ -75,8 +75,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) - projectID := d.Get(projectIDVar).(string) + userID := d.Get(UserIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) grantID := d.Get(GrantIDVar).(string) _, err = client.AddProjectGrantMember(ctx, &management.AddProjectGrantMemberRequest{ UserId: userID, @@ -104,9 +104,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) grantID := d.Get(GrantIDVar).(string) - userID := d.Get(userIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.ListProjectGrantMembers(ctx, &management.ListProjectGrantMembersRequest{ ProjectId: projectID, GrantId: grantID, @@ -129,9 +129,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { memberRes := resp.Result[0] set := map[string]interface{}{ - userIDVar: userID, + UserIDVar: userID, helper.OrgIDVar: org, - projectIDVar: projectID, + ProjectIDVar: projectID, RolesVar: memberRes.GetRoles(), GrantIDVar: grantID, } diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/v2/project_grant_member/resource.go index b4f1fce7..908a4cf1 100644 --- a/zitadel/v2/project_grant_member/resource.go +++ b/zitadel/v2/project_grant_member/resource.go @@ -2,6 +2,7 @@ package project_grant_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,7 +11,7 @@ func GetResource() *schema.Resource { Description: "Resource representing the membership of a user on an granted project, defined with the given role.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", @@ -22,7 +23,7 @@ func GetResource() *schema.Resource { Description: "ID of the grant", ForceNew: true, }, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -43,9 +44,9 @@ func GetResource() *schema.Resource { ReadContext: read, Importer: helper.ImportWithEmptyID( helper.ImportOptionalOrgAttribute, - helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), helper.NewImportAttribute(GrantIDVar, helper.ConvertID, false), - helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + helper.NewImportAttribute(UserIDVar, helper.ConvertID, false), ), } } diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/v2/project_grant_member/resource_test.go index 590ee29e..49d878cb 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/v2/project_grant_member/resource_test.go @@ -2,6 +2,7 @@ package project_grant_member_test import ( "fmt" + "regexp" "strings" "testing" @@ -35,12 +36,23 @@ func TestAccProjectGrantMember(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "PROJECT_GRANT_OWNER_VIEWER", - "", "", + "", "", "", true, checkRemoteProperty(*frame, projectID, grantID, userID), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf( + "^%s_%s_%s_%s$", + helper.ZitadelGeneratedIdPattern, + helper.ZitadelGeneratedIdPattern, + helper.ZitadelGeneratedIdPattern, + helper.ZitadelGeneratedIdPattern, + )), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, grantID, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_grant_member.ProjectIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_grant_member.GrantIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_grant_member.UserIDVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/project_member/const.go b/zitadel/v2/project_member/const.go index 18ba11dd..a2fb16c0 100644 --- a/zitadel/v2/project_member/const.go +++ b/zitadel/v2/project_member/const.go @@ -1,7 +1,7 @@ package project_member const ( - projectIDVar = "project_id" - userIDVar = "user_id" + ProjectIDVar = "project_id" + UserIDVar = "user_id" rolesVar = "roles" ) diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/v2/project_member/funcs.go index 26e0c689..5272ec6b 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/v2/project_member/funcs.go @@ -26,8 +26,8 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveProjectMember(ctx, &management.RemoveProjectMemberRequest{ - UserId: d.Get(userIDVar).(string), - ProjectId: d.Get(projectIDVar).(string), + UserId: d.Get(UserIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), }) if err != nil { return diag.Errorf("failed to delete projectmember: %v", err) @@ -49,9 +49,9 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateProjectMember(ctx, &management.UpdateProjectMemberRequest{ - UserId: d.Get(userIDVar).(string), + UserId: d.Get(UserIDVar).(string), Roles: helper.GetOkSetToStringSlice(d, rolesVar), - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), }) if err != nil { return diag.Errorf("failed to update projectmember: %v", err) @@ -73,8 +73,8 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - userID := d.Get(userIDVar).(string) - projectID := d.Get(projectIDVar).(string) + userID := d.Get(UserIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) _, err = client.AddProjectMember(ctx, &management.AddProjectMemberRequest{ UserId: userID, ProjectId: projectID, @@ -100,8 +100,8 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) - userID := d.Get(userIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) + userID := d.Get(UserIDVar).(string) resp, err := client.ListProjectMembers(ctx, &management.ListProjectMembersRequest{ ProjectId: projectID, Queries: []*member.SearchQuery{{ @@ -123,9 +123,9 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn if len(resp.Result) == 1 { memberRes := resp.Result[0] set := map[string]interface{}{ - userIDVar: memberRes.GetUserId(), + UserIDVar: memberRes.GetUserId(), helper.OrgIDVar: memberRes.GetDetails().GetResourceOwner(), - projectIDVar: projectID, + ProjectIDVar: projectID, rolesVar: memberRes.GetRoles(), } for k, v := range set { diff --git a/zitadel/v2/project_member/resource.go b/zitadel/v2/project_member/resource.go index 54842151..23f02e8d 100644 --- a/zitadel/v2/project_member/resource.go +++ b/zitadel/v2/project_member/resource.go @@ -2,6 +2,7 @@ package project_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,13 +11,13 @@ func GetResource() *schema.Resource { Description: "Resource representing the membership of a user on an project, defined with the given role.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", ForceNew: true, }, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -36,8 +37,8 @@ func GetResource() *schema.Resource { UpdateContext: update, ReadContext: read, Importer: helper.ImportWithEmptyID( - helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), - helper.NewImportAttribute(userIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(UserIDVar, helper.ConvertID, false), helper.ImportOptionalOrgAttribute, ), } diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/v2/project_member/resource_test.go index c7e2da5a..d7f16c7e 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/v2/project_member/resource_test.go @@ -2,6 +2,7 @@ package project_member_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -14,6 +15,7 @@ import ( "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" ) func TestAccProjectMember(t *testing.T) { @@ -28,12 +30,16 @@ func TestAccProjectMember(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, "PROJECT_OWNER_VIEWER", - "", "", + "", "", "", true, checkRemoteProperty(*frame, projectID, userID), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf("^%s_%s_%s$", helper.ZitadelGeneratedIdPattern, helper.ZitadelGeneratedIdPattern, helper.ZitadelGeneratedIdPattern)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_member.ProjectIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_member.UserIDVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/project_role/const.go b/zitadel/v2/project_role/const.go index 0d95e2ee..d121383b 100644 --- a/zitadel/v2/project_role/const.go +++ b/zitadel/v2/project_role/const.go @@ -1,7 +1,7 @@ package project_role const ( - projectIDVar = "project_id" + ProjectIDVar = "project_id" KeyVar = "role_key" displayNameVar = "display_name" groupVar = "group" diff --git a/zitadel/v2/project_role/datasource.go b/zitadel/v2/project_role/datasource.go index f3599c4a..34adf292 100644 --- a/zitadel/v2/project_role/datasource.go +++ b/zitadel/v2/project_role/datasource.go @@ -2,6 +2,7 @@ package project_role import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -9,7 +10,7 @@ func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing the project roles, which can be given as authorizations to users.", Schema: map[string]*schema.Schema{ - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/v2/project_role/funcs.go index b0a445f4..5adbdc44 100644 --- a/zitadel/v2/project_role/funcs.go +++ b/zitadel/v2/project_role/funcs.go @@ -27,7 +27,7 @@ func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.RemoveProjectRole(ctx, &management.RemoveProjectRoleRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), RoleKey: d.Get(KeyVar).(string), }) if err != nil { @@ -50,7 +50,7 @@ func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia } _, err = client.UpdateProjectRole(ctx, &management.UpdateProjectRoleRequest{ - ProjectId: d.Get(projectIDVar).(string), + ProjectId: d.Get(ProjectIDVar).(string), RoleKey: d.Get(KeyVar).(string), DisplayName: d.Get(displayNameVar).(string), Group: d.Get(groupVar).(string), @@ -76,7 +76,7 @@ func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Dia return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) roleKey := d.Get(KeyVar).(string) _, err = client.AddProjectRole(ctx, &management.AddProjectRoleRequest{ ProjectId: projectID, @@ -106,7 +106,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn return diag.FromErr(err) } - projectID := d.Get(projectIDVar).(string) + projectID := d.Get(ProjectIDVar).(string) resp, err := client.ListProjectRoles(ctx, &management.ListProjectRolesRequest{ ProjectId: projectID, Queries: []*project2.RoleQuery{ @@ -127,7 +127,7 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn projectRole := resp.GetResult()[0] roleKey := projectRole.GetKey() set := map[string]interface{}{ - projectIDVar: projectID, + ProjectIDVar: projectID, helper.OrgIDVar: orgID, KeyVar: roleKey, displayNameVar: projectRole.GetDisplayName(), diff --git a/zitadel/v2/project_role/resource.go b/zitadel/v2/project_role/resource.go index cfd60b79..dcc7cc21 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/v2/project_role/resource.go @@ -2,6 +2,7 @@ package project_role import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -10,7 +11,7 @@ func GetResource() *schema.Resource { Description: "Resource representing the project roles, which can be given as authorizations to users.", Schema: map[string]*schema.Schema{ helper.OrgIDVar: helper.OrgIDResourceField, - projectIDVar: { + ProjectIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the project", @@ -38,7 +39,7 @@ func GetResource() *schema.Resource { UpdateContext: update, ReadContext: read, Importer: helper.ImportWithEmptyID( - helper.NewImportAttribute(projectIDVar, helper.ConvertID, false), + helper.NewImportAttribute(ProjectIDVar, helper.ConvertID, false), helper.NewImportAttribute(KeyVar, helper.ConvertNonEmpty, false), helper.ImportOptionalOrgAttribute, ), diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/v2/project_role/resource_test.go index e59806b5..369ccd5c 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/v2/project_role/resource_test.go @@ -2,6 +2,7 @@ package project_role_test import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -19,19 +20,24 @@ func TestAccProjectRole(t *testing.T) { frame := test_utils.NewOrgTestFrame(t, "zitadel_project_role") resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) exampleProperty := test_utils.AttributeValue(t, project_role.KeyVar, exampleAttributes).AsString() + updatedProperty := "updatedProperty" projectDep, projectID := project_test_dep.Create(t, frame) test_utils.RunLifecyleTest( t, frame.BaseTestFrame, []string{frame.AsOrgDefaultDependency, projectDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), - exampleProperty, "updatedProperty", - "", "", + exampleProperty, updatedProperty, + "", "", "", true, checkRemoteProperty(*frame, projectID), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf("^%s_%s_(%s|%s)$", helper.ZitadelGeneratedIdPattern, helper.ZitadelGeneratedIdPattern, exampleProperty, updatedProperty)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, projectID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_role.ProjectIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, project_role.KeyVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/v2/sms_provider_twilio/resource.go index 20d70162..cb204ad4 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/v2/sms_provider_twilio/resource.go @@ -2,6 +2,7 @@ package sms_provider_twilio import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/v2/sms_provider_twilio/resource_test.go index b53835e4..cf1e0564 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/v2/sms_provider_twilio/resource_test.go @@ -24,12 +24,15 @@ func TestAccSMSProviderTwilio(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), exampleProperty, "987654321", - exampleSecret, "updatedSecret", + sms_provider_twilio.TokenVar, exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", sms_provider_twilio.TokenVar, + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, sms_provider_twilio.TokenVar), + ), ) } diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/v2/smtp_config/resource.go index ecac8659..78723221 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/v2/smtp_config/resource.go @@ -2,6 +2,7 @@ package smtp_config import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/v2/smtp_config/resource_test.go index fdabf7e2..ae54cb63 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/v2/smtp_config/resource_test.go @@ -33,12 +33,12 @@ func TestAccSMTPConfig(t *testing.T) { nil, test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), exampleProperty, "updatedProperty", - exampleSecret, "updatedSecret", + smtp_config.PasswordVar, exampleSecret, "updatedSecret", false, checkRemoteProperty(*frame), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckNothing, - nil, nil, "", smtp_config.PasswordVar, + test_utils.ImportStateAttribute(frame.BaseTestFrame, smtp_config.PasswordVar), ) } diff --git a/zitadel/v2/trigger_actions/datasource.go b/zitadel/v2/trigger_actions/datasource.go index 8d8a8b05..cce4919b 100644 --- a/zitadel/v2/trigger_actions/datasource.go +++ b/zitadel/v2/trigger_actions/datasource.go @@ -2,6 +2,7 @@ package trigger_actions import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/v2/trigger_actions/resource_test.go index 36fad075..16401c91 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/v2/trigger_actions/resource_test.go @@ -2,6 +2,7 @@ package trigger_actions_test import ( "fmt" + "regexp" "strconv" "testing" @@ -21,18 +22,23 @@ func TestAccTriggerActions(t *testing.T) { exampleProperty := test_utils.AttributeValue(t, trigger_actions.TriggerTypeVar, exampleAttributes).AsString() flowType := test_utils.AttributeValue(t, trigger_actions.FlowTypeVar, exampleAttributes).AsString() actionDep, _ := action_test_dep.Create(t, frame) + updatedProperty := "TRIGGER_TYPE_PRE_USERINFO_CREATION" test_utils.RunLifecyleTest( t, frame.BaseTestFrame, []string{frame.AsOrgDefaultDependency, actionDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), - exampleProperty, "TRIGGER_TYPE_PRE_USERINFO_CREATION", - "", "", + exampleProperty, updatedProperty, + "", "", "", false, checkRemoteProperty(*frame, flowType), - helper.ZitadelGeneratedIdOnlyRegex, + regexp.MustCompile(fmt.Sprintf("^%s_([A-Z_]+)_(%s|%s)$", helper.ZitadelGeneratedIdPattern, exampleProperty, updatedProperty)), test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, flowType), exampleProperty), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportStateAttribute(frame.BaseTestFrame, trigger_actions.FlowTypeVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, trigger_actions.TriggerTypeVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/user_grant/const.go b/zitadel/v2/user_grant/const.go index a170e567..53b377e1 100644 --- a/zitadel/v2/user_grant/const.go +++ b/zitadel/v2/user_grant/const.go @@ -4,6 +4,6 @@ const ( grantIDVar = "grant_id" projectIDVar = "project_id" projectGrantIDVar = "project_grant_id" - userIDVar = "user_id" + UserIDVar = "user_id" RoleKeysVar = "role_keys" ) diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/v2/user_grant/resource.go index bb5cc8f8..474a4461 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/v2/user_grant/resource.go @@ -2,6 +2,7 @@ package user_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) @@ -22,7 +23,7 @@ func GetResource() *schema.Resource { Description: "ID of the granted project", ForceNew: true, }, - userIDVar: { + UserIDVar: { Type: schema.TypeString, Required: true, Description: "ID of the user", @@ -41,6 +42,6 @@ func GetResource() *schema.Resource { CreateContext: create, UpdateContext: update, ReadContext: read, - Importer: helper.ImportWithIDAndOptionalOrg(grantIDVar, helper.NewImportAttribute(userIDVar, helper.ConvertID, false)), + Importer: helper.ImportWithIDAndOptionalOrg(grantIDVar, helper.NewImportAttribute(UserIDVar, helper.ConvertID, false)), } } diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/v2/user_grant/resource_test.go index 88624ab4..77bf4601 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/v2/user_grant/resource_test.go @@ -30,12 +30,16 @@ func TestAccUserGrant(t *testing.T) { []string{frame.AsOrgDefaultDependency, projectDep, userDep}, test_utils.ReplaceAll(resourceExample, exampleProperty, ""), exampleProperty, updatedProperty, - "", "", + "", "", "", true, checkRemoteProperty(*frame, userID), helper.ZitadelGeneratedIdOnlyRegex, test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame, userID), ""), - nil, nil, "", "", + test_utils.ChainImportStateIdFuncs( + test_utils.ImportResourceId(frame.BaseTestFrame), + test_utils.ImportStateAttribute(frame.BaseTestFrame, user_grant.UserIDVar), + test_utils.ImportOrgId(frame), + ), ) } diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/v2/verify_email_message_text/resource.go index 4e344880..3cf3242c 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/v2/verify_email_message_text/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/v2/verify_phone_message_text/resource.go index ed9f052d..dbd75af7 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/v2/verify_phone_message_text/resource.go @@ -4,8 +4,6 @@ import ( "context" "strings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -17,6 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) const ( From 7f517be216b0944bbd8a1050e392aca1028b7307 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 22 Aug 2023 14:02:15 +0200 Subject: [PATCH 244/260] document importing --- templates/data-sources/idp_azure_ad.md.tmpl | 8 -------- templates/data-sources/idp_github.md.tmpl | 8 -------- templates/data-sources/idp_github_es.md.tmpl | 8 -------- templates/data-sources/idp_gitlab.md.tmpl | 8 -------- .../data-sources/idp_gitlab_self_hosted.md.tmpl | 8 -------- templates/data-sources/idp_google.md.tmpl | 8 -------- templates/data-sources/idp_ldap.md.tmpl | 8 -------- templates/data-sources/org_idp_azure_ad.md.tmpl | 8 -------- templates/data-sources/org_idp_github.md.tmpl | 8 -------- templates/data-sources/org_idp_github_es.md.tmpl | 8 -------- templates/data-sources/org_idp_gitlab.md.tmpl | 8 -------- .../data-sources/org_idp_gitlab_self_hosted.md.tmpl | 8 -------- templates/data-sources/org_idp_google.md.tmpl | 8 -------- templates/data-sources/org_idp_ldap.md.tmpl | 8 -------- templates/resources/action.md.tmpl | 12 +++++++++++- templates/resources/application_api.md.tmpl | 12 +++++++++++- templates/resources/application_key.md.tmpl | 12 +++++++++++- templates/resources/application_oidc.md.tmpl | 12 +++++++++++- templates/resources/default_domain_policy.md.tmpl | 12 +++++++++++- templates/resources/default_label_policy.md.tmpl | 12 +++++++++++- templates/resources/default_lockout_policy.md.tmpl | 12 +++++++++++- templates/resources/default_login_policy.md.tmpl | 12 +++++++++++- .../resources/default_notification_policy.md.tmpl | 12 +++++++++++- .../default_password_complexity_policy.md.tmpl | 12 +++++++++++- templates/resources/default_privacy_policy.md.tmpl | 12 +++++++++++- templates/resources/domain.md.tmpl | 12 +++++++++++- templates/resources/domain_policy.md.tmpl | 12 +++++++++++- templates/resources/human_user.md.tmpl | 12 +++++++++++- templates/resources/idp_azure_ad.md.tmpl | 10 ++++++++++ templates/resources/idp_github.md.tmpl | 10 ++++++++++ templates/resources/idp_github_es.md.tmpl | 10 ++++++++++ templates/resources/idp_gitlab.md.tmpl | 10 ++++++++++ templates/resources/idp_gitlab_self_hosted.md.tmpl | 10 ++++++++++ templates/resources/idp_google.md.tmpl | 10 ++++++++++ templates/resources/idp_ldap.md.tmpl | 10 ++++++++++ templates/resources/instance_member.md.tmpl | 12 +++++++++++- templates/resources/label_policy.md.tmpl | 12 +++++++++++- templates/resources/lockout_policy.md.tmpl | 12 +++++++++++- templates/resources/login_policy.md.tmpl | 12 +++++++++++- templates/resources/machine_key.md.tmpl | 12 +++++++++++- templates/resources/machine_user.md.tmpl | 12 +++++++++++- templates/resources/notification_policy.md.tmpl | 12 +++++++++++- templates/resources/org.md.tmpl | 12 +++++++++++- templates/resources/org_idp_azure_ad.md.tmpl | 10 ++++++++++ templates/resources/org_idp_github.md.tmpl | 10 ++++++++++ templates/resources/org_idp_github_es.md.tmpl | 12 ++++++++++++ templates/resources/org_idp_gitlab.md.tmpl | 10 ++++++++++ .../resources/org_idp_gitlab_self_hosted.md.tmpl | 10 ++++++++++ templates/resources/org_idp_google.md.tmpl | 10 ++++++++++ templates/resources/org_idp_jwt.md.tmpl | 12 +++++++++++- templates/resources/org_idp_ldap.md.tmpl | 10 ++++++++++ templates/resources/org_idp_oidc.md.tmpl | 12 +++++++++++- templates/resources/org_member.md.tmpl | 12 +++++++++++- templates/resources/personal_access_token.md.tmpl | 12 +++++++++++- templates/resources/privacy_policy.md.tmpl | 12 +++++++++++- templates/resources/project.md.tmpl | 12 +++++++++++- templates/resources/project_grant.md.tmpl | 12 +++++++++++- templates/resources/project_grant_member.md.tmpl | 12 +++++++++++- templates/resources/project_member.md.tmpl | 12 +++++++++++- templates/resources/project_role.md.tmpl | 12 +++++++++++- templates/resources/sms_provider_twilio.md.tmpl | 12 +++++++++++- templates/resources/smtp_config.md.tmpl | 12 +++++++++++- templates/resources/trigger_actions.md.tmpl | 12 +++++++++++- templates/resources/user_grant.md.tmpl | 12 +++++++++++- 64 files changed, 538 insertions(+), 148 deletions(-) diff --git a/templates/data-sources/idp_azure_ad.md.tmpl b/templates/data-sources/idp_azure_ad.md.tmpl index ff8f9b47..0aaf0c0d 100644 --- a/templates/data-sources/idp_azure_ad.md.tmpl +++ b/templates/data-sources/idp_azure_ad.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_github.md.tmpl b/templates/data-sources/idp_github.md.tmpl index 16f0accc..94baab8e 100644 --- a/templates/data-sources/idp_github.md.tmpl +++ b/templates/data-sources/idp_github.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_github_es.md.tmpl b/templates/data-sources/idp_github_es.md.tmpl index 0a039ecf..2f07f6b3 100644 --- a/templates/data-sources/idp_github_es.md.tmpl +++ b/templates/data-sources/idp_github_es.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_gitlab.md.tmpl b/templates/data-sources/idp_gitlab.md.tmpl index bcd296f8..48bdafc4 100644 --- a/templates/data-sources/idp_gitlab.md.tmpl +++ b/templates/data-sources/idp_gitlab.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl index 168464ac..8475746d 100644 --- a/templates/data-sources/idp_gitlab_self_hosted.md.tmpl +++ b/templates/data-sources/idp_gitlab_self_hosted.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_google.md.tmpl b/templates/data-sources/idp_google.md.tmpl index b3299fda..dde90fce 100644 --- a/templates/data-sources/idp_google.md.tmpl +++ b/templates/data-sources/idp_google.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/idp_ldap.md.tmpl b/templates/data-sources/idp_ldap.md.tmpl index 698fb77a..362dd199 100644 --- a/templates/data-sources/idp_ldap.md.tmpl +++ b/templates/data-sources/idp_ldap.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs bind_password. - -``` -terraform import {{.Name}} 210210971312980331:mybindpassword -``` diff --git a/templates/data-sources/org_idp_azure_ad.md.tmpl b/templates/data-sources/org_idp_azure_ad.md.tmpl index 42628fb3..90084566 100644 --- a/templates/data-sources/org_idp_azure_ad.md.tmpl +++ b/templates/data-sources/org_idp_azure_ad.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_github.md.tmpl b/templates/data-sources/org_idp_github.md.tmpl index 8d4a5329..245ccbc9 100644 --- a/templates/data-sources/org_idp_github.md.tmpl +++ b/templates/data-sources/org_idp_github.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_github_es.md.tmpl b/templates/data-sources/org_idp_github_es.md.tmpl index 88d13bc3..c75102e7 100644 --- a/templates/data-sources/org_idp_github_es.md.tmpl +++ b/templates/data-sources/org_idp_github_es.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_gitlab.md.tmpl b/templates/data-sources/org_idp_gitlab.md.tmpl index cc03d0f1..570d85b2 100644 --- a/templates/data-sources/org_idp_gitlab.md.tmpl +++ b/templates/data-sources/org_idp_gitlab.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl index 086534ac..58f3624b 100644 --- a/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl +++ b/templates/data-sources/org_idp_gitlab_self_hosted.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_google.md.tmpl b/templates/data-sources/org_idp_google.md.tmpl index 13e21bd1..a7c65747 100644 --- a/templates/data-sources/org_idp_google.md.tmpl +++ b/templates/data-sources/org_idp_google.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/templates/data-sources/org_idp_ldap.md.tmpl b/templates/data-sources/org_idp_ldap.md.tmpl index 0a7ea503..832967e7 100644 --- a/templates/data-sources/org_idp_ldap.md.tmpl +++ b/templates/data-sources/org_idp_ldap.md.tmpl @@ -14,11 +14,3 @@ description: |- {{ tffile "examples/provider/data-sources/org_idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs bind_password. - -``` -terraform import {{.Name}} 210148218065912171:210210971312980331:mybindpassword -``` diff --git a/templates/resources/action.md.tmpl b/templates/resources/action.md.tmpl index 74d933cd..0759e038 100644 --- a/templates/resources/action.md.tmpl +++ b/templates/resources/action.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/action.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/application_api.md.tmpl b/templates/resources/application_api.md.tmpl index dd0a9973..1fb8c6cd 100644 --- a/templates/resources/application_api.md.tmpl +++ b/templates/resources/application_api.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/application_api.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index 26b4ce7e..29f24c6a 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -11,6 +11,16 @@ description: |- ## Example Usage -{{ tffile "examples/provider/resources/application_key.tf" }} +{{ tffile "examples/provider/resources/app_key.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678:import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/application_oidc.md.tmpl b/templates/resources/application_oidc.md.tmpl index 40d3d2e5..44fc22ea 100644 --- a/templates/resources/application_oidc.md.tmpl +++ b/templates/resources/application_oidc.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/application_oidc.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_domain_policy.md.tmpl b/templates/resources/default_domain_policy.md.tmpl index d8ad471c..9a63d64c 100644 --- a/templates/resources/default_domain_policy.md.tmpl +++ b/templates/resources/default_domain_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_domain_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_label_policy.md.tmpl b/templates/resources/default_label_policy.md.tmpl index d832b0ec..f1a114fc 100644 --- a/templates/resources/default_label_policy.md.tmpl +++ b/templates/resources/default_label_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_label_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_lockout_policy.md.tmpl b/templates/resources/default_lockout_policy.md.tmpl index e04a9d63..3219519f 100644 --- a/templates/resources/default_lockout_policy.md.tmpl +++ b/templates/resources/default_lockout_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_lockout_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_login_policy.md.tmpl b/templates/resources/default_login_policy.md.tmpl index 70f68c57..398acd06 100644 --- a/templates/resources/default_login_policy.md.tmpl +++ b/templates/resources/default_login_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_login_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_notification_policy.md.tmpl b/templates/resources/default_notification_policy.md.tmpl index b05a01d0..d755419f 100644 --- a/templates/resources/default_notification_policy.md.tmpl +++ b/templates/resources/default_notification_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_notification_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_password_complexity_policy.md.tmpl b/templates/resources/default_password_complexity_policy.md.tmpl index 94483dd0..591c7f67 100644 --- a/templates/resources/default_password_complexity_policy.md.tmpl +++ b/templates/resources/default_password_complexity_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_password_complexity_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/default_privacy_policy.md.tmpl b/templates/resources/default_privacy_policy.md.tmpl index 1159b409..7cc68c92 100644 --- a/templates/resources/default_privacy_policy.md.tmpl +++ b/templates/resources/default_privacy_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/default_privacy_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import {{ .Name }}.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/domain.md.tmpl b/templates/resources/domain.md.tmpl index 07cb8624..8bac659f 100644 --- a/templates/resources/domain.md.tmpl +++ b/templates/resources/domain.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/domain.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `name[:org_id]`, e.g. + +```bash +terraform import {{ .Name }}.imported 'example.com:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/domain_policy.md.tmpl b/templates/resources/domain_policy.md.tmpl index 252f3ebd..b4c9d1b3 100644 --- a/templates/resources/domain_policy.md.tmpl +++ b/templates/resources/domain_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/domain_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/human_user.md.tmpl b/templates/resources/human_user.md.tmpl index 4dbdefcc..e1c43a27 100644 --- a/templates/resources/human_user.md.tmpl +++ b/templates/resources/human_user.md.tmpl @@ -15,4 +15,14 @@ description: |- {{ tffile "examples/provider/resources/human_user.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:Password1!' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_azure_ad.md.tmpl b/templates/resources/idp_azure_ad.md.tmpl index 43de3de7..d1805d9a 100644 --- a/templates/resources/idp_azure_ad.md.tmpl +++ b/templates/resources/idp_azure_ad.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:12345678-1234-1234-1234-123456789012' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_github.md.tmpl b/templates/resources/idp_github.md.tmpl index d75e98b3..b79f49cc 100644 --- a/templates/resources/idp_github.md.tmpl +++ b/templates/resources/idp_github.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_github_es.md.tmpl b/templates/resources/idp_github_es.md.tmpl index 2640893a..15516d9f 100644 --- a/templates/resources/idp_github_es.md.tmpl +++ b/templates/resources/idp_github_es.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_gitlab.md.tmpl b/templates/resources/idp_gitlab.md.tmpl index a796bb07..d419a492 100644 --- a/templates/resources/idp_gitlab.md.tmpl +++ b/templates/resources/idp_gitlab.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_gitlab_self_hosted.md.tmpl b/templates/resources/idp_gitlab_self_hosted.md.tmpl index a3a5cecd..79e69b4b 100644 --- a/templates/resources/idp_gitlab_self_hosted.md.tmpl +++ b/templates/resources/idp_gitlab_self_hosted.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_google.md.tmpl b/templates/resources/idp_google.md.tmpl index e9d3574d..56618e6e 100644 --- a/templates/resources/idp_google.md.tmpl +++ b/templates/resources/idp_google.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:G1234567890123' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/idp_ldap.md.tmpl b/templates/resources/idp_ldap.md.tmpl index 3b655dbb..4c2f0c1d 100644 --- a/templates/resources/idp_ldap.md.tmpl +++ b/templates/resources/idp_ldap.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:b1nd_p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/instance_member.md.tmpl b/templates/resources/instance_member.md.tmpl index 9a8b83ed..1ac0abf4 100644 --- a/templates/resources/instance_member.md.tmpl +++ b/templates/resources/instance_member.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/instance_member.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/label_policy.md.tmpl b/templates/resources/label_policy.md.tmpl index 0e397709..d14744a9 100644 --- a/templates/resources/label_policy.md.tmpl +++ b/templates/resources/label_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/label_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/lockout_policy.md.tmpl b/templates/resources/lockout_policy.md.tmpl index 201466f6..1b576a60 100644 --- a/templates/resources/lockout_policy.md.tmpl +++ b/templates/resources/lockout_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/lockout_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/login_policy.md.tmpl b/templates/resources/login_policy.md.tmpl index 9cf97c1b..e3329458 100644 --- a/templates/resources/login_policy.md.tmpl +++ b/templates/resources/login_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/login_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/machine_key.md.tmpl b/templates/resources/machine_key.md.tmpl index 3c99ef02..595b7ed5 100644 --- a/templates/resources/machine_key.md.tmpl +++ b/templates/resources/machine_key.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/machine_key.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/machine_user.md.tmpl b/templates/resources/machine_user.md.tmpl index 2d747b76..f082b6cb 100644 --- a/templates/resources/machine_user.md.tmpl +++ b/templates/resources/machine_user.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/machine_user.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/notification_policy.md.tmpl b/templates/resources/notification_policy.md.tmpl index a0f6b6c2..423e8ff9 100644 --- a/templates/resources/notification_policy.md.tmpl +++ b/templates/resources/notification_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/notification_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org.md.tmpl b/templates/resources/org.md.tmpl index 84e4f17b..1096f548 100644 --- a/templates/resources/org.md.tmpl +++ b/templates/resources/org.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/org.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_azure_ad.md.tmpl b/templates/resources/org_idp_azure_ad.md.tmpl index 7a690c29..d02d18c2 100644 --- a/templates/resources/org_idp_azure_ad.md.tmpl +++ b/templates/resources/org_idp_azure_ad.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_azure_ad.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_github.md.tmpl b/templates/resources/org_idp_github.md.tmpl index 2caaa886..6491a017 100644 --- a/templates/resources/org_idp_github.md.tmpl +++ b/templates/resources/org_idp_github.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_github.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_github_es.md.tmpl b/templates/resources/org_idp_github_es.md.tmpl index d759d9c3..c58ae2d1 100644 --- a/templates/resources/org_idp_github_es.md.tmpl +++ b/templates/resources/org_idp_github_es.md.tmpl @@ -14,3 +14,15 @@ description: |- {{ tffile "examples/provider/resources/org_idp_github_es.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +``` + +If you don't have the configuration file yet, [you can generate it](https://developer.hashicorp.com/terraform/language/import/generating-configuration). + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_gitlab.md.tmpl b/templates/resources/org_idp_gitlab.md.tmpl index deed4ae5..e0a437b9 100644 --- a/templates/resources/org_idp_gitlab.md.tmpl +++ b/templates/resources/org_idp_gitlab.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_gitlab.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_gitlab_self_hosted.md.tmpl b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl index 331a1350..1e7b21a6 100644 --- a/templates/resources/org_idp_gitlab_self_hosted.md.tmpl +++ b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_gitlab_self_hosted.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_google.md.tmpl b/templates/resources/org_idp_google.md.tmpl index 2e92ca59..00ee18c8 100644 --- a/templates/resources/org_idp_google.md.tmpl +++ b/templates/resources/org_idp_google.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_google.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:G1234567890123' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_jwt.md.tmpl b/templates/resources/org_idp_jwt.md.tmpl index aa06ec8c..f60bd5dd 100644 --- a/templates/resources/org_idp_jwt.md.tmpl +++ b/templates/resources/org_idp_jwt.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/org_idp_jwt.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_ldap.md.tmpl b/templates/resources/org_idp_ldap.md.tmpl index f5f06697..f9c0dada 100644 --- a/templates/resources/org_idp_ldap.md.tmpl +++ b/templates/resources/org_idp_ldap.md.tmpl @@ -14,3 +14,13 @@ description: |- {{ tffile "examples/provider/resources/org_idp_ldap.tf" }} {{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_idp_oidc.md.tmpl b/templates/resources/org_idp_oidc.md.tmpl index ac2b1616..abdb7b2a 100644 --- a/templates/resources/org_idp_oidc.md.tmpl +++ b/templates/resources/org_idp_oidc.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/org_idp_oidc.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/org_member.md.tmpl b/templates/resources/org_member.md.tmpl index f10ecd05..7a802c86 100644 --- a/templates/resources/org_member.md.tmpl +++ b/templates/resources/org_member.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/org_member.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/personal_access_token.md.tmpl b/templates/resources/personal_access_token.md.tmpl index c2334ff0..7e14854e 100644 --- a/templates/resources/personal_access_token.md.tmpl +++ b/templates/resources/personal_access_token.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/personal_access_token.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/privacy_policy.md.tmpl b/templates/resources/privacy_policy.md.tmpl index cb607535..e68ccef8 100644 --- a/templates/resources/privacy_policy.md.tmpl +++ b/templates/resources/privacy_policy.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/privacy_policy.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/project.md.tmpl b/templates/resources/project.md.tmpl index a913694e..56a1be51 100644 --- a/templates/resources/project.md.tmpl +++ b/templates/resources/project.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/project.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/project_grant.md.tmpl b/templates/resources/project_grant.md.tmpl index 2a9dbb41..7c7f9b21 100644 --- a/templates/resources/project_grant.md.tmpl +++ b/templates/resources/project_grant.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/project_grant.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/project_grant_member.md.tmpl b/templates/resources/project_grant_member.md.tmpl index c2ea58ff..999b88c5 100644 --- a/templates/resources/project_grant_member.md.tmpl +++ b/templates/resources/project_grant_member.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/project_grant_member.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/project_member.md.tmpl b/templates/resources/project_member.md.tmpl index 626865ea..da7cde30 100644 --- a/templates/resources/project_member.md.tmpl +++ b/templates/resources/project_member.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/project_member.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/project_role.md.tmpl b/templates/resources/project_role.md.tmpl index b9e52b05..5a7713d3 100644 --- a/templates/resources/project_role.md.tmpl +++ b/templates/resources/project_role.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/project_role.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:my-role-key:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/sms_provider_twilio.md.tmpl b/templates/resources/sms_provider_twilio.md.tmpl index a5f01360..d74361e5 100644 --- a/templates/resources/sms_provider_twilio.md.tmpl +++ b/templates/resources/sms_provider_twilio.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/sms_provider_twilio.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:12345678901234567890123456abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/smtp_config.md.tmpl b/templates/resources/smtp_config.md.tmpl index 2e068e72..bc7bbd0e 100644 --- a/templates/resources/smtp_config.md.tmpl +++ b/templates/resources/smtp_config.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/smtp_config.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format `<[password]>`, e.g. + +```bash +terraform import {{ .Name }}.imported 'p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/trigger_actions.md.tmpl b/templates/resources/trigger_actions.md.tmpl index ba7202c9..547aa9b3 100644 --- a/templates/resources/trigger_actions.md.tmpl +++ b/templates/resources/trigger_actions.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/trigger_actions.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/user_grant.md.tmpl b/templates/resources/user_grant.md.tmpl index e13c1c22..a4fccc2f 100644 --- a/templates/resources/user_grant.md.tmpl +++ b/templates/resources/user_grant.md.tmpl @@ -13,4 +13,14 @@ description: |- {{ tffile "examples/provider/resources/user_grant.tf" }} -{{ .SchemaMarkdown | trimspace }} \ No newline at end of file +{{ .SchemaMarkdown | trimspace }} + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). From 17656344bc69f7b2bbbcc56f258d164fa8e9f61a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 22 Aug 2023 14:05:55 +0200 Subject: [PATCH 245/260] gen docs --- docs/data-sources/action.md | 3 +++ docs/data-sources/application_api.md | 5 ++++- docs/data-sources/application_oidc.md | 5 ++++- docs/data-sources/idp_azure_ad.md | 8 ------- docs/data-sources/idp_github.md | 8 ------- docs/data-sources/idp_github_es.md | 8 ------- docs/data-sources/idp_gitlab.md | 8 ------- docs/data-sources/idp_gitlab_self_hosted.md | 8 ------- docs/data-sources/idp_google.md | 8 ------- docs/data-sources/idp_ldap.md | 8 ------- docs/data-sources/machine_user.md | 5 ++++- docs/data-sources/org.md | 2 +- docs/data-sources/org_idp_azure_ad.md | 11 +++------- docs/data-sources/org_idp_github.md | 11 +++------- docs/data-sources/org_idp_github_es.md | 11 +++------- docs/data-sources/org_idp_gitlab.md | 11 +++------- .../org_idp_gitlab_self_hosted.md | 11 +++------- docs/data-sources/org_idp_google.md | 11 +++------- docs/data-sources/org_idp_ldap.md | 11 +++------- docs/data-sources/project.md | 5 ++++- docs/data-sources/trigger_actions.md | 5 ++++- docs/resources/action.md | 17 +++++++++++++-- docs/resources/application_api.md | 16 +++++++++++--- docs/resources/application_key.md | 15 ++++++++++++- docs/resources/application_oidc.md | 14 +++++++++++-- docs/resources/default_domain_policy.md | 12 ++++++++++- docs/resources/default_label_policy.md | 12 ++++++++++- docs/resources/default_lockout_policy.md | 12 ++++++++++- docs/resources/default_login_policy.md | 12 ++++++++++- docs/resources/default_notification_policy.md | 12 ++++++++++- .../default_password_complexity_policy.md | 12 ++++++++++- docs/resources/default_privacy_policy.md | 12 ++++++++++- docs/resources/domain.md | 14 +++++++++++-- docs/resources/domain_policy.md | 21 +++++++++++++++---- docs/resources/human_user.md | 14 +++++++++++-- docs/resources/idp_azure_ad.md | 10 +++++++++ docs/resources/idp_github.md | 10 +++++++++ docs/resources/idp_github_es.md | 10 +++++++++ docs/resources/idp_gitlab.md | 10 +++++++++ docs/resources/idp_gitlab_self_hosted.md | 10 +++++++++ docs/resources/idp_google.md | 10 +++++++++ docs/resources/idp_ldap.md | 10 +++++++++ docs/resources/instance_member.md | 12 ++++++++++- docs/resources/label_policy.md | 14 +++++++++++-- docs/resources/lockout_policy.md | 14 +++++++++++-- docs/resources/login_policy.md | 14 +++++++++++-- docs/resources/machine_key.md | 14 +++++++++++-- docs/resources/machine_user.md | 14 +++++++++++-- docs/resources/notification_policy.md | 17 +++++++++++++-- docs/resources/org.md | 12 ++++++++++- docs/resources/org_idp_azure_ad.md | 12 ++++++++++- docs/resources/org_idp_github.md | 12 ++++++++++- docs/resources/org_idp_github_es.md | 14 ++++++++++++- docs/resources/org_idp_gitlab.md | 12 ++++++++++- docs/resources/org_idp_gitlab_self_hosted.md | 12 ++++++++++- docs/resources/org_idp_google.md | 12 ++++++++++- docs/resources/org_idp_jwt.md | 17 +++++++++++++-- docs/resources/org_idp_ldap.md | 12 ++++++++++- docs/resources/org_idp_oidc.md | 21 +++++++++++++++---- docs/resources/org_member.md | 17 +++++++++++++-- docs/resources/password_complexity_policy.md | 5 ++++- docs/resources/personal_access_token.md | 14 +++++++++++-- docs/resources/privacy_policy.md | 17 +++++++++++++-- docs/resources/project.md | 14 +++++++++++-- docs/resources/project_grant.md | 14 +++++++++++-- docs/resources/project_grant_member.md | 17 +++++++++++++-- docs/resources/project_member.md | 17 +++++++++++++-- docs/resources/project_role.md | 14 +++++++++++-- docs/resources/sms_provider_twilio.md | 12 ++++++++++- docs/resources/smtp_config.md | 12 ++++++++++- docs/resources/trigger_actions.md | 17 +++++++++++++-- docs/resources/user_grant.md | 14 +++++++++++-- templates/resources/application_key.md.tmpl | 2 +- zitadel/provider.go | 4 ++-- .../v2/{app_key => application_key}/const.go | 2 +- .../v2/{app_key => application_key}/funcs.go | 2 +- .../{app_key => application_key}/resource.go | 2 +- .../resource_test.go | 12 +++++------ 78 files changed, 668 insertions(+), 203 deletions(-) rename zitadel/v2/{app_key => application_key}/const.go (89%) rename zitadel/v2/{app_key => application_key}/funcs.go (99%) rename zitadel/v2/{app_key => application_key}/resource.go (98%) rename zitadel/v2/{app_key => application_key}/resource_test.go (81%) diff --git a/docs/data-sources/action.md b/docs/data-sources/action.md index c88c6521..cb696192 100644 --- a/docs/data-sources/action.md +++ b/docs/data-sources/action.md @@ -28,6 +28,9 @@ output "action" { ### Required - `action_id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only diff --git a/docs/data-sources/application_api.md b/docs/data-sources/application_api.md index be1bdcfd..8b0a6cb3 100644 --- a/docs/data-sources/application_api.md +++ b/docs/data-sources/application_api.md @@ -29,9 +29,12 @@ output "application_api" { ### Required - `app_id` (String) The ID of this resource. -- `org_id` (String) orgID of the application - `project_id` (String) ID of the project +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `auth_method_type` (String) Auth method type diff --git a/docs/data-sources/application_oidc.md b/docs/data-sources/application_oidc.md index 5eb401cc..0053d9a1 100644 --- a/docs/data-sources/application_oidc.md +++ b/docs/data-sources/application_oidc.md @@ -29,9 +29,12 @@ output "application_oidc" { ### Required - `app_id` (String) The ID of this resource. -- `org_id` (String) orgID of the application - `project_id` (String) ID of the project +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `access_token_role_assertion` (Boolean) Access token role assertion diff --git a/docs/data-sources/idp_azure_ad.md b/docs/data-sources/idp_azure_ad.md index 946193a4..fdc9be01 100644 --- a/docs/data-sources/idp_azure_ad.md +++ b/docs/data-sources/idp_azure_ad.md @@ -37,11 +37,3 @@ data "zitadel_idp_azure_ad" "default" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id - `tenant_type` (String) the azure ad tenant type - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_azure_ad 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_github.md b/docs/data-sources/idp_github.md index 86878522..567699cf 100644 --- a/docs/data-sources/idp_github.md +++ b/docs/data-sources/idp_github.md @@ -34,11 +34,3 @@ data "zitadel_idp_github" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_github 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_github_es.md b/docs/data-sources/idp_github_es.md index 28ff7f4f..9eb79692 100644 --- a/docs/data-sources/idp_github_es.md +++ b/docs/data-sources/idp_github_es.md @@ -37,11 +37,3 @@ data "zitadel_idp_github_es" "default" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_github_es 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_gitlab.md b/docs/data-sources/idp_gitlab.md index 96551c15..4b2cb92f 100644 --- a/docs/data-sources/idp_gitlab.md +++ b/docs/data-sources/idp_gitlab.md @@ -34,11 +34,3 @@ data "zitadel_idp_gitlab" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_gitlab 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_gitlab_self_hosted.md b/docs/data-sources/idp_gitlab_self_hosted.md index a1e0c28b..62b94782 100644 --- a/docs/data-sources/idp_gitlab_self_hosted.md +++ b/docs/data-sources/idp_gitlab_self_hosted.md @@ -35,11 +35,3 @@ data "zitadel_idp_gitlab_self_hosted" "default" { - `issuer` (String) the providers issuer - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_gitlab_self_hosted 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_google.md b/docs/data-sources/idp_google.md index b0cf5937..4d7c1676 100644 --- a/docs/data-sources/idp_google.md +++ b/docs/data-sources/idp_google.md @@ -34,11 +34,3 @@ data "zitadel_idp_google" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_idp_google 210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/idp_ldap.md b/docs/data-sources/idp_ldap.md index 6b3662a7..34aace90 100644 --- a/docs/data-sources/idp_ldap.md +++ b/docs/data-sources/idp_ldap.md @@ -53,11 +53,3 @@ data "zitadel_idp_ldap" "default" { - `user_base` (String) User base for LDAP connections - `user_filters` (Set of String) User filters for LDAP connections - `user_object_classes` (Set of String) User object classes for LDAP connections - -## Import - -Instance IdP imports use semicolon-delimited identifiers. The resource can be imported using the IdPs id and the IdPs bind_password. - -``` -terraform import zitadel_idp_ldap 210210971312980331:mybindpassword -``` diff --git a/docs/data-sources/machine_user.md b/docs/data-sources/machine_user.md index aee787a8..22439163 100644 --- a/docs/data-sources/machine_user.md +++ b/docs/data-sources/machine_user.md @@ -27,9 +27,12 @@ output "machine_user" { ### Required -- `org_id` (String) ID of the organization - `user_id` (String) The ID of this resource. +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `access_token_type` (String) Access token type diff --git a/docs/data-sources/org.md b/docs/data-sources/org.md index 2c34e613..10527a93 100644 --- a/docs/data-sources/org.md +++ b/docs/data-sources/org.md @@ -26,7 +26,7 @@ output "org" { ### Required -- `id` (String) An organizations resource ID. +- `id` (String) ID of the organization ### Read-Only diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md index 86b5154b..f022f4db 100644 --- a/docs/data-sources/org_idp_azure_ad.md +++ b/docs/data-sources/org_idp_azure_ad.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_azure_ad" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -38,11 +41,3 @@ data "zitadel_org_idp_azure_ad" "default" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) the azure ad tenant id - `tenant_type` (String) the azure ad tenant type - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_azure_ad 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md index 3ddec252..96a1153c 100644 --- a/docs/data-sources/org_idp_github.md +++ b/docs/data-sources/org_idp_github.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_github" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -35,11 +38,3 @@ data "zitadel_org_idp_github" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_github 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md index f4df9e40..dfb509c4 100644 --- a/docs/data-sources/org_idp_github_es.md +++ b/docs/data-sources/org_idp_github_es.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_github_es" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -38,11 +41,3 @@ data "zitadel_org_idp_github_es" "default" { - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_github_es 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md index 124cb8d5..7b522e95 100644 --- a/docs/data-sources/org_idp_gitlab.md +++ b/docs/data-sources/org_idp_gitlab.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_gitlab" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -35,11 +38,3 @@ data "zitadel_org_idp_gitlab" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_gitlab 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md index bb12f2d3..29d14bda 100644 --- a/docs/data-sources/org_idp_gitlab_self_hosted.md +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_gitlab_self_hosted" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -36,11 +39,3 @@ data "zitadel_org_idp_gitlab_self_hosted" "default" { - `issuer` (String) the providers issuer - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_gitlab_self_hosted 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md index a71b514a..b9c4656b 100644 --- a/docs/data-sources/org_idp_google.md +++ b/docs/data-sources/org_idp_google.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_google" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -35,11 +38,3 @@ data "zitadel_org_idp_google" "default" { - `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account - `name` (String) Name of the IDP - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs client_secret. - -``` -terraform import zitadel_org_idp_google 210148218065912171:210210971312980331:myclientsecret -``` diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md index 50bd0618..3288c489 100644 --- a/docs/data-sources/org_idp_ldap.md +++ b/docs/data-sources/org_idp_ldap.md @@ -23,6 +23,9 @@ data "zitadel_org_idp_ldap" "default" { ### Required - `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only @@ -54,11 +57,3 @@ data "zitadel_org_idp_ldap" "default" { - `user_base` (String) User base for LDAP connections - `user_filters` (Set of String) User filters for LDAP connections - `user_object_classes` (Set of String) User object classes for LDAP connections - -## Import - -Organization IdP imports use semicolon-delimited identifiers. The resource can be imported using the org_id, the IdPs id and the IdPs bind_password. - -``` -terraform import zitadel_org_idp_ldap 210148218065912171:210210971312980331:mybindpassword -``` diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 8eb10aff..83574494 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -27,9 +27,12 @@ output "project" { ### Required -- `org_id` (String) Organization in which the project is located - `project_id` (String) The ID of this resource. +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project diff --git a/docs/data-sources/trigger_actions.md b/docs/data-sources/trigger_actions.md index 4bd5f57a..195c77da 100644 --- a/docs/data-sources/trigger_actions.md +++ b/docs/data-sources/trigger_actions.md @@ -29,9 +29,12 @@ output "trigger_actions" { ### Required - `flow_type` (String) Type of the flow to which the action triggers belong -- `org_id` (String) ID of the organization - `trigger_type` (String) Trigger type on when the actions get triggered +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `action_ids` (Set of String) IDs of the triggered actions diff --git a/docs/resources/action.md b/docs/resources/action.md index 06430ffa..0246f457 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -28,11 +28,24 @@ resource "zitadel_action" "default" { - `allowed_to_fail` (Boolean) when true, the next action will be called even if this action fails - `name` (String) -- `org_id` (String) ID of the organization - `script` (String) - `timeout` (String) after which time the action will be terminated if not finished +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `id` (String) The ID of this resource. -- `state` (Number) the state of the action \ No newline at end of file +- `state` (Number) the state of the action + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_action.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 4e78b623..1c7c740f 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -16,7 +16,7 @@ resource "zitadel_application_api" "default" { org_id = data.zitadel_org.default.id project_id = data.zitadel_project.default.id name = "applicationapi" - auth_method_type = "API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT" + auth_method_type = "API_AUTH_METHOD_TYPE_BASIC" } ``` @@ -26,15 +26,25 @@ resource "zitadel_application_api" "default" { ### Required - `name` (String) Name of the application -- `org_id` (String) orgID of the application - `project_id` (String) ID of the project ### Optional - `auth_method_type` (String) Auth method type, supported values: API_AUTH_METHOD_TYPE_BASIC, API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT +- `org_id` (String) ID of the organization ### Read-Only - `client_id` (String, Sensitive) generated ID for this config - `client_secret` (String, Sensitive) generated secret for this config -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_application_api.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index a876d150..26cb081e 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -29,10 +29,23 @@ resource "zitadel_application_key" "default" { - `app_id` (String) ID of the application - `expiration_date` (String) Expiration date of the app key in the RFC3339 format - `key_type` (String) Type of the app key, supported values: KEY_TYPE_UNSPECIFIED, KEY_TYPE_JSON -- `org_id` (String) ID of the organization - `project_id` (String) ID of the project +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only - `id` (String) The ID of this resource. - `key_details` (String, Sensitive) Value of the app key + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_application_key.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678:import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index d449c4f8..5ff59fad 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -41,7 +41,6 @@ resource "zitadel_application_oidc" "default" { - `grant_types` (List of String) Grant types, supported values: OIDC_GRANT_TYPE_AUTHORIZATION_CODE, OIDC_GRANT_TYPE_IMPLICIT, OIDC_GRANT_TYPE_REFRESH_TOKEN, OIDC_GRANT_TYPE_DEVICE_CODE - `name` (String) Name of the application -- `org_id` (String) orgID of the application - `project_id` (String) ID of the project - `redirect_uris` (List of String) RedirectURIs - `response_types` (List of String) Response type, supported values: OIDC_RESPONSE_TYPE_CODE, OIDC_RESPONSE_TYPE_ID_TOKEN, OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN @@ -57,6 +56,7 @@ resource "zitadel_application_oidc" "default" { - `dev_mode` (Boolean) Dev mode - `id_token_role_assertion` (Boolean) ID token role assertion - `id_token_userinfo_assertion` (Boolean) Token userinfo assertion +- `org_id` (String) ID of the organization - `post_logout_redirect_uris` (List of String) Post logout redirect URIs - `version` (String) Version, supported values: OIDC_VERSION_1_0 @@ -64,4 +64,14 @@ resource "zitadel_application_oidc" "default" { - `client_id` (String, Sensitive) generated ID for this config - `client_secret` (String, Sensitive) generated secret for this config -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_application_oidc.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md index 3efa09b6..2a155fac 100644 --- a/docs/resources/default_domain_policy.md +++ b/docs/resources/default_domain_policy.md @@ -30,4 +30,14 @@ resource "zitadel_default_domain_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_domain_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index 6c7558d1..76848fce 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -74,4 +74,14 @@ resource "zitadel_default_label_policy" "default" { - `icon_url_dark` (String) - `id` (String) The ID of this resource. - `logo_url` (String) -- `logo_url_dark` (String) \ No newline at end of file +- `logo_url_dark` (String) + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_label_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md index 6b8098d6..9e857482 100644 --- a/docs/resources/default_lockout_policy.md +++ b/docs/resources/default_lockout_policy.md @@ -26,4 +26,14 @@ resource "zitadel_default_lockout_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_lockout_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index a7338875..8fc2f6c7 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -65,4 +65,14 @@ resource "zitadel_default_login_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_login_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_notification_policy.md b/docs/resources/default_notification_policy.md index 382efbea..f7265588 100644 --- a/docs/resources/default_notification_policy.md +++ b/docs/resources/default_notification_policy.md @@ -26,4 +26,14 @@ resource "zitadel_default_notification_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_notification_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_password_complexity_policy.md b/docs/resources/default_password_complexity_policy.md index e2a03337..e5d23ec7 100644 --- a/docs/resources/default_password_complexity_policy.md +++ b/docs/resources/default_password_complexity_policy.md @@ -34,4 +34,14 @@ resource "zitadel_default_password_complexity_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_password_complexity_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index c2ce8e06..f77765f1 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -32,4 +32,14 @@ resource "zitadel_default_privacy_policy" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<>`, e.g. + +```bash +terraform import zitadel_default_privacy_policy.imported '' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/domain.md b/docs/resources/domain.md index f65450f8..cc52474c 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -25,14 +25,24 @@ resource "zitadel_domain" "default" { ### Required - `name` (String) Name of the domain -- `org_id` (String) ID of the organization ### Optional - `is_primary` (Boolean) Is domain primary +- `org_id` (String) ID of the organization ### Read-Only - `id` (String) The ID of this resource. - `is_verified` (Boolean) Is domain verified -- `validation_type` (Number) Validation type \ No newline at end of file +- `validation_type` (Number) Validation type + +## Import + +The resource can be imported using the ID format `name[:org_id]`, e.g. + +```bash +terraform import zitadel_domain.imported 'example.com:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 388f5cbb..0adcb503 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -14,8 +14,8 @@ Resource representing the custom domain policy of an organization. ```terraform resource "zitadel_domain_policy" "default" { org_id = data.zitadel_org.default.id - user_login_must_be_domain = true - validate_org_domains = false + user_login_must_be_domain = false + validate_org_domains = true smtp_sender_address_matches_instance_domain = true } ``` @@ -25,11 +25,24 @@ resource "zitadel_domain_policy" "default" { ### Required -- `org_id` (String) Id for the organization - `smtp_sender_address_matches_instance_domain` (Boolean) - `user_login_must_be_domain` (Boolean) User login must be domain - `validate_org_domains` (Boolean) Validate organization domains +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_domain_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index ebe55b0e..1066a89a 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -39,7 +39,6 @@ resource "zitadel_human_user" "default" { - `email` (String) Email of the user - `first_name` (String) First name of the user - `last_name` (String) Last name of the user -- `org_id` (String) ID of the organization - `user_name` (String) Username ### Optional @@ -50,6 +49,7 @@ resource "zitadel_human_user" "default" { - `is_email_verified` (Boolean) Is the email verified of the user, can only be true if password of the user is set - `is_phone_verified` (Boolean) Is the phone verified of the user - `nick_name` (String) Nick name of the user +- `org_id` (String) ID of the organization - `phone` (String) Phone of the user - `preferred_language` (String) Preferred language of the user @@ -58,4 +58,14 @@ resource "zitadel_human_user" "default" { - `id` (String) The ID of this resource. - `login_names` (List of String) Loginnames - `preferred_login_name` (String) Preferred login name -- `state` (String) State of the user \ No newline at end of file +- `state` (String) State of the user + +## Import + +The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. + +```bash +terraform import zitadel_human_user.imported '123456789012345678:123456789012345678:Password1!' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_azure_ad.md b/docs/resources/idp_azure_ad.md index 0a4e477c..88838089 100644 --- a/docs/resources/idp_azure_ad.md +++ b/docs/resources/idp_azure_ad.md @@ -49,3 +49,13 @@ resource "zitadel_idp_azure_ad" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_azure_ad.imported '123456789012345678:12345678-1234-1234-1234-123456789012' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_github.md b/docs/resources/idp_github.md index c49b4ee7..d5a66edb 100644 --- a/docs/resources/idp_github.md +++ b/docs/resources/idp_github.md @@ -44,3 +44,13 @@ resource "zitadel_idp_github" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_github.imported '123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_github_es.md b/docs/resources/idp_github_es.md index cc9e406c..56373e16 100644 --- a/docs/resources/idp_github_es.md +++ b/docs/resources/idp_github_es.md @@ -50,3 +50,13 @@ resource "zitadel_idp_github_es" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_github_es.imported '123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_gitlab.md b/docs/resources/idp_gitlab.md index d5a24ddf..b7cb907e 100644 --- a/docs/resources/idp_gitlab.md +++ b/docs/resources/idp_gitlab.md @@ -44,3 +44,13 @@ resource "zitadel_idp_gitlab" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_gitlab.imported '123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_gitlab_self_hosted.md b/docs/resources/idp_gitlab_self_hosted.md index 54f6d2e0..b8424384 100644 --- a/docs/resources/idp_gitlab_self_hosted.md +++ b/docs/resources/idp_gitlab_self_hosted.md @@ -46,3 +46,13 @@ resource "zitadel_idp_gitlab_self_hosted" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_gitlab_self_hosted.imported '123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_google.md b/docs/resources/idp_google.md index 51307b9a..281762f5 100644 --- a/docs/resources/idp_google.md +++ b/docs/resources/idp_google.md @@ -44,3 +44,13 @@ resource "zitadel_idp_google" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_google.imported '123456789012345678:G1234567890123' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_ldap.md b/docs/resources/idp_ldap.md index 170e8168..a375241b 100644 --- a/docs/resources/idp_ldap.md +++ b/docs/resources/idp_ldap.md @@ -72,3 +72,13 @@ resource "zitadel_idp_ldap" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_idp_ldap.imported '123456789012345678:b1nd_p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 8aa957bb..2edf9b56 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -28,4 +28,14 @@ resource "zitadel_instance_member" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_instance_member.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index b34a37f5..af2c3b34 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -49,7 +49,6 @@ resource "zitadel_label_policy" "default" { - `font_color` (String) hex value for font color - `font_color_dark` (String) hex value for font color dark theme - `hide_login_name_suffix` (Boolean) hides the org suffix on the login form if the scope "urn:zitadel:iam:org:domain:primary:{domainname}" is set. Details about this scope in https://zitadel.com/docs/apis/openidoauth/scopes#reserved-scopes -- `org_id` (String) Id for the organization - `primary_color` (String) hex value for primary color - `primary_color_dark` (String) hex value for primary color dark theme - `warn_color` (String) hex value for warn color @@ -67,6 +66,7 @@ resource "zitadel_label_policy" "default" { - `logo_dark_path` (String) - `logo_hash` (String) - `logo_path` (String) +- `org_id` (String) ID of the organization - `set_active` (Boolean) set the label policy active after creating/updating ### Read-Only @@ -76,4 +76,14 @@ resource "zitadel_label_policy" "default" { - `icon_url_dark` (String) - `id` (String) The ID of this resource. - `logo_url` (String) -- `logo_url_dark` (String) \ No newline at end of file +- `logo_url_dark` (String) + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_label_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index f79e74cb..a5ea3ed1 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -27,8 +27,18 @@ resource "zitadel_lockout_policy" "default" { ### Optional -- `org_id` (String) Id for the organization +- `org_id` (String) ID of the organization ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_lockout_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 4a6132b5..1c7d4f59 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -50,7 +50,6 @@ resource "zitadel_login_policy" "default" { - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) - `multi_factor_check_lifetime` (String) -- `org_id` (String) Id for the organization - `password_check_lifetime` (String) - `passwordless_type` (String) defines if passwordless is allowed for users - `second_factor_check_lifetime` (String) @@ -63,8 +62,19 @@ resource "zitadel_login_policy" "default" { - `disable_login_with_phone` (Boolean) defines if user can additionally (to the loginname) be identified by their verified phone number - `idps` (Set of String) allowed idps to login or register - `multi_factors` (Set of String) allowed multi factors +- `org_id` (String) ID of the organization - `second_factors` (Set of String) allowed second factors ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_login_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index e60ca1e1..bc4abb6a 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -26,14 +26,24 @@ resource "zitadel_machine_key" "default" { ### Required - `key_type` (String) Type of the machine key, supported values: KEY_TYPE_UNSPECIFIED, KEY_TYPE_JSON -- `org_id` (String) ID of the organization - `user_id` (String) ID of the user ### Optional - `expiration_date` (String) Expiration date of the machine key in the RFC3339 format +- `org_id` (String) ID of the organization ### Read-Only - `id` (String) The ID of this resource. -- `key_details` (String, Sensitive) Value of the machine key \ No newline at end of file +- `key_details` (String, Sensitive) Value of the machine key + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_machine_key.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index fb5c149e..d8331cc3 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -26,17 +26,27 @@ resource "zitadel_machine_user" "default" { ### Required - `name` (String) Name of the machine user -- `org_id` (String) ID of the organization - `user_name` (String) Username ### Optional - `access_token_type` (String) Access token type, supported values: ACCESS_TOKEN_TYPE_BEARER, ACCESS_TOKEN_TYPE_JWT - `description` (String) Description of the user +- `org_id` (String) ID of the organization ### Read-Only - `id` (String) The ID of this resource. - `login_names` (List of String) Loginnames - `preferred_login_name` (String) Preferred login name -- `state` (String) State of the user \ No newline at end of file +- `state` (String) State of the user + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_machine_user.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index 085329cc..5b593c96 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -23,9 +23,22 @@ resource "zitadel_notification_policy" "default" { ### Required -- `org_id` (String) Id for the organization - `password_change` (Boolean) Send notification if a user changes his password +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_notification_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org.md b/docs/resources/org.md index f3f1d873..24959d9d 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -28,4 +28,14 @@ resource "zitadel_org" "default" { - `id` (String) The ID of this resource. - `primary_domain` (String) Primary domain of the org -- `state` (String) State of the org \ No newline at end of file +- `state` (String) State of the org + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md index c119daef..c1e2347d 100644 --- a/docs/resources/org_idp_azure_ad.md +++ b/docs/resources/org_idp_azure_ad.md @@ -39,11 +39,11 @@ resource "zitadel_org_idp_azure_ad" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `tenant_id` (String) if tenant_id is not set, the tenant_type is used - `tenant_type` (String) the azure ad tenant type @@ -51,3 +51,13 @@ resource "zitadel_org_idp_azure_ad" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_azure_ad.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md index 2e6e30a1..d1973a10 100644 --- a/docs/resources/org_idp_github.md +++ b/docs/resources/org_idp_github.md @@ -36,13 +36,23 @@ resource "zitadel_org_idp_github" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_github.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md index 3efb5c26..b7521c51 100644 --- a/docs/resources/org_idp_github_es.md +++ b/docs/resources/org_idp_github_es.md @@ -40,15 +40,27 @@ resource "zitadel_org_idp_github_es" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization - `token_endpoint` (String) the providers token endpoint - `user_endpoint` (String) the providers user endpoint ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_github_es.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +``` + +If you don't have the configuration file yet, [you can generate it](https://developer.hashicorp.com/terraform/language/import/generating-configuration). + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md index 31da7587..3c7cbc2c 100644 --- a/docs/resources/org_idp_gitlab.md +++ b/docs/resources/org_idp_gitlab.md @@ -36,13 +36,23 @@ resource "zitadel_org_idp_gitlab" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_gitlab.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md index e737bc7f..35a9eb07 100644 --- a/docs/resources/org_idp_gitlab_self_hosted.md +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -38,13 +38,23 @@ resource "zitadel_org_idp_gitlab_self_hosted" "default" { - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account - `issuer` (String) the providers issuer -- `org_id` (String) ID of the organization ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_gitlab_self_hosted.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md index 14bd6f2b..77e6ca4c 100644 --- a/docs/resources/org_idp_google.md +++ b/docs/resources/org_idp_google.md @@ -36,13 +36,23 @@ resource "zitadel_org_idp_google" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization ### Optional - `name` (String) Name of the IDP +- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_google.imported '123456789012345678:123456789012345678:G1234567890123' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index cd8c7e77..c41395a7 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -35,9 +35,22 @@ resource "zitadel_org_idp_jwt" "default" { - `jwt_endpoint` (String) the endpoint where the jwt can be extracted - `keys_endpoint` (String) the endpoint to the key (JWK) which are used to sign the JWT with - `name` (String) Name of the IDP -- `org_id` (String) ID of the organization - `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_jwt.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md index 2f3d3271..924ac615 100644 --- a/docs/resources/org_idp_ldap.md +++ b/docs/resources/org_idp_ldap.md @@ -46,7 +46,6 @@ resource "zitadel_org_idp_ldap" "default" { - `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login - `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account - `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account -- `org_id` (String) ID of the organization - `servers` (List of String) Servers to try in order for establishing LDAP connections - `start_tls` (Boolean) Wether to use StartTLS for LDAP connections - `timeout` (String) Timeout for LDAP connections @@ -65,6 +64,7 @@ resource "zitadel_org_idp_ldap" "default" { - `last_name_attribute` (String) User attribute for the last name - `name` (String) Name of the IDP - `nick_name_attribute` (String) User attribute for the nick name +- `org_id` (String) ID of the organization - `phone_attribute` (String) User attribute for the phone - `phone_verified_attribute` (String) User attribute for the phone verified state - `preferred_language_attribute` (String) User attribute for the preferred language @@ -74,3 +74,13 @@ resource "zitadel_org_idp_ldap" "default" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_ldap.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index d1cb2371..90a7cb58 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -16,8 +16,8 @@ resource "zitadel_org_idp_oidc" "default" { org_id = data.zitadel_org.default.id name = "oidcidp" styling_type = "STYLING_TYPE_UNSPECIFIED" - client_id = "google" - client_secret = "google_secret" + client_id = "a_client_id" + client_secret = "a_client_secret" issuer = "https://google.com" scopes = ["openid", "profile", "email"] display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" @@ -37,11 +37,24 @@ resource "zitadel_org_idp_oidc" "default" { - `display_name_mapping` (String) definition which field is mapped to the display name of the user - `issuer` (String) the oidc issuer of the identity provider - `name` (String) Name of the IDP -- `org_id` (String) ID of the organization - `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider - `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE - `username_mapping` (String) definition which field is mapped to the email of the user +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_idp_oidc.imported '123456789012345678:123456789012345678:1234567890abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index ddf2d973..50315085 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -24,10 +24,23 @@ resource "zitadel_org_member" "default" { ### Required -- `org_id` (String) ID of the organization - `roles` (Set of String) List of roles granted - `user_id` (String) ID of the user +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_org_member.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/password_complexity_policy.md b/docs/resources/password_complexity_policy.md index d6a2ad12..11069b79 100644 --- a/docs/resources/password_complexity_policy.md +++ b/docs/resources/password_complexity_policy.md @@ -32,7 +32,10 @@ resource "zitadel_password_complexity_policy" "default" { - `has_symbol` (Boolean) defines if the password MUST contain a symbol. E.g. "$" - `has_uppercase` (Boolean) defines if the password MUST contain an upper case letter - `min_length` (Number) Minimal length for the password -- `org_id` (String) Id for the organization + +### Optional + +- `org_id` (String) ID of the organization ### Read-Only diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 1222e72f..2befb88a 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -24,14 +24,24 @@ resource "zitadel_personal_access_token" "default" { ### Required -- `org_id` (String) ID of the organization - `user_id` (String) ID of the user ### Optional - `expiration_date` (String) Expiration date of the token in the RFC3339 format +- `org_id` (String) ID of the organization ### Read-Only - `id` (String) The ID of this resource. -- `token` (String, Sensitive) Value of the token \ No newline at end of file +- `token` (String, Sensitive) Value of the token + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_personal_access_token.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 35255c67..563aca81 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -27,11 +27,24 @@ resource "zitadel_privacy_policy" "default" { ### Required - `help_link` (String) -- `org_id` (String) Id for the organization - `privacy_link` (String) - `support_email` (String) - `tos_link` (String) +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[org_id]>`, e.g. + +```bash +terraform import zitadel_privacy_policy.imported '123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project.md b/docs/resources/project.md index 756fe601..c7564cfb 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -28,11 +28,11 @@ resource "zitadel_project" "default" { ### Required - `name` (String) Name of the project -- `org_id` (String) Organization in which the project is located ### Optional - `has_project_check` (Boolean) ZITADEL checks if the org of the user has permission to this project +- `org_id` (String) ID of the organization - `private_labeling_setting` (String) Defines from where the private labeling should be triggered, supported values: PRIVATE_LABELING_SETTING_UNSPECIFIED, PRIVATE_LABELING_SETTING_ENFORCE_PROJECT_RESOURCE_OWNER_POLICY, PRIVATE_LABELING_SETTING_ALLOW_LOGIN_USER_RESOURCE_OWNER_POLICY - `project_role_assertion` (Boolean) describes if roles of user should be added in token - `project_role_check` (Boolean) ZITADEL checks if the user has at least one on this project @@ -40,4 +40,14 @@ resource "zitadel_project" "default" { ### Read-Only - `id` (String) The ID of this resource. -- `state` (String) State of the project \ No newline at end of file +- `state` (String) State of the project + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_project.imported '123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 9512e5a2..7adb4c2a 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -26,13 +26,23 @@ resource "zitadel_project_grant" "default" { ### Required - `granted_org_id` (String) ID of the organization granted the project -- `org_id` (String) ID of the organization which owns the resource - `project_id` (String) ID of the project ### Optional +- `org_id` (String) ID of the organization - `role_keys` (Set of String) List of roles granted ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_project_grant.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index b0c7715b..0cb651df 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -27,11 +27,24 @@ resource "zitadel_project_grant_member" "default" { ### Required - `grant_id` (String) ID of the grant -- `org_id` (String) ID of the organization which owns the resource - `project_id` (String) ID of the project - `roles` (Set of String) List of roles granted - `user_id` (String) ID of the user +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_project_grant_member.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index 3d89d863..10d52470 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -25,11 +25,24 @@ resource "zitadel_project_member" "default" { ### Required -- `org_id` (String) ID of the organization which owns the resource - `project_id` (String) ID of the project - `roles` (Set of String) List of roles granted - `user_id` (String) ID of the user +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_project_member.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index b4bdaad2..9ccc2b37 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -27,14 +27,24 @@ resource "zitadel_project_role" "default" { ### Required - `display_name` (String) Name used for project role -- `org_id` (String) ID of the organization - `project_id` (String) ID of the project - `role_key` (String) Key used for project role ### Optional - `group` (String) Group used for project role +- `org_id` (String) ID of the organization ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_project_role.imported '123456789012345678:my-role-key:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index d62d818e..977b5393 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -30,4 +30,14 @@ resource "zitadel_sms_provider_twilio" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_sms_provider_twilio.imported '123456789012345678:12345678901234567890123456abcdef' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index 377e7d5a..ab3d9d7b 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -39,4 +39,14 @@ resource "zitadel_smtp_config" "default" { ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format `<[password]>`, e.g. + +```bash +terraform import zitadel_smtp_config.imported 'p4ssw0rd' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index 824b62c2..c3294fd2 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -27,9 +27,22 @@ resource "zitadel_trigger_actions" "default" { - `action_ids` (Set of String) IDs of the triggered actions - `flow_type` (String) Type of the flow to which the action triggers belong, supported values: , FLOW_TYPE_EXTERNAL_AUTHENTICATION, FLOW_TYPE_CUSTOMISE_TOKEN -- `org_id` (String) ID of the organization - `trigger_type` (String) Trigger type on when the actions get triggered, supported values: , TRIGGER_TYPE_POST_AUTHENTICATION, TRIGGER_TYPE_PRE_CREATION, TRIGGER_TYPE_POST_CREATION, TRIGGER_TYPE_PRE_USERINFO_CREATION +### Optional + +- `org_id` (String) ID of the organization + ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_trigger_actions.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 10231802..5d036980 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -25,15 +25,25 @@ resource "zitadel_user_grant" "default" { ### Required -- `org_id` (String) ID of the organization which owns the resource - `user_id` (String) ID of the user ### Optional +- `org_id` (String) ID of the organization - `project_grant_id` (String) ID of the granted project - `project_id` (String) ID of the project - `role_keys` (Set of String) List of roles granted ### Read-Only -- `id` (String) The ID of this resource. \ No newline at end of file +- `id` (String) The ID of this resource. + +## Import + +The resource can be imported using the ID format ``, e.g. + +```bash +terraform import zitadel_user_grant.imported '123456789012345678:123456789012345678:123456789012345678' +``` + +You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index 29f24c6a..fb86221e 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -11,7 +11,7 @@ description: |- ## Example Usage -{{ tffile "examples/provider/resources/app_key.tf" }} +{{ tffile "examples/provider/resources/application_key.tf" }} {{ .SchemaMarkdown | trimspace }} diff --git a/zitadel/provider.go b/zitadel/provider.go index 20caa8f3..54f53954 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -14,8 +14,8 @@ import ( zitadel_go "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" @@ -266,7 +266,7 @@ func Provider() *schema.Provider { "zitadel_action": action.GetResource(), "zitadel_application_oidc": application_oidc.GetResource(), "zitadel_application_api": application_api.GetResource(), - "zitadel_application_key": app_key.GetResource(), + "zitadel_application_key": application_key.GetResource(), "zitadel_project_grant": project_grant.GetResource(), "zitadel_user_grant": user_grant.GetResource(), "zitadel_org_member": org_member.GetResource(), diff --git a/zitadel/v2/app_key/const.go b/zitadel/v2/application_key/const.go similarity index 89% rename from zitadel/v2/app_key/const.go rename to zitadel/v2/application_key/const.go index 7d39b524..d9d32ada 100644 --- a/zitadel/v2/app_key/const.go +++ b/zitadel/v2/application_key/const.go @@ -1,4 +1,4 @@ -package app_key +package application_key const ( keyIDVar = "key_id" diff --git a/zitadel/v2/app_key/funcs.go b/zitadel/v2/application_key/funcs.go similarity index 99% rename from zitadel/v2/app_key/funcs.go rename to zitadel/v2/application_key/funcs.go index bde5c99c..a37feb3c 100644 --- a/zitadel/v2/app_key/funcs.go +++ b/zitadel/v2/application_key/funcs.go @@ -1,4 +1,4 @@ -package app_key +package application_key import ( "context" diff --git a/zitadel/v2/app_key/resource.go b/zitadel/v2/application_key/resource.go similarity index 98% rename from zitadel/v2/app_key/resource.go rename to zitadel/v2/application_key/resource.go index 12ad31e0..8a94fa51 100644 --- a/zitadel/v2/app_key/resource.go +++ b/zitadel/v2/application_key/resource.go @@ -1,4 +1,4 @@ -package app_key +package application_key import ( "github.com/hashicorp/go-cty/cty" diff --git a/zitadel/v2/app_key/resource_test.go b/zitadel/v2/application_key/resource_test.go similarity index 81% rename from zitadel/v2/app_key/resource_test.go rename to zitadel/v2/application_key/resource_test.go index 002781d1..0dd84d79 100644 --- a/zitadel/v2/app_key/resource_test.go +++ b/zitadel/v2/application_key/resource_test.go @@ -1,4 +1,4 @@ -package app_key_test +package application_key_test import ( "fmt" @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/app_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api/application_api_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_key" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" @@ -18,7 +18,7 @@ import ( func TestAccAppKey(t *testing.T) { frame := test_utils.NewOrgTestFrame(t, "zitadel_application_key") resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) - exampleProperty := test_utils.AttributeValue(t, app_key.ExpirationDateVar, exampleAttributes).AsString() + exampleProperty := test_utils.AttributeValue(t, application_key.ExpirationDateVar, exampleAttributes).AsString() updatedProperty := "2501-01-01T08:45:00Z" projectDep, projectID := project_test_dep.Create(t, frame) appDep, appID := application_api_test_dep.Create(t, frame, projectID) @@ -35,10 +35,10 @@ func TestAccAppKey(t *testing.T) { test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(frame, projectID, appID), updatedProperty), test_utils.ChainImportStateIdFuncs( test_utils.ImportResourceId(frame.BaseTestFrame), - test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.ProjectIDVar), - test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.AppIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_key.ProjectIDVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_key.AppIDVar), test_utils.ImportOrgId(frame), - test_utils.ImportStateAttribute(frame.BaseTestFrame, app_key.KeyDetailsVar), + test_utils.ImportStateAttribute(frame.BaseTestFrame, application_key.KeyDetailsVar), ), ) } From 65aea06a123b76d91235f25c2158188dbefd5e91 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 22 Aug 2023 14:12:24 +0200 Subject: [PATCH 246/260] improve machine_key docs --- docs/resources/application_key.md | 5 +++-- templates/resources/application_key.md.tmpl | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 26cb081e..1acf0f5a 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -42,10 +42,11 @@ resource "zitadel_application_key" "default" { ## Import -The resource can be imported using the ID format ``, e.g. +The resource can be imported using the ID format ``. +You can use `__SEMICOLON__` to escape `:`, e.g. ```bash -terraform import zitadel_application_key.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678:import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')' +terraform import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" ``` You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index fb86221e..06aea96c 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -17,10 +17,11 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. +The resource can be imported using the ID format ``. +You can use `__SEMICOLON__` to escape `:`, e.g. ```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678:import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')' +terraform import {{ .Name }}.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" ``` You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). From b21781729609a17f0e65165afba1bca208604342 Mon Sep 17 00:00:00 2001 From: Stefan Benz <46600784+stebenz@users.noreply.github.com> Date: Tue, 22 Aug 2023 14:13:21 +0200 Subject: [PATCH 247/260] fix: update zitadel/v2/login_policy/resource.go Co-authored-by: Elio Bischof --- zitadel/v2/login_policy/resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/v2/login_policy/resource.go index fdd56fe2..cba41721 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/v2/login_policy/resource.go @@ -37,7 +37,7 @@ func GetResource() *schema.Resource { forceMFALocalOnlyVar: { Type: schema.TypeBool, Required: true, - Description: "if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login.", + Description: "if activated, ZITADEL only enforces MFA on local authentications. On authentications through MFA, ZITADEL won't prompt for MFA.", }, passwordlessTypeVar: { Type: schema.TypeString, From 71e8fbd42faadae17ed143ab122334a91d862a3f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 23 Aug 2023 13:44:48 +0200 Subject: [PATCH 248/260] use new generic oidc template api --- .../provider/data-sources/org_idp_azure_ad.tf | 3 +- .../provider/data-sources/org_idp_github.tf | 3 +- .../data-sources/org_idp_github_es.tf | 3 +- .../provider/data-sources/org_idp_gitlab.tf | 3 +- .../org_idp_gitlab_self_hosted.tf | 3 +- .../provider/data-sources/org_idp_google.tf | 3 +- .../provider/data-sources/org_idp_ldap.tf | 3 +- examples/provider/data-sources/org_jwt_idp.tf | 2 +- .../provider/data-sources/org_oidc_idp.tf | 2 +- examples/provider/resources/org_idp_oidc.tf | 21 +-- zitadel/v2/org_idp_oidc/const.go | 14 -- zitadel/v2/org_idp_oidc/datasource.go | 73 ++-------- zitadel/v2/org_idp_oidc/funcs.go | 132 ++++++------------ zitadel/v2/org_idp_oidc/resource.go | 74 ++-------- zitadel/v2/org_idp_oidc/resource_test.go | 50 +------ zitadel/v2/org_idp_oidc/schema.go | 31 ++++ 16 files changed, 128 insertions(+), 292 deletions(-) delete mode 100644 zitadel/v2/org_idp_oidc/const.go create mode 100644 zitadel/v2/org_idp_oidc/schema.go diff --git a/examples/provider/data-sources/org_idp_azure_ad.tf b/examples/provider/data-sources/org_idp_azure_ad.tf index 93b5bcbe..591b8ed8 100644 --- a/examples/provider/data-sources/org_idp_azure_ad.tf +++ b/examples/provider/data-sources/org_idp_azure_ad.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_azure_ad" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_github.tf b/examples/provider/data-sources/org_idp_github.tf index e094c8f2..94c5f4a2 100644 --- a/examples/provider/data-sources/org_idp_github.tf +++ b/examples/provider/data-sources/org_idp_github.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_github" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_github_es.tf b/examples/provider/data-sources/org_idp_github_es.tf index 020e1edc..cb81e2f0 100644 --- a/examples/provider/data-sources/org_idp_github_es.tf +++ b/examples/provider/data-sources/org_idp_github_es.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_github_es" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_gitlab.tf b/examples/provider/data-sources/org_idp_gitlab.tf index 502fc9f0..935e394e 100644 --- a/examples/provider/data-sources/org_idp_gitlab.tf +++ b/examples/provider/data-sources/org_idp_gitlab.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_gitlab" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf index be7551e1..7a3a6031 100644 --- a/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf +++ b/examples/provider/data-sources/org_idp_gitlab_self_hosted.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_gitlab_self_hosted" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_google.tf b/examples/provider/data-sources/org_idp_google.tf index ffbda608..79ae6653 100644 --- a/examples/provider/data-sources/org_idp_google.tf +++ b/examples/provider/data-sources/org_idp_google.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_google" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_idp_ldap.tf b/examples/provider/data-sources/org_idp_ldap.tf index 6bfa868a..0a550c93 100644 --- a/examples/provider/data-sources/org_idp_ldap.tf +++ b/examples/provider/data-sources/org_idp_ldap.tf @@ -1,3 +1,4 @@ data "zitadel_org_idp_ldap" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } diff --git a/examples/provider/data-sources/org_jwt_idp.tf b/examples/provider/data-sources/org_jwt_idp.tf index caa4e726..ffe5dd1c 100644 --- a/examples/provider/data-sources/org_jwt_idp.tf +++ b/examples/provider/data-sources/org_jwt_idp.tf @@ -1,6 +1,6 @@ data "zitadel_org_jwt_idp" "default" { org_id = data.zitadel_org.default.id - idp_id = "123456789012345678" + id = "123456789012345678" } output "org_idp_org_jwt_idp" { diff --git a/examples/provider/data-sources/org_oidc_idp.tf b/examples/provider/data-sources/org_oidc_idp.tf index 4924d0ac..a833d710 100644 --- a/examples/provider/data-sources/org_oidc_idp.tf +++ b/examples/provider/data-sources/org_oidc_idp.tf @@ -1,6 +1,6 @@ data "zitadel_org_oidc_idp" "default" { org_id = data.zitadel_org.default.id - idp_id = "123456789012345678" + id = "123456789012345678" } output "org_oidc_idp" { diff --git a/examples/provider/resources/org_idp_oidc.tf b/examples/provider/resources/org_idp_oidc.tf index 3b63e4b2..ebdb19af 100644 --- a/examples/provider/resources/org_idp_oidc.tf +++ b/examples/provider/resources/org_idp_oidc.tf @@ -1,12 +1,13 @@ resource "zitadel_org_idp_oidc" "default" { - org_id = data.zitadel_org.default.id - name = "oidcidp" - styling_type = "STYLING_TYPE_UNSPECIFIED" - client_id = "a_client_id" - client_secret = "a_client_secret" - issuer = "https://google.com" - scopes = ["openid", "profile", "email"] - display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - auto_register = false + org_id = data.zitadel_org.default.id + name = "My Generic OIDC IDP" + client_id = "a_client_id" + client_secret = "a_client_secret" + scopes = ["openid", "profile", "email"] + issuer = "https://example.com" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true + is_id_token_mapping = true } diff --git a/zitadel/v2/org_idp_oidc/const.go b/zitadel/v2/org_idp_oidc/const.go deleted file mode 100644 index f081d0bb..00000000 --- a/zitadel/v2/org_idp_oidc/const.go +++ /dev/null @@ -1,14 +0,0 @@ -package org_idp_oidc - -const ( - idpIDVar = "idp_id" - nameVar = "name" - stylingTypeVar = "styling_type" - clientIDVar = "client_id" - clientSecretVar = "client_secret" - issuerVar = "issuer" - scopesVar = "scopes" - DisplayNameMappingVar = "display_name_mapping" - usernameMappingVar = "username_mapping" - autoRegisterVar = "auto_register" -) diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/v2/org_idp_oidc/datasource.go index 2dd5333c..223b000b 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/v2/org_idp_oidc/datasource.go @@ -4,72 +4,25 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func GetDatasource() *schema.Resource { return &schema.Resource{ Description: "Datasource representing a generic OIDC IdP on the organization.", Schema: map[string]*schema.Schema{ - idpIDVar: { - Type: schema.TypeString, - Required: true, - Description: "The ID of this resource.", - }, - helper.OrgIDVar: { - Type: schema.TypeString, - Required: true, - Description: "ID of the organization", - }, - nameVar: { - Type: schema.TypeString, - Computed: true, - Description: "Name of the IDP", - }, - stylingTypeVar: { - Type: schema.TypeString, - Computed: true, - Description: "Some identity providers specify the styling of the button to their login", - }, - clientIDVar: { - Type: schema.TypeString, - Computed: true, - Description: "client id generated by the identity provider", - Sensitive: true, - }, - clientSecretVar: { - Type: schema.TypeString, - Computed: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - issuerVar: { - Type: schema.TypeString, - Computed: true, - Description: "the oidc issuer of the identity provider", - }, - scopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - DisplayNameMappingVar: { - Type: schema.TypeString, - Computed: true, - Description: "definition which field is mapped to the display name of the user", - }, - usernameMappingVar: { - Type: schema.TypeString, - Computed: true, - Description: "definition which field is mapped to the email of the user", - }, - autoRegisterVar: { - Type: schema.TypeBool, - Computed: true, - Description: "auto register for users from this idp", - }, + idp_utils.IdpIDVar: idp_utils.IdPIDDataSourceField, + helper.OrgIDVar: helper.OrgIDDatasourceField, + idp_utils.NameVar: idp_utils.NameDataSourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDDataSourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretDataSourceField, + idp_utils.ScopesVar: idp_utils.ScopesDataSourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedDataSourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedDataSourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationDataSourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateDataSourceField, + IssuerVar: IssuerDatasourceField, + IsIdTokenMappingVar: IsIdTokenMappingDatasourceField, }, ReadContext: read, } diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index 839ce0c0..c530f000 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -3,147 +3,98 @@ package org_idp_oidc import ( "context" - "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" ) -func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started delete") - - clientinfo, ok := m.(*helper.ClientInfo) - if !ok { - return diag.Errorf("failed to get client") - } - - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) - if err != nil { - return diag.FromErr(err) - } - - _, err = client.RemoveOrgIDP(ctx, &management.RemoveOrgIDPRequest{ - IdpId: d.Id(), - }) - if err != nil { - return diag.Errorf("failed to delete oidc idp: %v", err) - } - return nil -} - func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started create") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } - - resp, err := client.AddOrgOIDCIDP(ctx, &management.AddOrgOIDCIDPRequest{ - Name: d.Get(nameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), - ClientId: d.Get(clientIDVar).(string), - ClientSecret: d.Get(clientSecretVar).(string), - Issuer: d.Get(issuerVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, scopesVar), - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(DisplayNameMappingVar).(string)]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), - AutoRegister: d.Get(autoRegisterVar).(bool), + resp, err := client.AddGenericOIDCProvider(ctx, &management.AddGenericOIDCProviderRequest{ + Name: idp_utils.StringValue(d, idp_utils.NameVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + Issuer: idp_utils.StringValue(d, IssuerVar), + IsIdTokenMapping: idp_utils.BoolValue(d, IsIdTokenMappingVar), }) if err != nil { return diag.Errorf("failed to create oidc idp: %v", err) } - d.SetId(resp.GetIdpId()) - + d.SetId(resp.GetId()) return nil } func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started update") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) + client, err := helper.GetManagementClient(clientinfo, idp_utils.StringValue(d, helper.OrgIDVar)) if err != nil { return diag.FromErr(err) } - - if d.HasChanges(nameVar, stylingTypeVar, autoRegisterVar) { - _, err := client.UpdateOrgIDP(ctx, &management.UpdateOrgIDPRequest{ - IdpId: d.Id(), - Name: d.Get(nameVar).(string), - StylingType: idp.IDPStylingType(idp.IDPStylingType_value[d.Get(stylingTypeVar).(string)]), - AutoRegister: d.Get(autoRegisterVar).(bool), - }) - if err != nil { - return diag.Errorf("failed to update oidc idp: %v", err) - } - } - - if d.HasChanges(clientIDVar, clientSecretVar, issuerVar, DisplayNameMappingVar, usernameMappingVar, scopesVar) { - _, err = client.UpdateOrgIDPOIDCConfig(ctx, &management.UpdateOrgIDPOIDCConfigRequest{ - IdpId: d.Id(), - ClientId: d.Get(clientIDVar).(string), - ClientSecret: d.Get(clientSecretVar).(string), - Issuer: d.Get(issuerVar).(string), - Scopes: helper.GetOkSetToStringSlice(d, scopesVar), - DisplayNameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(DisplayNameMappingVar).(string)]), - UsernameMapping: idp.OIDCMappingField(idp.OIDCMappingField_value[d.Get(usernameMappingVar).(string)]), - }) - if err != nil { - return diag.Errorf("failed to update oidc idp config: %v", err) - } - + _, err = client.UpdateGenericOIDCProvider(ctx, &management.UpdateGenericOIDCProviderRequest{ + Id: d.Id(), + Name: idp_utils.StringValue(d, idp_utils.NameVar), + Issuer: idp_utils.StringValue(d, IssuerVar), + ClientId: idp_utils.StringValue(d, idp_utils.ClientIDVar), + ClientSecret: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + Scopes: idp_utils.ScopesValue(d), + ProviderOptions: idp_utils.ProviderOptionsValue(d), + IsIdTokenMapping: idp_utils.BoolValue(d, IsIdTokenMappingVar), + }) + if err != nil { + return diag.Errorf("failed to update idp: %v", err) } return nil } func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - tflog.Info(ctx, "started read") - clientinfo, ok := m.(*helper.ClientInfo) if !ok { return diag.Errorf("failed to get client") } - client, err := helper.GetManagementClient(clientinfo, d.Get(helper.OrgIDVar).(string)) if err != nil { return diag.FromErr(err) } - - resp, err := client.GetOrgIDPByID(ctx, &management.GetOrgIDPByIDRequest{Id: helper.GetID(d, idpIDVar)}) + resp, err := client.GetProviderByID(ctx, &management.GetProviderByIDRequest{Id: helper.GetID(d, idp_utils.IdpIDVar)}) if err != nil && helper.IgnoreIfNotFoundError(err) == nil { d.SetId("") return nil } if err != nil { - return diag.Errorf("failed to get org idp oidc") + return diag.Errorf("failed to get idp") } - idp := resp.GetIdp() - oidc := idp.GetOidcConfig() + cfg := idp.GetConfig() + specificCfg := cfg.GetOidc() + generalCfg := cfg.GetOptions() set := map[string]interface{}{ - helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), - nameVar: idp.GetName(), - stylingTypeVar: idp.GetStylingType().String(), - clientIDVar: oidc.GetClientId(), - clientSecretVar: d.Get(clientSecretVar).(string), - issuerVar: oidc.GetIssuer(), - scopesVar: oidc.GetScopes(), - DisplayNameMappingVar: oidc.GetDisplayNameMapping().String(), - usernameMappingVar: oidc.GetUsernameMapping().String(), - autoRegisterVar: idp.GetAutoRegister(), + helper.OrgIDVar: idp.GetDetails().GetResourceOwner(), + idp_utils.NameVar: idp.GetName(), + idp_utils.ClientIDVar: specificCfg.GetClientId(), + idp_utils.ClientSecretVar: idp_utils.StringValue(d, idp_utils.ClientSecretVar), + idp_utils.ScopesVar: specificCfg.GetScopes(), + idp_utils.IsLinkingAllowedVar: generalCfg.GetIsLinkingAllowed(), + idp_utils.IsCreationAllowedVar: generalCfg.GetIsCreationAllowed(), + idp_utils.IsAutoCreationVar: generalCfg.GetIsAutoCreation(), + idp_utils.IsAutoUpdateVar: generalCfg.GetIsAutoUpdate(), + IssuerVar: specificCfg.GetIssuer(), + IsIdTokenMappingVar: specificCfg.GetIsIdTokenMapping(), } for k, v := range set { if err := d.Set(k, v); err != nil { @@ -151,6 +102,5 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn } } d.SetId(idp.Id) - return nil } diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index cc7c0b3e..60662a2c 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -1,78 +1,32 @@ package org_idp_oidc import ( - "github.com/hashicorp/go-cty/cty" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" ) func GetResource() *schema.Resource { return &schema.Resource{ Description: "Resource representing a generic OIDC IdP on the organization.", Schema: map[string]*schema.Schema{ - helper.OrgIDVar: helper.OrgIDResourceField, - nameVar: { - Type: schema.TypeString, - Required: true, - Description: "Name of the IDP", - }, - stylingTypeVar: { - Type: schema.TypeString, - Required: true, - Description: "Some identity providers specify the styling of the button to their login" + helper.DescriptionEnumValuesList(idp.IDPStylingType_name), - ValidateDiagFunc: func(value interface{}, path cty.Path) diag.Diagnostics { - return helper.EnumValueValidation(stylingTypeVar, value, idp.IDPStylingType_value) - }, - }, - clientIDVar: { - Type: schema.TypeString, - Required: true, - Description: "client id generated by the identity provider", - Sensitive: true, - }, - clientSecretVar: { - Type: schema.TypeString, - Required: true, - Description: "client secret generated by the identity provider", - Sensitive: true, - }, - issuerVar: { - Type: schema.TypeString, - Required: true, - Description: "the oidc issuer of the identity provider", - }, - scopesVar: { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Required: true, - Description: "the scopes requested by ZITADEL during the request on the identity provider", - }, - DisplayNameMappingVar: { - Type: schema.TypeString, - Required: true, - Description: "definition which field is mapped to the display name of the user", - }, - usernameMappingVar: { - Type: schema.TypeString, - Required: true, - Description: "definition which field is mapped to the email of the user", - }, - autoRegisterVar: { - Type: schema.TypeBool, - Required: true, - Description: "auto register for users from this idp", - }, + helper.OrgIDVar: helper.OrgIDResourceField, + idp_utils.NameVar: idp_utils.NameResourceField, + idp_utils.ClientIDVar: idp_utils.ClientIDResourceField, + idp_utils.ClientSecretVar: idp_utils.ClientSecretResourceField, + idp_utils.ScopesVar: idp_utils.ScopesResourceField, + idp_utils.IsLinkingAllowedVar: idp_utils.IsLinkingAllowedResourceField, + idp_utils.IsCreationAllowedVar: idp_utils.IsCreationAllowedResourceField, + idp_utils.IsAutoCreationVar: idp_utils.IsAutoCreationResourceField, + idp_utils.IsAutoUpdateVar: idp_utils.IsAutoUpdateResourceField, + IssuerVar: IssuerResourceField, + IsIdTokenMappingVar: IsIdTokenMappingResourceField, }, ReadContext: read, UpdateContext: update, CreateContext: create, - DeleteContext: delete, - Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, clientSecretVar), + DeleteContext: org_idp_utils.Delete, + Importer: helper.ImportWithIDAndOptionalOrgAndSecret(idp_utils.IdpIDVar, idp_utils.ClientSecretVar), } } diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go index 7cc440b6..f000446d 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -1,59 +1,13 @@ package org_idp_oidc_test import ( - "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" ) func TestAccOrgIDPOIDC(t *testing.T) { - frame := test_utils.NewOrgTestFrame(t, "zitadel_org_idp_oidc") - resourceExample, exampleAttributes := test_utils.ReadExample(t, test_utils.Resources, frame.ResourceType) - exampleProperty := test_utils.AttributeValue(t, org_idp_oidc.DisplayNameMappingVar, exampleAttributes).AsString() - updatedProperty := idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL.String() - exampleSecret := test_utils.AttributeValue(t, idp_utils.ClientSecretVar, exampleAttributes).AsString() - test_utils.RunLifecyleTest( - t, - frame.BaseTestFrame, - []string{frame.AsOrgDefaultDependency}, - test_utils.ReplaceAll(resourceExample, exampleProperty, exampleSecret), - exampleProperty, updatedProperty, - idp_utils.ClientSecretVar, exampleSecret, "an updated secret", - true, - checkRemoteProperty(*frame), - helper.ZitadelGeneratedIdOnlyRegex, - test_utils.CheckIsNotFoundFromPropertyCheck(checkRemoteProperty(*frame), updatedProperty), - test_utils.ChainImportStateIdFuncs( - test_utils.ImportResourceId(frame.BaseTestFrame), - test_utils.ImportOrgId(frame), - test_utils.ImportStateAttribute(frame.BaseTestFrame, idp_utils.ClientSecretVar), - ), - ) -} - -func checkRemoteProperty(frame test_utils.OrgTestFrame) func(string) resource.TestCheckFunc { - return func(expect string) resource.TestCheckFunc { - return func(state *terraform.State) error { - resp, err := frame.GetOrgIDPByID(frame, &management.GetOrgIDPByIDRequest{ - Id: frame.State(state).ID, - }) - if err != nil { - return err - } - actual := resp.GetIdp().GetOidcConfig().GetDisplayNameMapping().String() - if expect != actual { - return fmt.Errorf("expected jwt endpoint %s, but got %s", expect, actual) - } - return nil - } - } + org_idp_test_utils.RunOrgLifecyleTest(t, "zitadel_org_idp_oidc", idp_utils.ClientSecretVar) } diff --git a/zitadel/v2/org_idp_oidc/schema.go b/zitadel/v2/org_idp_oidc/schema.go new file mode 100644 index 00000000..ea4231fd --- /dev/null +++ b/zitadel/v2/org_idp_oidc/schema.go @@ -0,0 +1,31 @@ +package org_idp_oidc + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +const ( + IsIdTokenMappingVar = "is_id_token_mapping" + IssuerVar = "issuer" +) + +var ( + IsIdTokenMappingResourceField = &schema.Schema{ + Type: schema.TypeBool, + Required: true, + Description: "if true, provider information get mapped from the id token, not from the userinfo endpoint", + } + IsIdTokenMappingDatasourceField = &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "if true, provider information get mapped from the id token, not from the userinfo endpoint.", + } + IssuerResourceField = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "the issuer of the idp", + } + IssuerDatasourceField = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "the issuer of the idp", + } +) From 2ecd9d9af772cf23349a8c3890f3319051c84dd0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 23 Aug 2023 13:49:26 +0200 Subject: [PATCH 249/260] lint --- zitadel/v2/org_idp_oidc/funcs.go | 3 +-- zitadel/v2/org_idp_oidc/resource.go | 1 + zitadel/v2/org_idp_oidc/resource_test.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/v2/org_idp_oidc/funcs.go index c530f000..bd31e2e2 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/v2/org_idp_oidc/funcs.go @@ -3,13 +3,12 @@ package org_idp_oidc import ( "context" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/v2/org_idp_oidc/resource.go index 60662a2c..e477d5de 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/v2/org_idp_oidc/resource.go @@ -2,6 +2,7 @@ package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/v2/org_idp_oidc/resource_test.go index f000446d..272e1a8b 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/v2/org_idp_oidc/resource_test.go @@ -3,9 +3,8 @@ package org_idp_oidc_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIDPOIDC(t *testing.T) { From 4376e3efbba64076c6be7ca67089d4d62652a831 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 23 Aug 2023 13:50:47 +0200 Subject: [PATCH 250/260] docs --- docs/data-sources/org_idp_azure_ad.md | 3 +- docs/data-sources/org_idp_github.md | 3 +- docs/data-sources/org_idp_github_es.md | 3 +- docs/data-sources/org_idp_gitlab.md | 3 +- .../org_idp_gitlab_self_hosted.md | 3 +- docs/data-sources/org_idp_google.md | 3 +- docs/data-sources/org_idp_ldap.md | 3 +- docs/data-sources/org_jwt_idp.md | 2 +- docs/data-sources/org_oidc_idp.md | 23 ++++++----- docs/resources/org_idp_oidc.md | 38 ++++++++++--------- 10 files changed, 48 insertions(+), 36 deletions(-) diff --git a/docs/data-sources/org_idp_azure_ad.md b/docs/data-sources/org_idp_azure_ad.md index f022f4db..407ac8d5 100644 --- a/docs/data-sources/org_idp_azure_ad.md +++ b/docs/data-sources/org_idp_azure_ad.md @@ -13,7 +13,8 @@ Datasource representing an Azure AD IdP of the organization. ```terraform data "zitadel_org_idp_azure_ad" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_github.md b/docs/data-sources/org_idp_github.md index 96a1153c..b2348903 100644 --- a/docs/data-sources/org_idp_github.md +++ b/docs/data-sources/org_idp_github.md @@ -13,7 +13,8 @@ Datasource representing a GitHub IdP of the organization. ```terraform data "zitadel_org_idp_github" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_github_es.md b/docs/data-sources/org_idp_github_es.md index dfb509c4..b2f1dfa1 100644 --- a/docs/data-sources/org_idp_github_es.md +++ b/docs/data-sources/org_idp_github_es.md @@ -13,7 +13,8 @@ Datasource representing a GitHub Enterprise IdP of the organization. ```terraform data "zitadel_org_idp_github_es" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_gitlab.md b/docs/data-sources/org_idp_gitlab.md index 7b522e95..e2c0153b 100644 --- a/docs/data-sources/org_idp_gitlab.md +++ b/docs/data-sources/org_idp_gitlab.md @@ -13,7 +13,8 @@ Datasource representing a GitLab IdP of the organization. ```terraform data "zitadel_org_idp_gitlab" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_gitlab_self_hosted.md b/docs/data-sources/org_idp_gitlab_self_hosted.md index 29d14bda..3853afeb 100644 --- a/docs/data-sources/org_idp_gitlab_self_hosted.md +++ b/docs/data-sources/org_idp_gitlab_self_hosted.md @@ -13,7 +13,8 @@ Datasource representing a GitLab Self Hosted IdP of the organization. ```terraform data "zitadel_org_idp_gitlab_self_hosted" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_google.md b/docs/data-sources/org_idp_google.md index b9c4656b..24f31e35 100644 --- a/docs/data-sources/org_idp_google.md +++ b/docs/data-sources/org_idp_google.md @@ -13,7 +13,8 @@ Datasource representing a Google IdP of the organization. ```terraform data "zitadel_org_idp_google" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_idp_ldap.md b/docs/data-sources/org_idp_ldap.md index 3288c489..b9c23273 100644 --- a/docs/data-sources/org_idp_ldap.md +++ b/docs/data-sources/org_idp_ldap.md @@ -13,7 +13,8 @@ Datasource representing an LDAP IdP on the organization. ```terraform data "zitadel_org_idp_ldap" "default" { - id = "123456789012345678" + org_id = data.zitadel_org.default.id + id = "123456789012345678" } ``` diff --git a/docs/data-sources/org_jwt_idp.md b/docs/data-sources/org_jwt_idp.md index bdfc9095..5dcd9395 100644 --- a/docs/data-sources/org_jwt_idp.md +++ b/docs/data-sources/org_jwt_idp.md @@ -14,7 +14,7 @@ Datasource representing a generic JWT IdP on the organization. ```terraform data "zitadel_org_jwt_idp" "default" { org_id = data.zitadel_org.default.id - idp_id = "123456789012345678" + id = "123456789012345678" } output "org_idp_org_jwt_idp" { diff --git a/docs/data-sources/org_oidc_idp.md b/docs/data-sources/org_oidc_idp.md index 5ca8a80e..1cfd6e33 100644 --- a/docs/data-sources/org_oidc_idp.md +++ b/docs/data-sources/org_oidc_idp.md @@ -14,7 +14,7 @@ Datasource representing a generic OIDC IdP on the organization. ```terraform data "zitadel_org_oidc_idp" "default" { org_id = data.zitadel_org.default.id - idp_id = "123456789012345678" + id = "123456789012345678" } output "org_oidc_idp" { @@ -27,18 +27,21 @@ output "org_oidc_idp" { ### Required -- `idp_id` (String) The ID of this resource. +- `id` (String) The ID of this resource. + +### Optional + - `org_id` (String) ID of the organization ### Read-Only -- `auto_register` (Boolean) auto register for users from this idp -- `client_id` (String, Sensitive) client id generated by the identity provider +- `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `display_name_mapping` (String) definition which field is mapped to the display name of the user -- `id` (String) The ID of this resource. -- `issuer` (String) the oidc issuer of the identity provider +- `is_auto_creation` (Boolean) enabled if a new account in ZITADEL are created automatically on login with an external account +- `is_auto_update` (Boolean) enabled if a the ZITADEL account fields are updated automatically on each login +- `is_creation_allowed` (Boolean) enabled if users are able to create a new account in ZITADEL when using an external account +- `is_id_token_mapping` (Boolean) if true, provider information get mapped from the id token, not from the userinfo endpoint. +- `is_linking_allowed` (Boolean) enabled if users are able to link an existing ZITADEL user with an external account +- `issuer` (String) the issuer of the idp - `name` (String) Name of the IDP -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `styling_type` (String) Some identity providers specify the styling of the button to their login -- `username_mapping` (String) definition which field is mapped to the email of the user \ No newline at end of file +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider \ No newline at end of file diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index 90a7cb58..91f9c010 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -13,16 +13,17 @@ Resource representing a generic OIDC IdP on the organization. ```terraform resource "zitadel_org_idp_oidc" "default" { - org_id = data.zitadel_org.default.id - name = "oidcidp" - styling_type = "STYLING_TYPE_UNSPECIFIED" - client_id = "a_client_id" - client_secret = "a_client_secret" - issuer = "https://google.com" - scopes = ["openid", "profile", "email"] - display_name_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - username_mapping = "OIDC_MAPPING_FIELD_PREFERRED_USERNAME" - auto_register = false + org_id = data.zitadel_org.default.id + name = "My Generic OIDC IDP" + client_id = "a_client_id" + client_secret = "a_client_secret" + scopes = ["openid", "profile", "email"] + issuer = "https://example.com" + is_linking_allowed = false + is_creation_allowed = true + is_auto_creation = false + is_auto_update = true + is_id_token_mapping = true } ``` @@ -31,19 +32,20 @@ resource "zitadel_org_idp_oidc" "default" { ### Required -- `auto_register` (Boolean) auto register for users from this idp -- `client_id` (String, Sensitive) client id generated by the identity provider +- `client_id` (String) client id generated by the identity provider - `client_secret` (String, Sensitive) client secret generated by the identity provider -- `display_name_mapping` (String) definition which field is mapped to the display name of the user -- `issuer` (String) the oidc issuer of the identity provider -- `name` (String) Name of the IDP -- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider -- `styling_type` (String) Some identity providers specify the styling of the button to their login, supported values: STYLING_TYPE_UNSPECIFIED, STYLING_TYPE_GOOGLE -- `username_mapping` (String) definition which field is mapped to the email of the user +- `is_auto_creation` (Boolean) enable if a new account in ZITADEL should be created automatically on login with an external account +- `is_auto_update` (Boolean) enable if a the ZITADEL account fields should be updated automatically on each login +- `is_creation_allowed` (Boolean) enable if users should be able to create a new account in ZITADEL when using an external account +- `is_id_token_mapping` (Boolean) if true, provider information get mapped from the id token, not from the userinfo endpoint +- `is_linking_allowed` (Boolean) enable if users should be able to link an existing ZITADEL user with an external account +- `issuer` (String) the issuer of the idp ### Optional +- `name` (String) Name of the IDP - `org_id` (String) ID of the organization +- `scopes` (Set of String) the scopes requested by ZITADEL during the request on the identity provider ### Read-Only From 6f3769d25e80a6cb884704c1f218ec2d1c9ce09f Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 11:42:54 +0200 Subject: [PATCH 251/260] test with generic oidc idp fix --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index e5406c5c..1abcfae4 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -15,7 +15,7 @@ services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.32.0}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.35.0-rc.1}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From 967235bd961bca47cf2e144dfb869aa4cadd4f59 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 12:39:50 +0200 Subject: [PATCH 252/260] test with generic oidc idp fix --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 1abcfae4..37daf312 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -15,7 +15,7 @@ services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.35.0-rc.1}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.35.0-rc.2}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From afac637d7f700ebf9d26e621227afc24b21688be Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 14:08:26 +0200 Subject: [PATCH 253/260] separate import command file --- docs/index.md | 4 ---- docs/resources/action.md | 9 +++------ docs/resources/application_api.md | 9 +++------ docs/resources/application_key.md | 11 ++++------- docs/resources/application_oidc.md | 9 +++------ docs/resources/default_domain_policy.md | 8 +++----- docs/resources/default_label_policy.md | 8 +++----- docs/resources/default_lockout_policy.md | 8 +++----- docs/resources/default_login_policy.md | 8 +++----- docs/resources/default_notification_policy.md | 8 +++----- docs/resources/default_password_complexity_policy.md | 8 +++----- docs/resources/default_privacy_policy.md | 9 +++------ docs/resources/domain.md | 9 +++------ docs/resources/domain_policy.md | 9 +++------ docs/resources/human_user.md | 9 +++------ docs/resources/idp_azure_ad.md | 9 +++------ docs/resources/idp_github.md | 9 +++------ docs/resources/idp_github_es.md | 9 +++------ docs/resources/idp_gitlab.md | 9 +++------ docs/resources/idp_gitlab_self_hosted.md | 9 +++------ docs/resources/idp_google.md | 9 +++------ docs/resources/idp_ldap.md | 9 +++------ docs/resources/instance_member.md | 9 +++------ docs/resources/label_policy.md | 9 +++------ docs/resources/lockout_policy.md | 9 +++------ docs/resources/login_policy.md | 9 +++------ docs/resources/machine_key.md | 9 +++------ docs/resources/machine_user.md | 9 +++------ docs/resources/notification_policy.md | 9 +++------ docs/resources/org.md | 9 +++------ docs/resources/org_idp_azure_ad.md | 9 +++------ docs/resources/org_idp_github.md | 9 +++------ docs/resources/org_idp_github_es.md | 11 +++-------- docs/resources/org_idp_gitlab.md | 9 +++------ docs/resources/org_idp_gitlab_self_hosted.md | 9 +++------ docs/resources/org_idp_google.md | 9 +++------ docs/resources/org_idp_jwt.md | 9 +++------ docs/resources/org_idp_ldap.md | 9 +++------ docs/resources/org_idp_oidc.md | 9 +++------ docs/resources/org_member.md | 9 +++------ docs/resources/personal_access_token.md | 9 +++------ docs/resources/privacy_policy.md | 9 +++------ docs/resources/project.md | 9 +++------ docs/resources/project_grant.md | 9 +++------ docs/resources/project_grant_member.md | 9 +++------ docs/resources/project_member.md | 9 +++------ docs/resources/project_role.md | 9 +++------ docs/resources/sms_provider_twilio.md | 9 +++------ docs/resources/smtp_config.md | 9 +++------ docs/resources/trigger_actions.md | 9 +++------ docs/resources/user_grant.md | 9 +++------ examples/provider/resources/action-import.sh | 2 ++ examples/provider/resources/application_api-import.sh | 2 ++ examples/provider/resources/application_key-import.sh | 3 +++ .../provider/resources/application_oidc-import.sh | 2 ++ .../resources/default_domain_policy-import.sh | 2 ++ .../provider/resources/default_label_policy-import.sh | 2 ++ .../resources/default_lockout_policy-import.sh | 2 ++ .../provider/resources/default_login_policy-import.sh | 2 ++ .../resources/default_notification_policy-import.sh | 2 ++ .../resources/default_oidc_settings-import.sh | 0 .../default_password_complexity_policy-import.sh | 2 ++ .../resources/default_privacy_policy-import.sh | 2 ++ examples/provider/resources/domain-import.sh | 2 ++ examples/provider/resources/domain_policy-import.sh | 2 ++ .../provider/resources/granted_human_user-import.sh | 0 examples/provider/resources/human_user-import.sh | 2 ++ examples/provider/resources/idp_azure_ad-import.sh | 2 ++ examples/provider/resources/idp_github-import.sh | 2 ++ examples/provider/resources/idp_github_es-import.sh | 2 ++ examples/provider/resources/idp_gitlab-import.sh | 2 ++ .../resources/idp_gitlab_self_hosted-import.sh | 2 ++ examples/provider/resources/idp_google-import.sh | 2 ++ examples/provider/resources/idp_ldap-import.sh | 2 ++ examples/provider/resources/instance_member-import.sh | 2 ++ examples/provider/resources/label_policy-import.sh | 2 ++ examples/provider/resources/lockout_policy-import.sh | 2 ++ examples/provider/resources/login_policy-import.sh | 2 ++ examples/provider/resources/machine_key-import.sh | 2 ++ examples/provider/resources/machine_user-import.sh | 2 ++ .../provider/resources/notification_policy-import.sh | 2 ++ examples/provider/resources/org-import.sh | 2 ++ .../provider/resources/org_idp_azure_ad-import.sh | 2 ++ examples/provider/resources/org_idp_github-import.sh | 2 ++ .../provider/resources/org_idp_github_es-import.sh | 2 ++ examples/provider/resources/org_idp_gitlab-import.sh | 2 ++ .../resources/org_idp_gitlab_self_hosted-import.sh | 2 ++ examples/provider/resources/org_idp_google-import.sh | 2 ++ examples/provider/resources/org_idp_jwt-import.sh | 2 ++ examples/provider/resources/org_idp_ldap-import.sh | 2 ++ examples/provider/resources/org_idp_oidc-import.sh | 2 ++ examples/provider/resources/org_member-import.sh | 2 ++ .../resources/password_complexity_policy-import.sh | 0 .../resources/personal_access_token-import.sh | 2 ++ examples/provider/resources/privacy_policy-import.sh | 2 ++ examples/provider/resources/project-import.sh | 2 ++ examples/provider/resources/project_grant-import.sh | 2 ++ .../provider/resources/project_grant_member-import.sh | 2 ++ examples/provider/resources/project_member-import.sh | 2 ++ examples/provider/resources/project_role-import.sh | 2 ++ .../provider/resources/sms_provider_twilio-import.sh | 2 ++ examples/provider/resources/smtp_config-import.sh | 2 ++ examples/provider/resources/trigger_actions-import.sh | 2 ++ examples/provider/resources/user_grant-import.sh | 2 ++ templates/index.md.tmpl | 4 ---- templates/resources/action.md.tmpl | 8 +------- templates/resources/application_api.md.tmpl | 8 +------- templates/resources/application_key.md.tmpl | 9 +-------- templates/resources/application_oidc.md.tmpl | 8 +------- templates/resources/default_domain_policy.md.tmpl | 7 +------ templates/resources/default_label_policy.md.tmpl | 7 +------ templates/resources/default_lockout_policy.md.tmpl | 7 +------ templates/resources/default_login_policy.md.tmpl | 7 +------ .../resources/default_notification_policy.md.tmpl | 7 +------ .../default_password_complexity_policy.md.tmpl | 7 +------ templates/resources/default_privacy_policy.md.tmpl | 8 +------- templates/resources/domain.md.tmpl | 8 +------- templates/resources/domain_policy.md.tmpl | 8 +------- templates/resources/human_user.md.tmpl | 8 +------- templates/resources/idp_azure_ad.md.tmpl | 8 +------- templates/resources/idp_github.md.tmpl | 8 +------- templates/resources/idp_github_es.md.tmpl | 8 +------- templates/resources/idp_gitlab.md.tmpl | 8 +------- templates/resources/idp_gitlab_self_hosted.md.tmpl | 8 +------- templates/resources/idp_google.md.tmpl | 8 +------- templates/resources/idp_ldap.md.tmpl | 8 +------- templates/resources/instance_member.md.tmpl | 8 +------- templates/resources/label_policy.md.tmpl | 8 +------- templates/resources/lockout_policy.md.tmpl | 8 +------- templates/resources/login_policy.md.tmpl | 8 +------- templates/resources/machine_key.md.tmpl | 8 +------- templates/resources/machine_user.md.tmpl | 8 +------- templates/resources/notification_policy.md.tmpl | 8 +------- templates/resources/org.md.tmpl | 8 +------- templates/resources/org_idp_azure_ad.md.tmpl | 8 +------- templates/resources/org_idp_github.md.tmpl | 8 +------- templates/resources/org_idp_github_es.md.tmpl | 10 +--------- templates/resources/org_idp_gitlab.md.tmpl | 8 +------- .../resources/org_idp_gitlab_self_hosted.md.tmpl | 8 +------- templates/resources/org_idp_google.md.tmpl | 8 +------- templates/resources/org_idp_jwt.md.tmpl | 8 +------- templates/resources/org_idp_ldap.md.tmpl | 8 +------- templates/resources/org_idp_oidc.md.tmpl | 8 +------- templates/resources/org_member.md.tmpl | 8 +------- templates/resources/personal_access_token.md.tmpl | 8 +------- templates/resources/privacy_policy.md.tmpl | 8 +------- templates/resources/project.md.tmpl | 8 +------- templates/resources/project_grant.md.tmpl | 8 +------- templates/resources/project_grant_member.md.tmpl | 8 +------- templates/resources/project_member.md.tmpl | 8 +------- templates/resources/project_role.md.tmpl | 8 +------- templates/resources/sms_provider_twilio.md.tmpl | 8 +------- templates/resources/smtp_config.md.tmpl | 8 +------- templates/resources/trigger_actions.md.tmpl | 8 +------- templates/resources/user_grant.md.tmpl | 8 +------- 155 files changed, 302 insertions(+), 652 deletions(-) create mode 100644 examples/provider/resources/action-import.sh create mode 100644 examples/provider/resources/application_api-import.sh create mode 100644 examples/provider/resources/application_key-import.sh create mode 100644 examples/provider/resources/application_oidc-import.sh create mode 100644 examples/provider/resources/default_domain_policy-import.sh create mode 100644 examples/provider/resources/default_label_policy-import.sh create mode 100644 examples/provider/resources/default_lockout_policy-import.sh create mode 100644 examples/provider/resources/default_login_policy-import.sh create mode 100644 examples/provider/resources/default_notification_policy-import.sh create mode 100644 examples/provider/resources/default_oidc_settings-import.sh create mode 100644 examples/provider/resources/default_password_complexity_policy-import.sh create mode 100644 examples/provider/resources/default_privacy_policy-import.sh create mode 100644 examples/provider/resources/domain-import.sh create mode 100644 examples/provider/resources/domain_policy-import.sh create mode 100644 examples/provider/resources/granted_human_user-import.sh create mode 100644 examples/provider/resources/human_user-import.sh create mode 100644 examples/provider/resources/idp_azure_ad-import.sh create mode 100644 examples/provider/resources/idp_github-import.sh create mode 100644 examples/provider/resources/idp_github_es-import.sh create mode 100644 examples/provider/resources/idp_gitlab-import.sh create mode 100644 examples/provider/resources/idp_gitlab_self_hosted-import.sh create mode 100644 examples/provider/resources/idp_google-import.sh create mode 100644 examples/provider/resources/idp_ldap-import.sh create mode 100644 examples/provider/resources/instance_member-import.sh create mode 100644 examples/provider/resources/label_policy-import.sh create mode 100644 examples/provider/resources/lockout_policy-import.sh create mode 100644 examples/provider/resources/login_policy-import.sh create mode 100644 examples/provider/resources/machine_key-import.sh create mode 100644 examples/provider/resources/machine_user-import.sh create mode 100644 examples/provider/resources/notification_policy-import.sh create mode 100644 examples/provider/resources/org-import.sh create mode 100644 examples/provider/resources/org_idp_azure_ad-import.sh create mode 100644 examples/provider/resources/org_idp_github-import.sh create mode 100644 examples/provider/resources/org_idp_github_es-import.sh create mode 100644 examples/provider/resources/org_idp_gitlab-import.sh create mode 100644 examples/provider/resources/org_idp_gitlab_self_hosted-import.sh create mode 100644 examples/provider/resources/org_idp_google-import.sh create mode 100644 examples/provider/resources/org_idp_jwt-import.sh create mode 100644 examples/provider/resources/org_idp_ldap-import.sh create mode 100644 examples/provider/resources/org_idp_oidc-import.sh create mode 100644 examples/provider/resources/org_member-import.sh create mode 100644 examples/provider/resources/password_complexity_policy-import.sh create mode 100644 examples/provider/resources/personal_access_token-import.sh create mode 100644 examples/provider/resources/privacy_policy-import.sh create mode 100644 examples/provider/resources/project-import.sh create mode 100644 examples/provider/resources/project_grant-import.sh create mode 100644 examples/provider/resources/project_grant_member-import.sh create mode 100644 examples/provider/resources/project_member-import.sh create mode 100644 examples/provider/resources/project_role-import.sh create mode 100644 examples/provider/resources/sms_provider_twilio-import.sh create mode 100644 examples/provider/resources/smtp_config-import.sh create mode 100644 examples/provider/resources/trigger_actions-import.sh create mode 100644 examples/provider/resources/user_grant-import.sh diff --git a/docs/index.md b/docs/index.md index 2b8321bc..5a360a7e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -59,7 +59,3 @@ provider "zitadel" { - `jwt_profile_json` (String) JSON value of credentials to connect to ZITADEL. Either 'jwt_profile_file' or 'jwt_profile_json' is required - `port` (String) Used port if not the default ports 80 or 443 are configured - `token` (String) Path to the file containing credentials to connect to ZITADEL - -## Limitations - -The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file diff --git a/docs/resources/action.md b/docs/resources/action.md index 0246f457..493b08d0 100644 --- a/docs/resources/action.md +++ b/docs/resources/action.md @@ -42,10 +42,7 @@ resource "zitadel_action" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_action.imported '123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import action.imported '123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_api.md b/docs/resources/application_api.md index 1c7c740f..feb7c3fb 100644 --- a/docs/resources/application_api.md +++ b/docs/resources/application_api.md @@ -41,10 +41,7 @@ resource "zitadel_application_api" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_application_api.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import application_api.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_key.md b/docs/resources/application_key.md index 1acf0f5a..eb6ad06d 100644 --- a/docs/resources/application_key.md +++ b/docs/resources/application_key.md @@ -42,11 +42,8 @@ resource "zitadel_application_key" "default" { ## Import -The resource can be imported using the ID format ``. -You can use `__SEMICOLON__` to escape `:`, e.g. - -```bash -terraform import zitadel_application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" +```terraform +# The resource can be imported using the ID format ``. +# You can use __SEMICOLON__ to escape :, e.g. +terraform import application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/application_oidc.md b/docs/resources/application_oidc.md index 5ff59fad..e3c560dd 100644 --- a/docs/resources/application_oidc.md +++ b/docs/resources/application_oidc.md @@ -68,10 +68,7 @@ resource "zitadel_application_oidc" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_application_oidc.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import application_oidc.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_domain_policy.md b/docs/resources/default_domain_policy.md index 2a155fac..db43c4a3 100644 --- a/docs/resources/default_domain_policy.md +++ b/docs/resources/default_domain_policy.md @@ -34,10 +34,8 @@ resource "zitadel_default_domain_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_domain_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_domain_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_label_policy.md b/docs/resources/default_label_policy.md index 76848fce..f4278797 100644 --- a/docs/resources/default_label_policy.md +++ b/docs/resources/default_label_policy.md @@ -78,10 +78,8 @@ resource "zitadel_default_label_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_label_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_label_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_lockout_policy.md b/docs/resources/default_lockout_policy.md index 9e857482..07cc2cc7 100644 --- a/docs/resources/default_lockout_policy.md +++ b/docs/resources/default_lockout_policy.md @@ -30,10 +30,8 @@ resource "zitadel_default_lockout_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_lockout_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_lockout_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 8fc2f6c7..f700825a 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -69,10 +69,8 @@ resource "zitadel_default_login_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_login_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_login_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_notification_policy.md b/docs/resources/default_notification_policy.md index f7265588..945bfc0a 100644 --- a/docs/resources/default_notification_policy.md +++ b/docs/resources/default_notification_policy.md @@ -30,10 +30,8 @@ resource "zitadel_default_notification_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_notification_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_notification_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_password_complexity_policy.md b/docs/resources/default_password_complexity_policy.md index e5d23ec7..4b426278 100644 --- a/docs/resources/default_password_complexity_policy.md +++ b/docs/resources/default_password_complexity_policy.md @@ -38,10 +38,8 @@ resource "zitadel_default_password_complexity_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import zitadel_default_password_complexity_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_password_complexity_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/default_privacy_policy.md b/docs/resources/default_privacy_policy.md index f77765f1..c5d034e5 100644 --- a/docs/resources/default_privacy_policy.md +++ b/docs/resources/default_privacy_policy.md @@ -36,10 +36,7 @@ resource "zitadel_default_privacy_policy" "default" { ## Import -The resource can be imported using the ID format `<>`, e.g. - -```bash -terraform import zitadel_default_privacy_policy.imported '' +```terraform +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_privacy_policy.imported '' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/domain.md b/docs/resources/domain.md index cc52474c..598b90a5 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -39,10 +39,7 @@ resource "zitadel_domain" "default" { ## Import -The resource can be imported using the ID format `name[:org_id]`, e.g. - -```bash -terraform import zitadel_domain.imported 'example.com:123456789012345678' +```terraform +# The resource can be imported using the ID format `name[:org_id]`, e.g. +terraform import domain.imported 'example.com:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/domain_policy.md b/docs/resources/domain_policy.md index 0adcb503..84259426 100644 --- a/docs/resources/domain_policy.md +++ b/docs/resources/domain_policy.md @@ -39,10 +39,7 @@ resource "zitadel_domain_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_domain_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import domain_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/human_user.md b/docs/resources/human_user.md index 1066a89a..e8f5740f 100644 --- a/docs/resources/human_user.md +++ b/docs/resources/human_user.md @@ -62,10 +62,7 @@ resource "zitadel_human_user" "default" { ## Import -The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. - -```bash -terraform import zitadel_human_user.imported '123456789012345678:123456789012345678:Password1!' +```terraform +# The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. +terraform import human_user.imported '123456789012345678:123456789012345678:Password1!' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_azure_ad.md b/docs/resources/idp_azure_ad.md index 88838089..fa321402 100644 --- a/docs/resources/idp_azure_ad.md +++ b/docs/resources/idp_azure_ad.md @@ -52,10 +52,7 @@ resource "zitadel_idp_azure_ad" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_azure_ad.imported '123456789012345678:12345678-1234-1234-1234-123456789012' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_azure_ad.imported '123456789012345678:12345678-1234-1234-1234-123456789012' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_github.md b/docs/resources/idp_github.md index d5a66edb..985ace58 100644 --- a/docs/resources/idp_github.md +++ b/docs/resources/idp_github.md @@ -47,10 +47,7 @@ resource "zitadel_idp_github" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_github.imported '123456789012345678:1234567890123456781234567890123456787890' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_github.imported '123456789012345678:1234567890123456781234567890123456787890' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_github_es.md b/docs/resources/idp_github_es.md index 56373e16..05395a96 100644 --- a/docs/resources/idp_github_es.md +++ b/docs/resources/idp_github_es.md @@ -53,10 +53,7 @@ resource "zitadel_idp_github_es" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_github_es.imported '123456789012345678:1234567890123456781234567890123456787890' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_github_es.imported '123456789012345678:1234567890123456781234567890123456787890' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_gitlab.md b/docs/resources/idp_gitlab.md index b7cb907e..6e7f26ed 100644 --- a/docs/resources/idp_gitlab.md +++ b/docs/resources/idp_gitlab.md @@ -47,10 +47,7 @@ resource "zitadel_idp_gitlab" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_gitlab.imported '123456789012345678:1234567890abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_gitlab.imported '123456789012345678:1234567890abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_gitlab_self_hosted.md b/docs/resources/idp_gitlab_self_hosted.md index b8424384..f982eff7 100644 --- a/docs/resources/idp_gitlab_self_hosted.md +++ b/docs/resources/idp_gitlab_self_hosted.md @@ -49,10 +49,7 @@ resource "zitadel_idp_gitlab_self_hosted" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_gitlab_self_hosted.imported '123456789012345678:1234567890abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_gitlab_self_hosted.imported '123456789012345678:1234567890abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_google.md b/docs/resources/idp_google.md index 281762f5..e8ff9b9e 100644 --- a/docs/resources/idp_google.md +++ b/docs/resources/idp_google.md @@ -47,10 +47,7 @@ resource "zitadel_idp_google" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_google.imported '123456789012345678:G1234567890123' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_google.imported '123456789012345678:G1234567890123' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/idp_ldap.md b/docs/resources/idp_ldap.md index a375241b..31e76f5e 100644 --- a/docs/resources/idp_ldap.md +++ b/docs/resources/idp_ldap.md @@ -75,10 +75,7 @@ resource "zitadel_idp_ldap" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_idp_ldap.imported '123456789012345678:b1nd_p4ssw0rd' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import idp_ldap.imported '123456789012345678:b1nd_p4ssw0rd' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/instance_member.md b/docs/resources/instance_member.md index 2edf9b56..44ea5f0c 100644 --- a/docs/resources/instance_member.md +++ b/docs/resources/instance_member.md @@ -32,10 +32,7 @@ resource "zitadel_instance_member" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_instance_member.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import instance_member.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/label_policy.md b/docs/resources/label_policy.md index af2c3b34..2e449d20 100644 --- a/docs/resources/label_policy.md +++ b/docs/resources/label_policy.md @@ -80,10 +80,7 @@ resource "zitadel_label_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_label_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import label_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/lockout_policy.md b/docs/resources/lockout_policy.md index a5ea3ed1..789b141c 100644 --- a/docs/resources/lockout_policy.md +++ b/docs/resources/lockout_policy.md @@ -35,10 +35,7 @@ resource "zitadel_lockout_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_lockout_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import lockout_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 1c7d4f59..46245e7f 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -71,10 +71,7 @@ resource "zitadel_login_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_login_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import login_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/machine_key.md b/docs/resources/machine_key.md index bc4abb6a..e4f2b351 100644 --- a/docs/resources/machine_key.md +++ b/docs/resources/machine_key.md @@ -40,10 +40,7 @@ resource "zitadel_machine_key" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_machine_key.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import machine_key.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/machine_user.md b/docs/resources/machine_user.md index d8331cc3..eb9541af 100644 --- a/docs/resources/machine_user.md +++ b/docs/resources/machine_user.md @@ -43,10 +43,7 @@ resource "zitadel_machine_user" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_machine_user.imported '123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import machine_user.imported '123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/notification_policy.md b/docs/resources/notification_policy.md index 5b593c96..49a05cf2 100644 --- a/docs/resources/notification_policy.md +++ b/docs/resources/notification_policy.md @@ -35,10 +35,7 @@ resource "zitadel_notification_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_notification_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import notification_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org.md b/docs/resources/org.md index 24959d9d..0cebcd7e 100644 --- a/docs/resources/org.md +++ b/docs/resources/org.md @@ -32,10 +32,7 @@ resource "zitadel_org" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_azure_ad.md b/docs/resources/org_idp_azure_ad.md index c1e2347d..4fb57bf5 100644 --- a/docs/resources/org_idp_azure_ad.md +++ b/docs/resources/org_idp_azure_ad.md @@ -54,10 +54,7 @@ resource "zitadel_org_idp_azure_ad" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_azure_ad.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_azure_ad.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_github.md b/docs/resources/org_idp_github.md index d1973a10..b2334f41 100644 --- a/docs/resources/org_idp_github.md +++ b/docs/resources/org_idp_github.md @@ -49,10 +49,7 @@ resource "zitadel_org_idp_github" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_github.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_github.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_github_es.md b/docs/resources/org_idp_github_es.md index b7521c51..dbce8df2 100644 --- a/docs/resources/org_idp_github_es.md +++ b/docs/resources/org_idp_github_es.md @@ -55,12 +55,7 @@ resource "zitadel_org_idp_github_es" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_github_es.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_github_es.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' ``` - -If you don't have the configuration file yet, [you can generate it](https://developer.hashicorp.com/terraform/language/import/generating-configuration). - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_gitlab.md b/docs/resources/org_idp_gitlab.md index 3c7cbc2c..60d5c446 100644 --- a/docs/resources/org_idp_gitlab.md +++ b/docs/resources/org_idp_gitlab.md @@ -49,10 +49,7 @@ resource "zitadel_org_idp_gitlab" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_gitlab.imported '123456789012345678:123456789012345678:1234567890abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_gitlab.imported '123456789012345678:123456789012345678:1234567890abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_gitlab_self_hosted.md b/docs/resources/org_idp_gitlab_self_hosted.md index 35a9eb07..dee3475c 100644 --- a/docs/resources/org_idp_gitlab_self_hosted.md +++ b/docs/resources/org_idp_gitlab_self_hosted.md @@ -51,10 +51,7 @@ resource "zitadel_org_idp_gitlab_self_hosted" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_gitlab_self_hosted.imported '123456789012345678:123456789012345678:1234567890abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_gitlab_self_hosted.imported '123456789012345678:123456789012345678:1234567890abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_google.md b/docs/resources/org_idp_google.md index 77e6ca4c..f080a840 100644 --- a/docs/resources/org_idp_google.md +++ b/docs/resources/org_idp_google.md @@ -49,10 +49,7 @@ resource "zitadel_org_idp_google" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_google.imported '123456789012345678:123456789012345678:G1234567890123' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_google.imported '123456789012345678:123456789012345678:G1234567890123' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_jwt.md b/docs/resources/org_idp_jwt.md index c41395a7..a8220923 100644 --- a/docs/resources/org_idp_jwt.md +++ b/docs/resources/org_idp_jwt.md @@ -47,10 +47,7 @@ resource "zitadel_org_idp_jwt" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_jwt.imported '123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_jwt.imported '123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_ldap.md b/docs/resources/org_idp_ldap.md index 924ac615..19309bfe 100644 --- a/docs/resources/org_idp_ldap.md +++ b/docs/resources/org_idp_ldap.md @@ -77,10 +77,7 @@ resource "zitadel_org_idp_ldap" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_ldap.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_ldap.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_idp_oidc.md b/docs/resources/org_idp_oidc.md index 90a7cb58..fed85d14 100644 --- a/docs/resources/org_idp_oidc.md +++ b/docs/resources/org_idp_oidc.md @@ -51,10 +51,7 @@ resource "zitadel_org_idp_oidc" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_idp_oidc.imported '123456789012345678:123456789012345678:1234567890abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_oidc.imported '123456789012345678:123456789012345678:1234567890abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/org_member.md b/docs/resources/org_member.md index 50315085..dcca6ade 100644 --- a/docs/resources/org_member.md +++ b/docs/resources/org_member.md @@ -37,10 +37,7 @@ resource "zitadel_org_member" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_org_member.imported '123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import org_member.imported '123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/personal_access_token.md b/docs/resources/personal_access_token.md index 2befb88a..ceaf3ecd 100644 --- a/docs/resources/personal_access_token.md +++ b/docs/resources/personal_access_token.md @@ -38,10 +38,7 @@ resource "zitadel_personal_access_token" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_personal_access_token.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import personal_access_token.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/privacy_policy.md b/docs/resources/privacy_policy.md index 563aca81..3dfd4b23 100644 --- a/docs/resources/privacy_policy.md +++ b/docs/resources/privacy_policy.md @@ -41,10 +41,7 @@ resource "zitadel_privacy_policy" "default" { ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import zitadel_privacy_policy.imported '123456789012345678' +```terraform +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import privacy_policy.imported '123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project.md b/docs/resources/project.md index c7564cfb..5fa5cb62 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -44,10 +44,7 @@ resource "zitadel_project" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_project.imported '123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import project.imported '123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_grant.md b/docs/resources/project_grant.md index 7adb4c2a..8a0aa354 100644 --- a/docs/resources/project_grant.md +++ b/docs/resources/project_grant.md @@ -39,10 +39,7 @@ resource "zitadel_project_grant" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_project_grant.imported '123456789012345678:123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import project_grant.imported '123456789012345678:123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_grant_member.md b/docs/resources/project_grant_member.md index 0cb651df..7b94e379 100644 --- a/docs/resources/project_grant_member.md +++ b/docs/resources/project_grant_member.md @@ -41,10 +41,7 @@ resource "zitadel_project_grant_member" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_project_grant_member.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import project_grant_member.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_member.md b/docs/resources/project_member.md index 10d52470..dd188b2a 100644 --- a/docs/resources/project_member.md +++ b/docs/resources/project_member.md @@ -39,10 +39,7 @@ resource "zitadel_project_member" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_project_member.imported '123456789012345678:123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import project_member.imported '123456789012345678:123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/project_role.md b/docs/resources/project_role.md index 9ccc2b37..63dcfeb2 100644 --- a/docs/resources/project_role.md +++ b/docs/resources/project_role.md @@ -41,10 +41,7 @@ resource "zitadel_project_role" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_project_role.imported '123456789012345678:my-role-key:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import project_role.imported '123456789012345678:my-role-key:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/sms_provider_twilio.md b/docs/resources/sms_provider_twilio.md index 977b5393..02cc5973 100644 --- a/docs/resources/sms_provider_twilio.md +++ b/docs/resources/sms_provider_twilio.md @@ -34,10 +34,7 @@ resource "zitadel_sms_provider_twilio" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_sms_provider_twilio.imported '123456789012345678:12345678901234567890123456abcdef' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import sms_provider_twilio.imported '123456789012345678:12345678901234567890123456abcdef' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/smtp_config.md b/docs/resources/smtp_config.md index ab3d9d7b..8f779a17 100644 --- a/docs/resources/smtp_config.md +++ b/docs/resources/smtp_config.md @@ -43,10 +43,7 @@ resource "zitadel_smtp_config" "default" { ## Import -The resource can be imported using the ID format `<[password]>`, e.g. - -```bash -terraform import zitadel_smtp_config.imported 'p4ssw0rd' +```terraform +# The resource can be imported using the ID format `<[password]>`, e.g. +terraform import smtp_config.imported 'p4ssw0rd' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/trigger_actions.md b/docs/resources/trigger_actions.md index c3294fd2..ebcba7de 100644 --- a/docs/resources/trigger_actions.md +++ b/docs/resources/trigger_actions.md @@ -39,10 +39,7 @@ resource "zitadel_trigger_actions" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_trigger_actions.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import trigger_actions.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/docs/resources/user_grant.md b/docs/resources/user_grant.md index 5d036980..5dbcc579 100644 --- a/docs/resources/user_grant.md +++ b/docs/resources/user_grant.md @@ -40,10 +40,7 @@ resource "zitadel_user_grant" "default" { ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import zitadel_user_grant.imported '123456789012345678:123456789012345678:123456789012345678' +```terraform +# The resource can be imported using the ID format ``, e.g. +terraform import user_grant.imported '123456789012345678:123456789012345678:123456789012345678' ``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). diff --git a/examples/provider/resources/action-import.sh b/examples/provider/resources/action-import.sh new file mode 100644 index 00000000..449d8f4b --- /dev/null +++ b/examples/provider/resources/action-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import action.imported '123456789012345678:123456789012345678' diff --git a/examples/provider/resources/application_api-import.sh b/examples/provider/resources/application_api-import.sh new file mode 100644 index 00000000..01612e33 --- /dev/null +++ b/examples/provider/resources/application_api-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import application_api.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' diff --git a/examples/provider/resources/application_key-import.sh b/examples/provider/resources/application_key-import.sh new file mode 100644 index 00000000..a7e1df1b --- /dev/null +++ b/examples/provider/resources/application_key-import.sh @@ -0,0 +1,3 @@ +# The resource can be imported using the ID format ``. +# You can use __SEMICOLON__ to escape :, e.g. +terraform import application_key.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" diff --git a/examples/provider/resources/application_oidc-import.sh b/examples/provider/resources/application_oidc-import.sh new file mode 100644 index 00000000..d180f6ea --- /dev/null +++ b/examples/provider/resources/application_oidc-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import application_oidc.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' diff --git a/examples/provider/resources/default_domain_policy-import.sh b/examples/provider/resources/default_domain_policy-import.sh new file mode 100644 index 00000000..cccbd21e --- /dev/null +++ b/examples/provider/resources/default_domain_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_domain_policy.imported '' diff --git a/examples/provider/resources/default_label_policy-import.sh b/examples/provider/resources/default_label_policy-import.sh new file mode 100644 index 00000000..db070952 --- /dev/null +++ b/examples/provider/resources/default_label_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_label_policy.imported '' diff --git a/examples/provider/resources/default_lockout_policy-import.sh b/examples/provider/resources/default_lockout_policy-import.sh new file mode 100644 index 00000000..708ec487 --- /dev/null +++ b/examples/provider/resources/default_lockout_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_lockout_policy.imported '' diff --git a/examples/provider/resources/default_login_policy-import.sh b/examples/provider/resources/default_login_policy-import.sh new file mode 100644 index 00000000..e252f948 --- /dev/null +++ b/examples/provider/resources/default_login_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_login_policy.imported '' diff --git a/examples/provider/resources/default_notification_policy-import.sh b/examples/provider/resources/default_notification_policy-import.sh new file mode 100644 index 00000000..626de74e --- /dev/null +++ b/examples/provider/resources/default_notification_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_notification_policy.imported '' diff --git a/examples/provider/resources/default_oidc_settings-import.sh b/examples/provider/resources/default_oidc_settings-import.sh new file mode 100644 index 00000000..e69de29b diff --git a/examples/provider/resources/default_password_complexity_policy-import.sh b/examples/provider/resources/default_password_complexity_policy-import.sh new file mode 100644 index 00000000..62a524cf --- /dev/null +++ b/examples/provider/resources/default_password_complexity_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_password_complexity_policy.imported '' diff --git a/examples/provider/resources/default_privacy_policy-import.sh b/examples/provider/resources/default_privacy_policy-import.sh new file mode 100644 index 00000000..e9c3b5b1 --- /dev/null +++ b/examples/provider/resources/default_privacy_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<>`, e.g. +terraform import default_privacy_policy.imported '' diff --git a/examples/provider/resources/domain-import.sh b/examples/provider/resources/domain-import.sh new file mode 100644 index 00000000..b37205a5 --- /dev/null +++ b/examples/provider/resources/domain-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `name[:org_id]`, e.g. +terraform import domain.imported 'example.com:123456789012345678' diff --git a/examples/provider/resources/domain_policy-import.sh b/examples/provider/resources/domain_policy-import.sh new file mode 100644 index 00000000..3c609c8a --- /dev/null +++ b/examples/provider/resources/domain_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import domain_policy.imported '123456789012345678' diff --git a/examples/provider/resources/granted_human_user-import.sh b/examples/provider/resources/granted_human_user-import.sh new file mode 100644 index 00000000..e69de29b diff --git a/examples/provider/resources/human_user-import.sh b/examples/provider/resources/human_user-import.sh new file mode 100644 index 00000000..33523dfd --- /dev/null +++ b/examples/provider/resources/human_user-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. +terraform import human_user.imported '123456789012345678:123456789012345678:Password1!' diff --git a/examples/provider/resources/idp_azure_ad-import.sh b/examples/provider/resources/idp_azure_ad-import.sh new file mode 100644 index 00000000..1595d239 --- /dev/null +++ b/examples/provider/resources/idp_azure_ad-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_azure_ad.imported '123456789012345678:12345678-1234-1234-1234-123456789012' diff --git a/examples/provider/resources/idp_github-import.sh b/examples/provider/resources/idp_github-import.sh new file mode 100644 index 00000000..5e4e9b49 --- /dev/null +++ b/examples/provider/resources/idp_github-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_github.imported '123456789012345678:1234567890123456781234567890123456787890' diff --git a/examples/provider/resources/idp_github_es-import.sh b/examples/provider/resources/idp_github_es-import.sh new file mode 100644 index 00000000..a16b5d58 --- /dev/null +++ b/examples/provider/resources/idp_github_es-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_github_es.imported '123456789012345678:1234567890123456781234567890123456787890' diff --git a/examples/provider/resources/idp_gitlab-import.sh b/examples/provider/resources/idp_gitlab-import.sh new file mode 100644 index 00000000..a5e451bc --- /dev/null +++ b/examples/provider/resources/idp_gitlab-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_gitlab.imported '123456789012345678:1234567890abcdef' diff --git a/examples/provider/resources/idp_gitlab_self_hosted-import.sh b/examples/provider/resources/idp_gitlab_self_hosted-import.sh new file mode 100644 index 00000000..59939862 --- /dev/null +++ b/examples/provider/resources/idp_gitlab_self_hosted-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_gitlab_self_hosted.imported '123456789012345678:1234567890abcdef' diff --git a/examples/provider/resources/idp_google-import.sh b/examples/provider/resources/idp_google-import.sh new file mode 100644 index 00000000..b942039e --- /dev/null +++ b/examples/provider/resources/idp_google-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_google.imported '123456789012345678:G1234567890123' diff --git a/examples/provider/resources/idp_ldap-import.sh b/examples/provider/resources/idp_ldap-import.sh new file mode 100644 index 00000000..876d07b1 --- /dev/null +++ b/examples/provider/resources/idp_ldap-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import idp_ldap.imported '123456789012345678:b1nd_p4ssw0rd' diff --git a/examples/provider/resources/instance_member-import.sh b/examples/provider/resources/instance_member-import.sh new file mode 100644 index 00000000..213c489f --- /dev/null +++ b/examples/provider/resources/instance_member-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import instance_member.imported '123456789012345678' diff --git a/examples/provider/resources/label_policy-import.sh b/examples/provider/resources/label_policy-import.sh new file mode 100644 index 00000000..ecee24d2 --- /dev/null +++ b/examples/provider/resources/label_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import label_policy.imported '123456789012345678' diff --git a/examples/provider/resources/lockout_policy-import.sh b/examples/provider/resources/lockout_policy-import.sh new file mode 100644 index 00000000..2f969857 --- /dev/null +++ b/examples/provider/resources/lockout_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import lockout_policy.imported '123456789012345678' diff --git a/examples/provider/resources/login_policy-import.sh b/examples/provider/resources/login_policy-import.sh new file mode 100644 index 00000000..c837b63b --- /dev/null +++ b/examples/provider/resources/login_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import login_policy.imported '123456789012345678' diff --git a/examples/provider/resources/machine_key-import.sh b/examples/provider/resources/machine_key-import.sh new file mode 100644 index 00000000..16c00e47 --- /dev/null +++ b/examples/provider/resources/machine_key-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import machine_key.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' diff --git a/examples/provider/resources/machine_user-import.sh b/examples/provider/resources/machine_user-import.sh new file mode 100644 index 00000000..3bcd0fbb --- /dev/null +++ b/examples/provider/resources/machine_user-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import machine_user.imported '123456789012345678:123456789012345678' diff --git a/examples/provider/resources/notification_policy-import.sh b/examples/provider/resources/notification_policy-import.sh new file mode 100644 index 00000000..f259e484 --- /dev/null +++ b/examples/provider/resources/notification_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import notification_policy.imported '123456789012345678' diff --git a/examples/provider/resources/org-import.sh b/examples/provider/resources/org-import.sh new file mode 100644 index 00000000..473304ee --- /dev/null +++ b/examples/provider/resources/org-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org.imported '123456789012345678' diff --git a/examples/provider/resources/org_idp_azure_ad-import.sh b/examples/provider/resources/org_idp_azure_ad-import.sh new file mode 100644 index 00000000..d472f5a3 --- /dev/null +++ b/examples/provider/resources/org_idp_azure_ad-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_azure_ad.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' diff --git a/examples/provider/resources/org_idp_github-import.sh b/examples/provider/resources/org_idp_github-import.sh new file mode 100644 index 00000000..7cf99027 --- /dev/null +++ b/examples/provider/resources/org_idp_github-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_github.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' diff --git a/examples/provider/resources/org_idp_github_es-import.sh b/examples/provider/resources/org_idp_github_es-import.sh new file mode 100644 index 00000000..58ea902f --- /dev/null +++ b/examples/provider/resources/org_idp_github_es-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_github_es.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' diff --git a/examples/provider/resources/org_idp_gitlab-import.sh b/examples/provider/resources/org_idp_gitlab-import.sh new file mode 100644 index 00000000..a161d990 --- /dev/null +++ b/examples/provider/resources/org_idp_gitlab-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_gitlab.imported '123456789012345678:123456789012345678:1234567890abcdef' diff --git a/examples/provider/resources/org_idp_gitlab_self_hosted-import.sh b/examples/provider/resources/org_idp_gitlab_self_hosted-import.sh new file mode 100644 index 00000000..e074469b --- /dev/null +++ b/examples/provider/resources/org_idp_gitlab_self_hosted-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_gitlab_self_hosted.imported '123456789012345678:123456789012345678:1234567890abcdef' diff --git a/examples/provider/resources/org_idp_google-import.sh b/examples/provider/resources/org_idp_google-import.sh new file mode 100644 index 00000000..df325207 --- /dev/null +++ b/examples/provider/resources/org_idp_google-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_google.imported '123456789012345678:123456789012345678:G1234567890123' diff --git a/examples/provider/resources/org_idp_jwt-import.sh b/examples/provider/resources/org_idp_jwt-import.sh new file mode 100644 index 00000000..dd7b9c38 --- /dev/null +++ b/examples/provider/resources/org_idp_jwt-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_jwt.imported '123456789012345678:123456789012345678' diff --git a/examples/provider/resources/org_idp_ldap-import.sh b/examples/provider/resources/org_idp_ldap-import.sh new file mode 100644 index 00000000..98edd18e --- /dev/null +++ b/examples/provider/resources/org_idp_ldap-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_ldap.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' diff --git a/examples/provider/resources/org_idp_oidc-import.sh b/examples/provider/resources/org_idp_oidc-import.sh new file mode 100644 index 00000000..6cd301de --- /dev/null +++ b/examples/provider/resources/org_idp_oidc-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_idp_oidc.imported '123456789012345678:123456789012345678:1234567890abcdef' diff --git a/examples/provider/resources/org_member-import.sh b/examples/provider/resources/org_member-import.sh new file mode 100644 index 00000000..527d4145 --- /dev/null +++ b/examples/provider/resources/org_member-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import org_member.imported '123456789012345678:123456789012345678' diff --git a/examples/provider/resources/password_complexity_policy-import.sh b/examples/provider/resources/password_complexity_policy-import.sh new file mode 100644 index 00000000..e69de29b diff --git a/examples/provider/resources/personal_access_token-import.sh b/examples/provider/resources/personal_access_token-import.sh new file mode 100644 index 00000000..6aaadc8d --- /dev/null +++ b/examples/provider/resources/personal_access_token-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import personal_access_token.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' diff --git a/examples/provider/resources/privacy_policy-import.sh b/examples/provider/resources/privacy_policy-import.sh new file mode 100644 index 00000000..8d7b61a8 --- /dev/null +++ b/examples/provider/resources/privacy_policy-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[org_id]>`, e.g. +terraform import privacy_policy.imported '123456789012345678' diff --git a/examples/provider/resources/project-import.sh b/examples/provider/resources/project-import.sh new file mode 100644 index 00000000..3d8378d9 --- /dev/null +++ b/examples/provider/resources/project-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import project.imported '123456789012345678:123456789012345678' diff --git a/examples/provider/resources/project_grant-import.sh b/examples/provider/resources/project_grant-import.sh new file mode 100644 index 00000000..327ebbde --- /dev/null +++ b/examples/provider/resources/project_grant-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import project_grant.imported '123456789012345678:123456789012345678:123456789012345678' diff --git a/examples/provider/resources/project_grant_member-import.sh b/examples/provider/resources/project_grant_member-import.sh new file mode 100644 index 00000000..be27f94e --- /dev/null +++ b/examples/provider/resources/project_grant_member-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import project_grant_member.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' diff --git a/examples/provider/resources/project_member-import.sh b/examples/provider/resources/project_member-import.sh new file mode 100644 index 00000000..e19fbbbb --- /dev/null +++ b/examples/provider/resources/project_member-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import project_member.imported '123456789012345678:123456789012345678:123456789012345678' diff --git a/examples/provider/resources/project_role-import.sh b/examples/provider/resources/project_role-import.sh new file mode 100644 index 00000000..0791692c --- /dev/null +++ b/examples/provider/resources/project_role-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import project_role.imported '123456789012345678:my-role-key:123456789012345678' diff --git a/examples/provider/resources/sms_provider_twilio-import.sh b/examples/provider/resources/sms_provider_twilio-import.sh new file mode 100644 index 00000000..2ea6a6ba --- /dev/null +++ b/examples/provider/resources/sms_provider_twilio-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import sms_provider_twilio.imported '123456789012345678:12345678901234567890123456abcdef' diff --git a/examples/provider/resources/smtp_config-import.sh b/examples/provider/resources/smtp_config-import.sh new file mode 100644 index 00000000..722b2128 --- /dev/null +++ b/examples/provider/resources/smtp_config-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format `<[password]>`, e.g. +terraform import smtp_config.imported 'p4ssw0rd' diff --git a/examples/provider/resources/trigger_actions-import.sh b/examples/provider/resources/trigger_actions-import.sh new file mode 100644 index 00000000..6ef7ec07 --- /dev/null +++ b/examples/provider/resources/trigger_actions-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import trigger_actions.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' diff --git a/examples/provider/resources/user_grant-import.sh b/examples/provider/resources/user_grant-import.sh new file mode 100644 index 00000000..38d28e05 --- /dev/null +++ b/examples/provider/resources/user_grant-import.sh @@ -0,0 +1,2 @@ +# The resource can be imported using the ID format ``, e.g. +terraform import user_grant.imported '123456789012345678:123456789012345678:123456789012345678' diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 38435cd7..5c10e7af 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -29,7 +29,3 @@ Not planned to include as resources, as more administration task as a resource: {{ tffile "examples/provider/provider.tf" }} {{ .SchemaMarkdown | trimspace }} - -## Limitations - -The token which is used to connect to ZITADEL is currently limited to JWT-token for serviceaccounts, so you have to create a service account first, to download the key from this. \ No newline at end of file diff --git a/templates/resources/action.md.tmpl b/templates/resources/action.md.tmpl index 0759e038..f7c825f8 100644 --- a/templates/resources/action.md.tmpl +++ b/templates/resources/action.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/action-import.sh" }} diff --git a/templates/resources/application_api.md.tmpl b/templates/resources/application_api.md.tmpl index 1fb8c6cd..c4c1d3f9 100644 --- a/templates/resources/application_api.md.tmpl +++ b/templates/resources/application_api.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/application_api-import.sh" }} diff --git a/templates/resources/application_key.md.tmpl b/templates/resources/application_key.md.tmpl index 06aea96c..b0a02f48 100644 --- a/templates/resources/application_key.md.tmpl +++ b/templates/resources/application_key.md.tmpl @@ -17,11 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``. -You can use `__SEMICOLON__` to escape `:`, e.g. - -```bash -terraform import {{ .Name }}.imported "123456789012345678:123456789012345678:123456789012345678:123456789012345678:$(cat ~/Downloads/123456789012345678.json | sed -e 's/:/__SEMICOLON__/g')" -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/application_key-import.sh" }} diff --git a/templates/resources/application_oidc.md.tmpl b/templates/resources/application_oidc.md.tmpl index 44fc22ea..e49c20a4 100644 --- a/templates/resources/application_oidc.md.tmpl +++ b/templates/resources/application_oidc.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678@zitadel:JuaDFFeOak5DGE655KCYPSAclSkbMVEJXXuX1lEMBT14eLMSs0A0qhafKX5SA2Df' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/application_oidc-import.sh" }} diff --git a/templates/resources/default_domain_policy.md.tmpl b/templates/resources/default_domain_policy.md.tmpl index 9a63d64c..453fe77f 100644 --- a/templates/resources/default_domain_policy.md.tmpl +++ b/templates/resources/default_domain_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_domain_policy-import.sh" }} diff --git a/templates/resources/default_label_policy.md.tmpl b/templates/resources/default_label_policy.md.tmpl index f1a114fc..b0774023 100644 --- a/templates/resources/default_label_policy.md.tmpl +++ b/templates/resources/default_label_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_label_policy-import.sh" }} diff --git a/templates/resources/default_lockout_policy.md.tmpl b/templates/resources/default_lockout_policy.md.tmpl index 3219519f..714c7b34 100644 --- a/templates/resources/default_lockout_policy.md.tmpl +++ b/templates/resources/default_lockout_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_lockout_policy-import.sh" }} diff --git a/templates/resources/default_login_policy.md.tmpl b/templates/resources/default_login_policy.md.tmpl index 398acd06..9dd7303f 100644 --- a/templates/resources/default_login_policy.md.tmpl +++ b/templates/resources/default_login_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_login_policy-import.sh" }} diff --git a/templates/resources/default_notification_policy.md.tmpl b/templates/resources/default_notification_policy.md.tmpl index d755419f..2d541a1d 100644 --- a/templates/resources/default_notification_policy.md.tmpl +++ b/templates/resources/default_notification_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_notification_policy-import.sh" }} diff --git a/templates/resources/default_password_complexity_policy.md.tmpl b/templates/resources/default_password_complexity_policy.md.tmpl index 591c7f67..264fdb53 100644 --- a/templates/resources/default_password_complexity_policy.md.tmpl +++ b/templates/resources/default_password_complexity_policy.md.tmpl @@ -17,10 +17,5 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_password_complexity_policy-import.sh" }} diff --git a/templates/resources/default_privacy_policy.md.tmpl b/templates/resources/default_privacy_policy.md.tmpl index 7cc68c92..da618548 100644 --- a/templates/resources/default_privacy_policy.md.tmpl +++ b/templates/resources/default_privacy_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<>`, e.g. - -```bash -terraform import {{ .Name }}.imported '' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/default_privacy_policy-import.sh" }} diff --git a/templates/resources/domain.md.tmpl b/templates/resources/domain.md.tmpl index 8bac659f..29e0a63f 100644 --- a/templates/resources/domain.md.tmpl +++ b/templates/resources/domain.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `name[:org_id]`, e.g. - -```bash -terraform import {{ .Name }}.imported 'example.com:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/domain-import.sh" }} diff --git a/templates/resources/domain_policy.md.tmpl b/templates/resources/domain_policy.md.tmpl index b4c9d1b3..27b470ed 100644 --- a/templates/resources/domain_policy.md.tmpl +++ b/templates/resources/domain_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/domain_policy-import.sh" }} diff --git a/templates/resources/human_user.md.tmpl b/templates/resources/human_user.md.tmpl index e1c43a27..341eae3d 100644 --- a/templates/resources/human_user.md.tmpl +++ b/templates/resources/human_user.md.tmpl @@ -19,10 +19,4 @@ description: |- ## Import -The resource can be imported using the ID format `id[:org_id][:initial_password]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:Password1!' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/human_user-import.sh" }} diff --git a/templates/resources/idp_azure_ad.md.tmpl b/templates/resources/idp_azure_ad.md.tmpl index d1805d9a..2d117e5c 100644 --- a/templates/resources/idp_azure_ad.md.tmpl +++ b/templates/resources/idp_azure_ad.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:12345678-1234-1234-1234-123456789012' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_azure_ad-import.sh" }} diff --git a/templates/resources/idp_github.md.tmpl b/templates/resources/idp_github.md.tmpl index b79f49cc..43b4c8ca 100644 --- a/templates/resources/idp_github.md.tmpl +++ b/templates/resources/idp_github.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:1234567890123456781234567890123456787890' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_github-import.sh" }} diff --git a/templates/resources/idp_github_es.md.tmpl b/templates/resources/idp_github_es.md.tmpl index 15516d9f..7f929c52 100644 --- a/templates/resources/idp_github_es.md.tmpl +++ b/templates/resources/idp_github_es.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:1234567890123456781234567890123456787890' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_github_es-import.sh" }} diff --git a/templates/resources/idp_gitlab.md.tmpl b/templates/resources/idp_gitlab.md.tmpl index d419a492..0a961df4 100644 --- a/templates/resources/idp_gitlab.md.tmpl +++ b/templates/resources/idp_gitlab.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:1234567890abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_gitlab-import.sh" }} diff --git a/templates/resources/idp_gitlab_self_hosted.md.tmpl b/templates/resources/idp_gitlab_self_hosted.md.tmpl index 79e69b4b..5c71bcdf 100644 --- a/templates/resources/idp_gitlab_self_hosted.md.tmpl +++ b/templates/resources/idp_gitlab_self_hosted.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:1234567890abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_gitlab_self_hosted-import.sh" }} diff --git a/templates/resources/idp_google.md.tmpl b/templates/resources/idp_google.md.tmpl index 56618e6e..e4dd9568 100644 --- a/templates/resources/idp_google.md.tmpl +++ b/templates/resources/idp_google.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:G1234567890123' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_google-import.sh" }} diff --git a/templates/resources/idp_ldap.md.tmpl b/templates/resources/idp_ldap.md.tmpl index 4c2f0c1d..7267d83d 100644 --- a/templates/resources/idp_ldap.md.tmpl +++ b/templates/resources/idp_ldap.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:b1nd_p4ssw0rd' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/idp_ldap-import.sh" }} diff --git a/templates/resources/instance_member.md.tmpl b/templates/resources/instance_member.md.tmpl index 1ac0abf4..8e4517e9 100644 --- a/templates/resources/instance_member.md.tmpl +++ b/templates/resources/instance_member.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/instance_member-import.sh" }} diff --git a/templates/resources/label_policy.md.tmpl b/templates/resources/label_policy.md.tmpl index d14744a9..a578d2b6 100644 --- a/templates/resources/label_policy.md.tmpl +++ b/templates/resources/label_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/label_policy-import.sh" }} diff --git a/templates/resources/lockout_policy.md.tmpl b/templates/resources/lockout_policy.md.tmpl index 1b576a60..df6a7553 100644 --- a/templates/resources/lockout_policy.md.tmpl +++ b/templates/resources/lockout_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/lockout_policy-import.sh" }} diff --git a/templates/resources/login_policy.md.tmpl b/templates/resources/login_policy.md.tmpl index e3329458..6716725d 100644 --- a/templates/resources/login_policy.md.tmpl +++ b/templates/resources/login_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/login_policy-import.sh" }} diff --git a/templates/resources/machine_key.md.tmpl b/templates/resources/machine_key.md.tmpl index 595b7ed5..37db7cf1 100644 --- a/templates/resources/machine_key.md.tmpl +++ b/templates/resources/machine_key.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:{"type":"serviceaccount","keyId":"123456789012345678","key":"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQ...-----END RSA PRIVATE KEY-----\n","userId":"123456789012345678"}' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/machine_key-import.sh" }} diff --git a/templates/resources/machine_user.md.tmpl b/templates/resources/machine_user.md.tmpl index f082b6cb..943dd71e 100644 --- a/templates/resources/machine_user.md.tmpl +++ b/templates/resources/machine_user.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/machine_user-import.sh" }} diff --git a/templates/resources/notification_policy.md.tmpl b/templates/resources/notification_policy.md.tmpl index 423e8ff9..6bfee305 100644 --- a/templates/resources/notification_policy.md.tmpl +++ b/templates/resources/notification_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/notification_policy-import.sh" }} diff --git a/templates/resources/org.md.tmpl b/templates/resources/org.md.tmpl index 1096f548..dfa864a7 100644 --- a/templates/resources/org.md.tmpl +++ b/templates/resources/org.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org-import.sh" }} diff --git a/templates/resources/org_idp_azure_ad.md.tmpl b/templates/resources/org_idp_azure_ad.md.tmpl index d02d18c2..faf0c2e5 100644 --- a/templates/resources/org_idp_azure_ad.md.tmpl +++ b/templates/resources/org_idp_azure_ad.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:12345678-1234-1234-1234-123456789012' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_azure_ad-import.sh" }} diff --git a/templates/resources/org_idp_github.md.tmpl b/templates/resources/org_idp_github.md.tmpl index 6491a017..96f92c8f 100644 --- a/templates/resources/org_idp_github.md.tmpl +++ b/templates/resources/org_idp_github.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890123456781234567890123456787890' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_github-import.sh" }} diff --git a/templates/resources/org_idp_github_es.md.tmpl b/templates/resources/org_idp_github_es.md.tmpl index c58ae2d1..abc5b1da 100644 --- a/templates/resources/org_idp_github_es.md.tmpl +++ b/templates/resources/org_idp_github_es.md.tmpl @@ -17,12 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' -``` - -If you don't have the configuration file yet, [you can generate it](https://developer.hashicorp.com/terraform/language/import/generating-configuration). - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_github_es-import.sh" }} diff --git a/templates/resources/org_idp_gitlab.md.tmpl b/templates/resources/org_idp_gitlab.md.tmpl index e0a437b9..11f5f876 100644 --- a/templates/resources/org_idp_gitlab.md.tmpl +++ b/templates/resources/org_idp_gitlab.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_gitlab-import.sh" }} diff --git a/templates/resources/org_idp_gitlab_self_hosted.md.tmpl b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl index 1e7b21a6..41166408 100644 --- a/templates/resources/org_idp_gitlab_self_hosted.md.tmpl +++ b/templates/resources/org_idp_gitlab_self_hosted.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_gitlab_self_hosted-import.sh" }} diff --git a/templates/resources/org_idp_google.md.tmpl b/templates/resources/org_idp_google.md.tmpl index 00ee18c8..342387a3 100644 --- a/templates/resources/org_idp_google.md.tmpl +++ b/templates/resources/org_idp_google.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:G1234567890123' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_google-import.sh" }} diff --git a/templates/resources/org_idp_jwt.md.tmpl b/templates/resources/org_idp_jwt.md.tmpl index f60bd5dd..d5c1d058 100644 --- a/templates/resources/org_idp_jwt.md.tmpl +++ b/templates/resources/org_idp_jwt.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_jwt-import.sh" }} diff --git a/templates/resources/org_idp_ldap.md.tmpl b/templates/resources/org_idp_ldap.md.tmpl index f9c0dada..b16bc21f 100644 --- a/templates/resources/org_idp_ldap.md.tmpl +++ b/templates/resources/org_idp_ldap.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:b1nd_p4ssw0rd' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_ldap-import.sh" }} diff --git a/templates/resources/org_idp_oidc.md.tmpl b/templates/resources/org_idp_oidc.md.tmpl index abdb7b2a..b149e23f 100644 --- a/templates/resources/org_idp_oidc.md.tmpl +++ b/templates/resources/org_idp_oidc.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:1234567890abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_idp_oidc-import.sh" }} diff --git a/templates/resources/org_member.md.tmpl b/templates/resources/org_member.md.tmpl index 7a802c86..fcdc6b0b 100644 --- a/templates/resources/org_member.md.tmpl +++ b/templates/resources/org_member.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/org_member-import.sh" }} diff --git a/templates/resources/personal_access_token.md.tmpl b/templates/resources/personal_access_token.md.tmpl index 7e14854e..b2dbc99b 100644 --- a/templates/resources/personal_access_token.md.tmpl +++ b/templates/resources/personal_access_token.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:LHt79...' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/personal_access_token-import.sh" }} diff --git a/templates/resources/privacy_policy.md.tmpl b/templates/resources/privacy_policy.md.tmpl index e68ccef8..4021dc11 100644 --- a/templates/resources/privacy_policy.md.tmpl +++ b/templates/resources/privacy_policy.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[org_id]>`, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/privacy_policy-import.sh" }} diff --git a/templates/resources/project.md.tmpl b/templates/resources/project.md.tmpl index 56a1be51..495e13c3 100644 --- a/templates/resources/project.md.tmpl +++ b/templates/resources/project.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/project-import.sh" }} diff --git a/templates/resources/project_grant.md.tmpl b/templates/resources/project_grant.md.tmpl index 7c7f9b21..83cc1456 100644 --- a/templates/resources/project_grant.md.tmpl +++ b/templates/resources/project_grant.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/project_grant-import.sh" }} diff --git a/templates/resources/project_grant_member.md.tmpl b/templates/resources/project_grant_member.md.tmpl index 999b88c5..d4392be7 100644 --- a/templates/resources/project_grant_member.md.tmpl +++ b/templates/resources/project_grant_member.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/project_grant_member-import.sh" }} diff --git a/templates/resources/project_member.md.tmpl b/templates/resources/project_member.md.tmpl index da7cde30..e3fcb0cd 100644 --- a/templates/resources/project_member.md.tmpl +++ b/templates/resources/project_member.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/project_member-import.sh" }} diff --git a/templates/resources/project_role.md.tmpl b/templates/resources/project_role.md.tmpl index 5a7713d3..dcfa76e8 100644 --- a/templates/resources/project_role.md.tmpl +++ b/templates/resources/project_role.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:my-role-key:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/project_role-import.sh" }} diff --git a/templates/resources/sms_provider_twilio.md.tmpl b/templates/resources/sms_provider_twilio.md.tmpl index d74361e5..914cbd25 100644 --- a/templates/resources/sms_provider_twilio.md.tmpl +++ b/templates/resources/sms_provider_twilio.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:12345678901234567890123456abcdef' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/sms_provider_twilio-import.sh" }} diff --git a/templates/resources/smtp_config.md.tmpl b/templates/resources/smtp_config.md.tmpl index bc7bbd0e..f54e2d43 100644 --- a/templates/resources/smtp_config.md.tmpl +++ b/templates/resources/smtp_config.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format `<[password]>`, e.g. - -```bash -terraform import {{ .Name }}.imported 'p4ssw0rd' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/smtp_config-import.sh" }} diff --git a/templates/resources/trigger_actions.md.tmpl b/templates/resources/trigger_actions.md.tmpl index 547aa9b3..f941b99d 100644 --- a/templates/resources/trigger_actions.md.tmpl +++ b/templates/resources/trigger_actions.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported 'FLOW_TYPE_EXTERNAL_AUTHENTICATION:TRIGGER_TYPE_POST_CREATION:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/trigger_actions-import.sh" }} diff --git a/templates/resources/user_grant.md.tmpl b/templates/resources/user_grant.md.tmpl index a4fccc2f..2c3d79dd 100644 --- a/templates/resources/user_grant.md.tmpl +++ b/templates/resources/user_grant.md.tmpl @@ -17,10 +17,4 @@ description: |- ## Import -The resource can be imported using the ID format ``, e.g. - -```bash -terraform import {{ .Name }}.imported '123456789012345678:123456789012345678:123456789012345678' -``` - -You can also declare an import block, for example if you'd like [to generate the configuration file](https://developer.hashicorp.com/terraform/language/import/generating-configuration). +{{ tffile "examples/provider/resources/user_grant-import.sh" }} From 85bd5a12da8c2cc621698a80341ecce7360dade3 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 14:27:57 +0200 Subject: [PATCH 254/260] debug tests with old zitadel version --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index 37daf312..e5406c5c 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -15,7 +15,7 @@ services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.35.0-rc.2}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.32.0}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From 0d3988cfa4fb2788109a0f0d765850cb2492e8af Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 15:25:35 +0200 Subject: [PATCH 255/260] test with fixed oidc idp --- acceptance/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/docker-compose.yaml b/acceptance/docker-compose.yaml index e5406c5c..55fb67b9 100644 --- a/acceptance/docker-compose.yaml +++ b/acceptance/docker-compose.yaml @@ -15,7 +15,7 @@ services: zitadel: user: '${ZITADEL_DEV_UID}' - image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.32.0}' + image: '${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:v2.32.1}' command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml' ports: - "8080:8080" From 22bf487c3e3150aa909cd2abbbf754edb1c32c1a Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 17:17:30 +0200 Subject: [PATCH 256/260] remove key --- signal-desktop-keyring.gpg | Bin 2223 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 signal-desktop-keyring.gpg diff --git a/signal-desktop-keyring.gpg b/signal-desktop-keyring.gpg deleted file mode 100644 index b5e68a0406c738a31fff4c4de4352399168f47e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2223 zcmV;g2vGN#0u2OM(o>8@%6k}|}?l=%0SOu3ZEv`h(5}P#jS~+r;ni_t? zNrY}n3T$7un?2=;`~jag0jB9PBsd%;D!g%b>g1aPJsnB_zNv@#Fe&JRHV?d@SSo$G zE|9Kz$n@BA*o^WS6BXQjFQP&vrbcKpABq|fn`as*3957C<)#ZtY!dXhm}|^BLOzmj z3D<7a)N-*mDtrKvN{26^rZjd|%{;?=k4_68$XqC4Vy5EVBg(M^TBR_A2?3-B{hbyu-z z`(BqDmG2_lBBYy=;9s2YN29S#xq(t@O@O2#%Mkibv-h|F=KDkXd&>zz&^r!XSu75R zxhTF#4VE>_vMjyO{!&EJpix;;bnH^$rUT7izb)%h{& zpqVsRbL8kTCMb1Ld2on&XX>a=?Hijoo_GjW{u2zd4OL2yaWWyDMR?!zBgV8@m3sM) z>C?dM47Un`rvtRDHObYOKTANPRJLcbY=b7b(Qete|J9O)!>SXe6G6j12p8WmDPFcp zxXIB0%=!ihx|aYE0RRECF;8%1ZXj1^X>)L8av)QAb97~Gb09o(b#QQRa&$mSkmbwQ$LenA^WjruSBy1}5gDmquCEazRgY!GTe2D=Ks| zLHj`OCoX_e4j$$H{Uw0bPxP~Py%Q{{ojr50Yf~GGeiV7O2<>5et8Jd_3Sp%0$!vE6 z_};Q&(|Q&~0GOL38c85yI}H494iT_XORzqA4gNLM5f&1f>^|or>z`aRlQBgkQlnTb zFRHzjPbRgeE7oins}Imc8BOs9l3@)~Ie<$Xj4|$s9%;D(SvY#~UPFCU<~+Ne)>2qS zb)_MuNJ2|Q(rwAdA{3fz5})ZVLiC7M_t76)92$CZ4&aS;>Sxwz63lI6z;3B7^ktlo zcI~nlGy(=r-YlS_xdIIYSmjD50T2MJ#3I#DPSm>_1dP_@PLzbo$`cQ&BXeoiKlg%& zf;oevumk&0DkKPH!I`l(LH0!33l0c%}P9Zejg5#BZLFfWB1;NduI zfH?6HjBtsAZ5J1B#)FQwiEkd>RJ#cPb8eYb32*2zsN>lQ9P3j{w;Xe_%NL9ygvRFf z9}tiMi(a1K?JZ9C8@@rJ2v#RwT_Q>yoI*7H{M>TLB0rp7Rtcn7lj!#niMFs(<_8k9 zyqX!0SYnR#L|o*gnqC3o>m-`3`(mmeTeJ|B8?(k08FHnahmtlcAmHYavR76nV8aML zR#DMv*t1<$D<8rt;Erq(}ece{1J#N0A zI`)jQ>kCJg>oBiXSpCN59PbI}o%tnGAz=qhIi%UGey64H*f?@{Yqm2i$K9_SvnyOG z=NrHDxEz$k-69YQzIK-e4mFO*o#uT8bcdFDPZj}Fa=z>6PYJgeZodAR6Tyn2@u(Up>$XF`v$!j z5CEPnT5`5dcLJvFXG|+m@mybu+f%yha+GTp*tl_+A8V%c_|slt+46=SPT zG|D0gX{~au(j>xY$(%P_hy2-{{kJ*)a*5+X!}Mr_h0hE%TyEHjq`-#2+3RT>hUp0B zXw+hDu<^v%Fh)V3j0jj7W-eTs4j9NYncicRZZEPMB9y;<**2F4z`?_6>p$y@VL3%< zcK|{SbhQqE2$eCY4JD#}YM$gV%nmMsHW)uRnr7_{XQp*VcOH6+9{nb7S7Wha`Y#B= zxabO(VS}w;q1VZT``MKTQt0kH*j&_yT?6_SP{in1Mmt%}2F-{kFz=b{DV*<`|4MLl zC#wN5*0!*Uz{7{Fv5QJ1$`U!vxBmEmsMp2ON}F!a+lfv1&t<4Va~lZSFTIB~ZYkGBoc`@pRbsr9j51ybf^eY#`=ji15(t-5X*X zTFRH!Ev4GKxOS4ZQScdXRetue3^J#dnWuHwm From a7984318ab99f4f98c8e328530ab439bf2024fdf Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 18:12:17 +0200 Subject: [PATCH 257/260] remove v2 --- .../action/action_test_dep/dependency.go | 4 +- zitadel/{v2 => }/action/const.go | 0 zitadel/{v2 => }/action/datasource.go | 2 +- zitadel/{v2 => }/action/funcs.go | 2 +- zitadel/{v2 => }/action/resource.go | 2 +- zitadel/{v2 => }/action/resource_test.go | 4 +- .../application_api_test_dep/dependency.go | 4 +- zitadel/{v2 => }/application_api/const.go | 0 .../{v2 => }/application_api/datasource.go | 2 +- zitadel/{v2 => }/application_api/funcs.go | 2 +- zitadel/{v2 => }/application_api/resource.go | 2 +- .../{v2 => }/application_api/resource_test.go | 8 +- zitadel/{v2 => }/application_key/const.go | 0 zitadel/{v2 => }/application_key/funcs.go | 2 +- zitadel/{v2 => }/application_key/resource.go | 2 +- .../{v2 => }/application_key/resource_test.go | 10 +- zitadel/{v2 => }/application_oidc/const.go | 0 .../{v2 => }/application_oidc/datasource.go | 2 +- zitadel/{v2 => }/application_oidc/funcs.go | 2 +- zitadel/{v2 => }/application_oidc/resource.go | 2 +- .../application_oidc/resource_test.go | 8 +- .../resource.go | 2 +- .../resource_test.go | 4 +- .../{v2 => }/default_domain_policy/const.go | 0 .../{v2 => }/default_domain_policy/funcs.go | 2 +- .../default_domain_policy/resource.go | 2 +- .../default_domain_policy/resource_test.go | 6 +- .../default_init_message_text/resource.go | 2 +- .../resource_test.go | 4 +- .../{v2 => }/default_label_policy/const.go | 0 .../{v2 => }/default_label_policy/funcs.go | 2 +- .../{v2 => }/default_label_policy/resource.go | 2 +- .../default_label_policy/resource_test.go | 6 +- .../{v2 => }/default_lockout_policy/const.go | 0 .../{v2 => }/default_lockout_policy/funcs.go | 2 +- .../default_lockout_policy/resource.go | 2 +- .../default_lockout_policy/resource_test.go | 6 +- .../{v2 => }/default_login_policy/const.go | 0 .../{v2 => }/default_login_policy/funcs.go | 2 +- .../{v2 => }/default_login_policy/resource.go | 2 +- .../default_login_policy/resource_test.go | 10 +- .../{v2 => }/default_login_texts/resource.go | 2 +- .../default_login_texts/resource_test.go | 4 +- .../default_notification_policy/const.go | 0 .../default_notification_policy/funcs.go | 2 +- .../default_notification_policy/resource.go | 2 +- .../resource_test.go | 4 +- .../{v2 => }/default_oidc_settings/const.go | 0 .../default_oidc_settings/datasource.go | 0 .../{v2 => }/default_oidc_settings/funcs.go | 2 +- .../default_oidc_settings/resource.go | 2 +- .../default_oidc_settings/resource_test.go | 6 +- .../resource.go | 2 +- .../resource_test.go | 4 +- .../const.go | 0 .../funcs.go | 2 +- .../resource.go | 2 +- .../resource_test.go | 6 +- .../resource.go | 2 +- .../resource_test.go | 4 +- .../resource.go | 2 +- .../resource_test.go | 4 +- .../{v2 => }/default_privacy_policy/const.go | 0 .../{v2 => }/default_privacy_policy/funcs.go | 2 +- .../default_privacy_policy/resource.go | 2 +- .../default_privacy_policy/resource_test.go | 6 +- .../resource.go | 2 +- .../resource_test.go | 4 +- .../resource.go | 2 +- .../resource_test.go | 4 +- zitadel/{v2 => }/domain/const.go | 0 zitadel/{v2 => }/domain/funcs.go | 2 +- zitadel/{v2 => }/domain/resource.go | 2 +- zitadel/{v2 => }/domain/resource_test.go | 4 +- .../domain_claimed_message_text/resource.go | 2 +- .../resource_test.go | 4 +- zitadel/{v2 => }/domain_policy/const.go | 0 zitadel/{v2 => }/domain_policy/funcs.go | 2 +- zitadel/{v2 => }/domain_policy/resource.go | 2 +- .../{v2 => }/domain_policy/resource_test.go | 6 +- zitadel/{v2 => }/helper/client.go | 0 zitadel/{v2 => }/helper/form.go | 0 zitadel/{v2 => }/helper/helper.go | 0 zitadel/{v2 => }/helper/import.go | 0 zitadel/{v2 => }/helper/import_test.go | 0 zitadel/{v2 => }/helper/schema.go | 0 .../{v2 => }/helper/test_utils/base_frame.go | 2 +- zitadel/{v2 => }/helper/test_utils/checks.go | 0 .../helper/test_utils/datasourcetest.go | 0 .../{v2 => }/helper/test_utils/dependency.go | 0 zitadel/{v2 => }/helper/test_utils/example.go | 0 .../{v2 => }/helper/test_utils/import_id.go | 2 +- .../helper/test_utils/instance_frame.go | 2 +- .../helper/test_utils/lifecyletest.go | 0 .../{v2 => }/helper/test_utils/org_frame.go | 2 +- zitadel/{v2 => }/human_user/const.go | 0 zitadel/{v2 => }/human_user/datasource.go | 2 +- zitadel/{v2 => }/human_user/funcs.go | 2 +- .../human_user_test_dep/dependency.go | 4 +- zitadel/{v2 => }/human_user/resource.go | 2 +- zitadel/{v2 => }/human_user/resource_test.go | 6 +- zitadel/{v2 => }/idp_azure_ad/datasource.go | 2 +- zitadel/{v2 => }/idp_azure_ad/funcs.go | 4 +- .../idp_azure_ad_test_dep/dependency.go | 4 +- zitadel/{v2 => }/idp_azure_ad/resource.go | 4 +- .../{v2 => }/idp_azure_ad/resource_test.go | 4 +- zitadel/{v2 => }/idp_azure_ad/schema.go | 2 +- zitadel/{v2 => }/idp_github/datasource.go | 2 +- zitadel/{v2 => }/idp_github/funcs.go | 4 +- zitadel/{v2 => }/idp_github/resource.go | 4 +- zitadel/{v2 => }/idp_github/resource_test.go | 4 +- zitadel/{v2 => }/idp_github_es/datasource.go | 2 +- zitadel/{v2 => }/idp_github_es/funcs.go | 4 +- zitadel/{v2 => }/idp_github_es/resource.go | 4 +- .../{v2 => }/idp_github_es/resource_test.go | 4 +- zitadel/{v2 => }/idp_github_es/schema.go | 0 zitadel/{v2 => }/idp_gitlab/datasource.go | 2 +- zitadel/{v2 => }/idp_gitlab/funcs.go | 4 +- zitadel/{v2 => }/idp_gitlab/resource.go | 4 +- zitadel/{v2 => }/idp_gitlab/resource_test.go | 4 +- .../idp_gitlab_self_hosted/datasource.go | 2 +- .../{v2 => }/idp_gitlab_self_hosted/funcs.go | 4 +- .../idp_gitlab_self_hosted/resource.go | 4 +- .../idp_gitlab_self_hosted/resource_test.go | 4 +- .../{v2 => }/idp_gitlab_self_hosted/schema.go | 0 zitadel/{v2 => }/idp_google/datasource.go | 2 +- zitadel/{v2 => }/idp_google/funcs.go | 4 +- .../idp_google_test_dep/dependency.go | 4 +- zitadel/{v2 => }/idp_google/resource.go | 4 +- zitadel/{v2 => }/idp_google/resource_test.go | 4 +- zitadel/{v2 => }/idp_ldap/datasource.go | 2 +- zitadel/{v2 => }/idp_ldap/funcs.go | 4 +- zitadel/{v2 => }/idp_ldap/resource.go | 4 +- zitadel/{v2 => }/idp_ldap/resource_test.go | 4 +- zitadel/{v2 => }/idp_ldap/schema.go | 0 zitadel/{v2 => }/idp_utils/funcs.go | 2 +- .../idp_utils/idp_test_utils/checks.go | 2 +- .../idp_utils/idp_test_utils/lifecyletest.go | 6 +- zitadel/{v2 => }/idp_utils/schema.go | 0 .../{v2 => }/init_message_text/resource.go | 2 +- .../init_message_text/resource_test.go | 4 +- zitadel/{v2 => }/instance_member/const.go | 0 zitadel/{v2 => }/instance_member/funcs.go | 2 +- zitadel/{v2 => }/instance_member/resource.go | 2 +- .../{v2 => }/instance_member/resource_test.go | 8 +- zitadel/{v2 => }/label_policy/const.go | 0 zitadel/{v2 => }/label_policy/funcs.go | 2 +- zitadel/{v2 => }/label_policy/resource.go | 2 +- .../{v2 => }/label_policy/resource_test.go | 6 +- zitadel/{v2 => }/lockout_policy/const.go | 0 zitadel/{v2 => }/lockout_policy/funcs.go | 2 +- zitadel/{v2 => }/lockout_policy/resource.go | 2 +- .../{v2 => }/lockout_policy/resource_test.go | 4 +- zitadel/{v2 => }/login_policy/const.go | 0 zitadel/{v2 => }/login_policy/funcs.go | 2 +- zitadel/{v2 => }/login_policy/resource.go | 2 +- .../{v2 => }/login_policy/resource_test.go | 10 +- zitadel/{v2 => }/login_texts/resource.go | 2 +- zitadel/{v2 => }/login_texts/resource_test.go | 4 +- zitadel/{v2 => }/machine_key/const.go | 0 zitadel/{v2 => }/machine_key/funcs.go | 2 +- zitadel/{v2 => }/machine_key/resource.go | 2 +- zitadel/{v2 => }/machine_key/resource_test.go | 8 +- zitadel/{v2 => }/machine_user/const.go | 0 zitadel/{v2 => }/machine_user/datasource.go | 2 +- zitadel/{v2 => }/machine_user/funcs.go | 2 +- .../machine_user_test_dep/dependency.go | 4 +- zitadel/{v2 => }/machine_user/resource.go | 2 +- .../{v2 => }/machine_user/resource_test.go | 6 +- zitadel/{v2 => }/notification_policy/const.go | 0 zitadel/{v2 => }/notification_policy/funcs.go | 2 +- .../{v2 => }/notification_policy/resource.go | 2 +- .../notification_policy/resource_test.go | 4 +- zitadel/{v2 => }/org/const.go | 0 zitadel/{v2 => }/org/datasource.go | 2 +- zitadel/{v2 => }/org/datasource_test.go | 4 +- zitadel/{v2 => }/org/funcs.go | 2 +- .../{v2 => }/org/org_test_dep/dependency.go | 4 +- zitadel/{v2 => }/org/remote_test.go | 2 +- zitadel/{v2 => }/org/resource.go | 2 +- zitadel/{v2 => }/org/resource_test.go | 6 +- .../{v2 => }/org_idp_azure_ad/datasource.go | 6 +- zitadel/{v2 => }/org_idp_azure_ad/funcs.go | 6 +- zitadel/{v2 => }/org_idp_azure_ad/resource.go | 8 +- .../org_idp_azure_ad/resource_test.go | 4 +- zitadel/{v2 => }/org_idp_github/datasource.go | 4 +- zitadel/{v2 => }/org_idp_github/funcs.go | 4 +- zitadel/{v2 => }/org_idp_github/resource.go | 6 +- .../{v2 => }/org_idp_github/resource_test.go | 4 +- .../{v2 => }/org_idp_github_es/datasource.go | 6 +- zitadel/{v2 => }/org_idp_github_es/funcs.go | 6 +- .../{v2 => }/org_idp_github_es/resource.go | 8 +- .../org_idp_github_es/resource_test.go | 4 +- zitadel/{v2 => }/org_idp_gitlab/datasource.go | 4 +- zitadel/{v2 => }/org_idp_gitlab/funcs.go | 4 +- zitadel/{v2 => }/org_idp_gitlab/resource.go | 6 +- .../{v2 => }/org_idp_gitlab/resource_test.go | 4 +- .../org_idp_gitlab_self_hosted/datasource.go | 6 +- .../org_idp_gitlab_self_hosted/funcs.go | 6 +- .../org_idp_gitlab_self_hosted/resource.go | 8 +- .../resource_test.go | 4 +- zitadel/{v2 => }/org_idp_google/datasource.go | 4 +- zitadel/{v2 => }/org_idp_google/funcs.go | 4 +- .../org_idp_google_test_dep/dependency.go | 4 +- zitadel/{v2 => }/org_idp_google/resource.go | 6 +- .../{v2 => }/org_idp_google/resource_test.go | 4 +- zitadel/{v2 => }/org_idp_jwt/const.go | 0 zitadel/{v2 => }/org_idp_jwt/datasource.go | 2 +- zitadel/{v2 => }/org_idp_jwt/funcs.go | 2 +- zitadel/{v2 => }/org_idp_jwt/resource.go | 4 +- zitadel/{v2 => }/org_idp_jwt/resource_test.go | 6 +- zitadel/{v2 => }/org_idp_ldap/datasource.go | 6 +- zitadel/{v2 => }/org_idp_ldap/funcs.go | 6 +- zitadel/{v2 => }/org_idp_ldap/resource.go | 8 +- .../{v2 => }/org_idp_ldap/resource_test.go | 4 +- zitadel/{v2 => }/org_idp_oidc/datasource.go | 4 +- zitadel/{v2 => }/org_idp_oidc/funcs.go | 4 +- zitadel/{v2 => }/org_idp_oidc/resource.go | 6 +- .../{v2 => }/org_idp_oidc/resource_test.go | 4 +- zitadel/{v2 => }/org_idp_oidc/schema.go | 0 zitadel/{v2 => }/org_idp_utils/funcs.go | 2 +- .../org_idp_test_utils/checks.go | 2 +- .../org_idp_test_utils/lifecyletest.go | 6 +- zitadel/{v2 => }/org_member/const.go | 0 zitadel/{v2 => }/org_member/funcs.go | 2 +- zitadel/{v2 => }/org_member/resource.go | 2 +- zitadel/{v2 => }/org_member/resource_test.go | 8 +- .../password_change_message_text/resource.go | 2 +- .../resource_test.go | 4 +- .../password_complexity_policy/const.go | 0 .../password_complexity_policy/funcs.go | 2 +- .../password_complexity_policy/resource.go | 2 +- .../resource_test.go | 4 +- .../password_reset_message_text/resource.go | 2 +- .../resource_test.go | 4 +- .../resource.go | 2 +- .../resource_test.go | 4 +- zitadel/{v2 => }/pat/const.go | 0 zitadel/{v2 => }/pat/funcs.go | 2 +- zitadel/{v2 => }/pat/resource.go | 2 +- zitadel/{v2 => }/pat/resource_test.go | 8 +- zitadel/{v2 => }/privacy_policy/const.go | 0 zitadel/{v2 => }/privacy_policy/funcs.go | 2 +- zitadel/{v2 => }/privacy_policy/resource.go | 2 +- .../{v2 => }/privacy_policy/resource_test.go | 6 +- zitadel/{v2 => }/project/const.go | 0 zitadel/{v2 => }/project/datasource.go | 2 +- zitadel/{v2 => }/project/funcs.go | 2 +- .../project/project_test_dep/dependency.go | 4 +- zitadel/{v2 => }/project/resource.go | 2 +- zitadel/{v2 => }/project/resource_test.go | 6 +- zitadel/{v2 => }/project_grant/const.go | 0 zitadel/{v2 => }/project_grant/funcs.go | 2 +- .../project_grant_test_dep/dependency.go | 2 +- zitadel/{v2 => }/project_grant/resource.go | 2 +- .../{v2 => }/project_grant/resource_test.go | 12 +- .../{v2 => }/project_grant_member/const.go | 0 .../{v2 => }/project_grant_member/funcs.go | 2 +- .../{v2 => }/project_grant_member/resource.go | 2 +- .../project_grant_member/resource_test.go | 14 +- zitadel/{v2 => }/project_member/const.go | 0 zitadel/{v2 => }/project_member/funcs.go | 2 +- zitadel/{v2 => }/project_member/resource.go | 2 +- .../{v2 => }/project_member/resource_test.go | 12 +- zitadel/{v2 => }/project_role/const.go | 0 zitadel/{v2 => }/project_role/datasource.go | 2 +- zitadel/{v2 => }/project_role/funcs.go | 2 +- .../project_role_test_dep/dependency.go | 4 +- zitadel/{v2 => }/project_role/resource.go | 2 +- .../{v2 => }/project_role/resource_test.go | 8 +- zitadel/provider.go | 138 +++++++++--------- zitadel/{v2 => }/sms_provider_twilio/const.go | 0 zitadel/{v2 => }/sms_provider_twilio/funcs.go | 2 +- .../{v2 => }/sms_provider_twilio/resource.go | 2 +- .../sms_provider_twilio/resource_test.go | 6 +- zitadel/{v2 => }/smtp_config/const.go | 0 zitadel/{v2 => }/smtp_config/funcs.go | 2 +- zitadel/{v2 => }/smtp_config/resource.go | 2 +- zitadel/{v2 => }/smtp_config/resource_test.go | 6 +- zitadel/{v2 => }/trigger_actions/const.go | 0 .../{v2 => }/trigger_actions/datasource.go | 2 +- zitadel/{v2 => }/trigger_actions/funcs.go | 2 +- zitadel/{v2 => }/trigger_actions/resource.go | 2 +- .../{v2 => }/trigger_actions/resource_test.go | 8 +- zitadel/{v2 => }/user_grant/const.go | 0 zitadel/{v2 => }/user_grant/funcs.go | 2 +- zitadel/{v2 => }/user_grant/resource.go | 2 +- zitadel/{v2 => }/user_grant/resource_test.go | 12 +- .../verify_email_message_text/resource.go | 2 +- .../resource_test.go | 4 +- .../verify_phone_message_text/resource.go | 2 +- .../resource_test.go | 4 +- 292 files changed, 506 insertions(+), 506 deletions(-) rename zitadel/{v2 => }/action/action_test_dep/dependency.go (81%) rename zitadel/{v2 => }/action/const.go (100%) rename zitadel/{v2 => }/action/datasource.go (94%) rename zitadel/{v2 => }/action/funcs.go (98%) rename zitadel/{v2 => }/action/resource.go (95%) rename zitadel/{v2 => }/action/resource_test.go (92%) rename zitadel/{v2 => }/application_api/application_api_test_dep/dependency.go (81%) rename zitadel/{v2 => }/application_api/const.go (100%) rename zitadel/{v2 => }/application_api/datasource.go (93%) rename zitadel/{v2 => }/application_api/funcs.go (98%) rename zitadel/{v2 => }/application_api/resource.go (96%) rename zitadel/{v2 => }/application_api/resource_test.go (86%) rename zitadel/{v2 => }/application_key/const.go (100%) rename zitadel/{v2 => }/application_key/funcs.go (98%) rename zitadel/{v2 => }/application_key/resource.go (96%) rename zitadel/{v2 => }/application_key/resource_test.go (84%) rename zitadel/{v2 => }/application_oidc/const.go (100%) rename zitadel/{v2 => }/application_oidc/datasource.go (97%) rename zitadel/{v2 => }/application_oidc/funcs.go (99%) rename zitadel/{v2 => }/application_oidc/resource.go (98%) rename zitadel/{v2 => }/application_oidc/resource_test.go (86%) rename zitadel/{v2 => }/default_domain_claimed_message_text/resource.go (99%) rename zitadel/{v2 => }/default_domain_claimed_message_text/resource_test.go (91%) rename zitadel/{v2 => }/default_domain_policy/const.go (100%) rename zitadel/{v2 => }/default_domain_policy/funcs.go (97%) rename zitadel/{v2 => }/default_domain_policy/resource.go (92%) rename zitadel/{v2 => }/default_domain_policy/resource_test.go (88%) rename zitadel/{v2 => }/default_init_message_text/resource.go (98%) rename zitadel/{v2 => }/default_init_message_text/resource_test.go (90%) rename zitadel/{v2 => }/default_label_policy/const.go (100%) rename zitadel/{v2 => }/default_label_policy/funcs.go (98%) rename zitadel/{v2 => }/default_label_policy/resource.go (98%) rename zitadel/{v2 => }/default_label_policy/resource_test.go (93%) rename zitadel/{v2 => }/default_lockout_policy/const.go (100%) rename zitadel/{v2 => }/default_lockout_policy/funcs.go (97%) rename zitadel/{v2 => }/default_lockout_policy/resource.go (91%) rename zitadel/{v2 => }/default_lockout_policy/resource_test.go (87%) rename zitadel/{v2 => }/default_login_policy/const.go (100%) rename zitadel/{v2 => }/default_login_policy/funcs.go (99%) rename zitadel/{v2 => }/default_login_policy/resource.go (98%) rename zitadel/{v2 => }/default_login_policy/resource_test.go (79%) rename zitadel/{v2 => }/default_login_texts/resource.go (98%) rename zitadel/{v2 => }/default_login_texts/resource_test.go (91%) rename zitadel/{v2 => }/default_notification_policy/const.go (100%) rename zitadel/{v2 => }/default_notification_policy/funcs.go (97%) rename zitadel/{v2 => }/default_notification_policy/resource.go (89%) rename zitadel/{v2 => }/default_notification_policy/resource_test.go (90%) rename zitadel/{v2 => }/default_oidc_settings/const.go (100%) rename zitadel/{v2 => }/default_oidc_settings/datasource.go (100%) rename zitadel/{v2 => }/default_oidc_settings/funcs.go (98%) rename zitadel/{v2 => }/default_oidc_settings/resource.go (93%) rename zitadel/{v2 => }/default_oidc_settings/resource_test.go (86%) rename zitadel/{v2 => }/default_password_change_message_text/resource.go (99%) rename zitadel/{v2 => }/default_password_change_message_text/resource_test.go (90%) rename zitadel/{v2 => }/default_password_complexity_policy/const.go (100%) rename zitadel/{v2 => }/default_password_complexity_policy/funcs.go (97%) rename zitadel/{v2 => }/default_password_complexity_policy/resource.go (94%) rename zitadel/{v2 => }/default_password_complexity_policy/resource_test.go (87%) rename zitadel/{v2 => }/default_password_reset_message_text/resource.go (99%) rename zitadel/{v2 => }/default_password_reset_message_text/resource_test.go (90%) rename zitadel/{v2 => }/default_passwordless_registration_message_text/resource.go (99%) rename zitadel/{v2 => }/default_passwordless_registration_message_text/resource_test.go (90%) rename zitadel/{v2 => }/default_privacy_policy/const.go (100%) rename zitadel/{v2 => }/default_privacy_policy/funcs.go (97%) rename zitadel/{v2 => }/default_privacy_policy/resource.go (92%) rename zitadel/{v2 => }/default_privacy_policy/resource_test.go (86%) rename zitadel/{v2 => }/default_verify_email_message_text/resource.go (99%) rename zitadel/{v2 => }/default_verify_email_message_text/resource_test.go (90%) rename zitadel/{v2 => }/default_verify_phone_message_text/resource.go (99%) rename zitadel/{v2 => }/default_verify_phone_message_text/resource_test.go (90%) rename zitadel/{v2 => }/domain/const.go (100%) rename zitadel/{v2 => }/domain/funcs.go (98%) rename zitadel/{v2 => }/domain/resource.go (94%) rename zitadel/{v2 => }/domain/resource_test.go (92%) rename zitadel/{v2 => }/domain_claimed_message_text/resource.go (99%) rename zitadel/{v2 => }/domain_claimed_message_text/resource_test.go (91%) rename zitadel/{v2 => }/domain_policy/const.go (100%) rename zitadel/{v2 => }/domain_policy/funcs.go (98%) rename zitadel/{v2 => }/domain_policy/resource.go (92%) rename zitadel/{v2 => }/domain_policy/resource_test.go (89%) rename zitadel/{v2 => }/helper/client.go (100%) rename zitadel/{v2 => }/helper/form.go (100%) rename zitadel/{v2 => }/helper/helper.go (100%) rename zitadel/{v2 => }/helper/import.go (100%) rename zitadel/{v2 => }/helper/import_test.go (100%) rename zitadel/{v2 => }/helper/schema.go (100%) rename zitadel/{v2 => }/helper/test_utils/base_frame.go (97%) rename zitadel/{v2 => }/helper/test_utils/checks.go (100%) rename zitadel/{v2 => }/helper/test_utils/datasourcetest.go (100%) rename zitadel/{v2 => }/helper/test_utils/dependency.go (100%) rename zitadel/{v2 => }/helper/test_utils/example.go (100%) rename zitadel/{v2 => }/helper/test_utils/import_id.go (96%) rename zitadel/{v2 => }/helper/test_utils/instance_frame.go (92%) rename zitadel/{v2 => }/helper/test_utils/lifecyletest.go (100%) rename zitadel/{v2 => }/helper/test_utils/org_frame.go (96%) rename zitadel/{v2 => }/human_user/const.go (100%) rename zitadel/{v2 => }/human_user/datasource.go (97%) rename zitadel/{v2 => }/human_user/funcs.go (99%) rename zitadel/{v2 => }/human_user/human_user_test_dep/dependency.go (82%) rename zitadel/{v2 => }/human_user/resource.go (98%) rename zitadel/{v2 => }/human_user/resource_test.go (90%) rename zitadel/{v2 => }/idp_azure_ad/datasource.go (94%) rename zitadel/{v2 => }/idp_azure_ad/funcs.go (97%) rename zitadel/{v2 => }/idp_azure_ad/idp_azure_ad_test_dep/dependency.go (83%) rename zitadel/{v2 => }/idp_azure_ad/resource.go (90%) rename zitadel/{v2 => }/idp_azure_ad/resource_test.go (55%) rename zitadel/{v2 => }/idp_azure_ad/schema.go (95%) rename zitadel/{v2 => }/idp_github/datasource.go (93%) rename zitadel/{v2 => }/idp_github/funcs.go (95%) rename zitadel/{v2 => }/idp_github/resource.go (88%) rename zitadel/{v2 => }/idp_github/resource_test.go (55%) rename zitadel/{v2 => }/idp_github_es/datasource.go (94%) rename zitadel/{v2 => }/idp_github_es/funcs.go (96%) rename zitadel/{v2 => }/idp_github_es/resource.go (90%) rename zitadel/{v2 => }/idp_github_es/resource_test.go (56%) rename zitadel/{v2 => }/idp_github_es/schema.go (100%) rename zitadel/{v2 => }/idp_gitlab/datasource.go (93%) rename zitadel/{v2 => }/idp_gitlab/funcs.go (95%) rename zitadel/{v2 => }/idp_gitlab/resource.go (88%) rename zitadel/{v2 => }/idp_gitlab/resource_test.go (55%) rename zitadel/{v2 => }/idp_gitlab_self_hosted/datasource.go (93%) rename zitadel/{v2 => }/idp_gitlab_self_hosted/funcs.go (96%) rename zitadel/{v2 => }/idp_gitlab_self_hosted/resource.go (89%) rename zitadel/{v2 => }/idp_gitlab_self_hosted/resource_test.go (59%) rename zitadel/{v2 => }/idp_gitlab_self_hosted/schema.go (100%) rename zitadel/{v2 => }/idp_google/datasource.go (93%) rename zitadel/{v2 => }/idp_google/funcs.go (95%) rename zitadel/{v2 => }/idp_google/idp_google_test_dep/dependency.go (78%) rename zitadel/{v2 => }/idp_google/resource.go (88%) rename zitadel/{v2 => }/idp_google/resource_test.go (55%) rename zitadel/{v2 => }/idp_ldap/datasource.go (96%) rename zitadel/{v2 => }/idp_ldap/funcs.go (98%) rename zitadel/{v2 => }/idp_ldap/resource.go (94%) rename zitadel/{v2 => }/idp_ldap/resource_test.go (54%) rename zitadel/{v2 => }/idp_ldap/schema.go (100%) rename zitadel/{v2 => }/idp_utils/funcs.go (95%) rename zitadel/{v2 => }/idp_utils/idp_test_utils/checks.go (93%) rename zitadel/{v2 => }/idp_utils/idp_test_utils/lifecyletest.go (85%) rename zitadel/{v2 => }/idp_utils/schema.go (100%) rename zitadel/{v2 => }/init_message_text/resource.go (99%) rename zitadel/{v2 => }/init_message_text/resource_test.go (91%) rename zitadel/{v2 => }/instance_member/const.go (100%) rename zitadel/{v2 => }/instance_member/funcs.go (98%) rename zitadel/{v2 => }/instance_member/resource.go (93%) rename zitadel/{v2 => }/instance_member/resource_test.go (87%) rename zitadel/{v2 => }/label_policy/const.go (100%) rename zitadel/{v2 => }/label_policy/funcs.go (99%) rename zitadel/{v2 => }/label_policy/resource.go (98%) rename zitadel/{v2 => }/label_policy/resource_test.go (93%) rename zitadel/{v2 => }/lockout_policy/const.go (100%) rename zitadel/{v2 => }/lockout_policy/funcs.go (97%) rename zitadel/{v2 => }/lockout_policy/resource.go (91%) rename zitadel/{v2 => }/lockout_policy/resource_test.go (91%) rename zitadel/{v2 => }/login_policy/const.go (100%) rename zitadel/{v2 => }/login_policy/funcs.go (99%) rename zitadel/{v2 => }/login_policy/resource.go (98%) rename zitadel/{v2 => }/login_policy/resource_test.go (80%) rename zitadel/{v2 => }/login_texts/resource.go (99%) rename zitadel/{v2 => }/login_texts/resource_test.go (91%) rename zitadel/{v2 => }/machine_key/const.go (100%) rename zitadel/{v2 => }/machine_key/funcs.go (97%) rename zitadel/{v2 => }/machine_key/resource.go (95%) rename zitadel/{v2 => }/machine_key/resource_test.go (86%) rename zitadel/{v2 => }/machine_user/const.go (100%) rename zitadel/{v2 => }/machine_user/datasource.go (95%) rename zitadel/{v2 => }/machine_user/funcs.go (98%) rename zitadel/{v2 => }/machine_user/machine_user_test_dep/dependency.go (77%) rename zitadel/{v2 => }/machine_user/resource.go (97%) rename zitadel/{v2 => }/machine_user/resource_test.go (89%) rename zitadel/{v2 => }/notification_policy/const.go (100%) rename zitadel/{v2 => }/notification_policy/funcs.go (98%) rename zitadel/{v2 => }/notification_policy/resource.go (90%) rename zitadel/{v2 => }/notification_policy/resource_test.go (90%) rename zitadel/{v2 => }/org/const.go (100%) rename zitadel/{v2 => }/org/datasource.go (98%) rename zitadel/{v2 => }/org/datasource_test.go (94%) rename zitadel/{v2 => }/org/funcs.go (98%) rename zitadel/{v2 => }/org/org_test_dep/dependency.go (77%) rename zitadel/{v2 => }/org/remote_test.go (92%) rename zitadel/{v2 => }/org/resource.go (93%) rename zitadel/{v2 => }/org/resource_test.go (84%) rename zitadel/{v2 => }/org_idp_azure_ad/datasource.go (85%) rename zitadel/{v2 => }/org_idp_azure_ad/funcs.go (95%) rename zitadel/{v2 => }/org_idp_azure_ad/resource.go (82%) rename zitadel/{v2 => }/org_idp_azure_ad/resource_test.go (54%) rename zitadel/{v2 => }/org_idp_github/datasource.go (88%) rename zitadel/{v2 => }/org_idp_github/funcs.go (96%) rename zitadel/{v2 => }/org_idp_github/resource.go (84%) rename zitadel/{v2 => }/org_idp_github/resource_test.go (53%) rename zitadel/{v2 => }/org_idp_github_es/datasource.go (86%) rename zitadel/{v2 => }/org_idp_github_es/funcs.go (95%) rename zitadel/{v2 => }/org_idp_github_es/resource.go (83%) rename zitadel/{v2 => }/org_idp_github_es/resource_test.go (54%) rename zitadel/{v2 => }/org_idp_gitlab/datasource.go (88%) rename zitadel/{v2 => }/org_idp_gitlab/funcs.go (96%) rename zitadel/{v2 => }/org_idp_gitlab/resource.go (84%) rename zitadel/{v2 => }/org_idp_gitlab/resource_test.go (53%) rename zitadel/{v2 => }/org_idp_gitlab_self_hosted/datasource.go (83%) rename zitadel/{v2 => }/org_idp_gitlab_self_hosted/funcs.go (94%) rename zitadel/{v2 => }/org_idp_gitlab_self_hosted/resource.go (81%) rename zitadel/{v2 => }/org_idp_gitlab_self_hosted/resource_test.go (57%) rename zitadel/{v2 => }/org_idp_google/datasource.go (88%) rename zitadel/{v2 => }/org_idp_google/funcs.go (96%) rename zitadel/{v2 => }/org_idp_google/org_idp_google_test_dep/dependency.go (77%) rename zitadel/{v2 => }/org_idp_google/resource.go (84%) rename zitadel/{v2 => }/org_idp_google/resource_test.go (53%) rename zitadel/{v2 => }/org_idp_jwt/const.go (100%) rename zitadel/{v2 => }/org_idp_jwt/datasource.go (96%) rename zitadel/{v2 => }/org_idp_jwt/funcs.go (98%) rename zitadel/{v2 => }/org_idp_jwt/resource.go (93%) rename zitadel/{v2 => }/org_idp_jwt/resource_test.go (88%) rename zitadel/{v2 => }/org_idp_ldap/datasource.go (92%) rename zitadel/{v2 => }/org_idp_ldap/funcs.go (97%) rename zitadel/{v2 => }/org_idp_ldap/resource.go (90%) rename zitadel/{v2 => }/org_idp_ldap/resource_test.go (53%) rename zitadel/{v2 => }/org_idp_oidc/datasource.go (89%) rename zitadel/{v2 => }/org_idp_oidc/funcs.go (96%) rename zitadel/{v2 => }/org_idp_oidc/resource.go (85%) rename zitadel/{v2 => }/org_idp_oidc/resource_test.go (53%) rename zitadel/{v2 => }/org_idp_oidc/schema.go (100%) rename zitadel/{v2 => }/org_idp_utils/funcs.go (91%) rename zitadel/{v2 => }/org_idp_utils/org_idp_test_utils/checks.go (93%) rename zitadel/{v2 => }/org_idp_utils/org_idp_test_utils/lifecyletest.go (85%) rename zitadel/{v2 => }/org_member/const.go (100%) rename zitadel/{v2 => }/org_member/funcs.go (98%) rename zitadel/{v2 => }/org_member/resource.go (93%) rename zitadel/{v2 => }/org_member/resource_test.go (87%) rename zitadel/{v2 => }/password_change_message_text/resource.go (99%) rename zitadel/{v2 => }/password_change_message_text/resource_test.go (91%) rename zitadel/{v2 => }/password_complexity_policy/const.go (100%) rename zitadel/{v2 => }/password_complexity_policy/funcs.go (98%) rename zitadel/{v2 => }/password_complexity_policy/resource.go (95%) rename zitadel/{v2 => }/password_complexity_policy/resource_test.go (91%) rename zitadel/{v2 => }/password_reset_message_text/resource.go (99%) rename zitadel/{v2 => }/password_reset_message_text/resource_test.go (91%) rename zitadel/{v2 => }/passwordless_registration_message_text/resource.go (99%) rename zitadel/{v2 => }/passwordless_registration_message_text/resource_test.go (91%) rename zitadel/{v2 => }/pat/const.go (100%) rename zitadel/{v2 => }/pat/funcs.go (97%) rename zitadel/{v2 => }/pat/resource.go (94%) rename zitadel/{v2 => }/pat/resource_test.go (86%) rename zitadel/{v2 => }/privacy_policy/const.go (100%) rename zitadel/{v2 => }/privacy_policy/funcs.go (98%) rename zitadel/{v2 => }/privacy_policy/resource.go (93%) rename zitadel/{v2 => }/privacy_policy/resource_test.go (86%) rename zitadel/{v2 => }/project/const.go (100%) rename zitadel/{v2 => }/project/datasource.go (95%) rename zitadel/{v2 => }/project/funcs.go (98%) rename zitadel/{v2 => }/project/project_test_dep/dependency.go (74%) rename zitadel/{v2 => }/project/resource.go (97%) rename zitadel/{v2 => }/project/resource_test.go (88%) rename zitadel/{v2 => }/project_grant/const.go (100%) rename zitadel/{v2 => }/project_grant/funcs.go (98%) rename zitadel/{v2 => }/project_grant/project_grant_test_dep/dependency.go (85%) rename zitadel/{v2 => }/project_grant/resource.go (94%) rename zitadel/{v2 => }/project_grant/resource_test.go (82%) rename zitadel/{v2 => }/project_grant_member/const.go (100%) rename zitadel/{v2 => }/project_grant_member/funcs.go (98%) rename zitadel/{v2 => }/project_grant_member/resource.go (95%) rename zitadel/{v2 => }/project_grant_member/resource_test.go (84%) rename zitadel/{v2 => }/project_member/const.go (100%) rename zitadel/{v2 => }/project_member/funcs.go (98%) rename zitadel/{v2 => }/project_member/resource.go (94%) rename zitadel/{v2 => }/project_member/resource_test.go (83%) rename zitadel/{v2 => }/project_role/const.go (100%) rename zitadel/{v2 => }/project_role/datasource.go (93%) rename zitadel/{v2 => }/project_role/funcs.go (98%) rename zitadel/{v2 => }/project_role/project_role_test_dep/dependency.go (80%) rename zitadel/{v2 => }/project_role/resource.go (94%) rename zitadel/{v2 => }/project_role/resource_test.go (88%) rename zitadel/{v2 => }/sms_provider_twilio/const.go (100%) rename zitadel/{v2 => }/sms_provider_twilio/funcs.go (98%) rename zitadel/{v2 => }/sms_provider_twilio/resource.go (93%) rename zitadel/{v2 => }/sms_provider_twilio/resource_test.go (88%) rename zitadel/{v2 => }/smtp_config/const.go (100%) rename zitadel/{v2 => }/smtp_config/funcs.go (98%) rename zitadel/{v2 => }/smtp_config/resource.go (95%) rename zitadel/{v2 => }/smtp_config/resource_test.go (91%) rename zitadel/{v2 => }/trigger_actions/const.go (100%) rename zitadel/{v2 => }/trigger_actions/datasource.go (92%) rename zitadel/{v2 => }/trigger_actions/funcs.go (98%) rename zitadel/{v2 => }/trigger_actions/resource.go (97%) rename zitadel/{v2 => }/trigger_actions/resource_test.go (89%) rename zitadel/{v2 => }/user_grant/const.go (100%) rename zitadel/{v2 => }/user_grant/funcs.go (98%) rename zitadel/{v2 => }/user_grant/resource.go (94%) rename zitadel/{v2 => }/user_grant/resource_test.go (81%) rename zitadel/{v2 => }/verify_email_message_text/resource.go (99%) rename zitadel/{v2 => }/verify_email_message_text/resource_test.go (91%) rename zitadel/{v2 => }/verify_phone_message_text/resource.go (99%) rename zitadel/{v2 => }/verify_phone_message_text/resource_test.go (91%) diff --git a/zitadel/v2/action/action_test_dep/dependency.go b/zitadel/action/action_test_dep/dependency.go similarity index 81% rename from zitadel/v2/action/action_test_dep/dependency.go rename to zitadel/action/action_test_dep/dependency.go index f48aba18..bbe6ee26 100644 --- a/zitadel/v2/action/action_test_dep/dependency.go +++ b/zitadel/action/action_test_dep/dependency.go @@ -7,8 +7,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/action" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { diff --git a/zitadel/v2/action/const.go b/zitadel/action/const.go similarity index 100% rename from zitadel/v2/action/const.go rename to zitadel/action/const.go diff --git a/zitadel/v2/action/datasource.go b/zitadel/action/datasource.go similarity index 94% rename from zitadel/v2/action/datasource.go rename to zitadel/action/datasource.go index e1eda5ca..5ce4c760 100644 --- a/zitadel/v2/action/datasource.go +++ b/zitadel/action/datasource.go @@ -3,7 +3,7 @@ package action import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/action/funcs.go b/zitadel/action/funcs.go similarity index 98% rename from zitadel/v2/action/funcs.go rename to zitadel/action/funcs.go index 6787e96f..53f7bc17 100644 --- a/zitadel/v2/action/funcs.go +++ b/zitadel/action/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/action/resource.go b/zitadel/action/resource.go similarity index 95% rename from zitadel/v2/action/resource.go rename to zitadel/action/resource.go index 5e7cd698..f88b0754 100644 --- a/zitadel/v2/action/resource.go +++ b/zitadel/action/resource.go @@ -3,7 +3,7 @@ package action import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/action/resource_test.go b/zitadel/action/resource_test.go similarity index 92% rename from zitadel/v2/action/resource_test.go rename to zitadel/action/resource_test.go index 02801e26..c71ec072 100644 --- a/zitadel/v2/action/resource_test.go +++ b/zitadel/action/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/action" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccAction(t *testing.T) { diff --git a/zitadel/v2/application_api/application_api_test_dep/dependency.go b/zitadel/application_api/application_api_test_dep/dependency.go similarity index 81% rename from zitadel/v2/application_api/application_api_test_dep/dependency.go rename to zitadel/application_api/application_api_test_dep/dependency.go index 954030ff..4215885a 100644 --- a/zitadel/v2/application_api/application_api_test_dep/dependency.go +++ b/zitadel/application_api/application_api_test_dep/dependency.go @@ -6,8 +6,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID string) (string, string) { diff --git a/zitadel/v2/application_api/const.go b/zitadel/application_api/const.go similarity index 100% rename from zitadel/v2/application_api/const.go rename to zitadel/application_api/const.go diff --git a/zitadel/v2/application_api/datasource.go b/zitadel/application_api/datasource.go similarity index 93% rename from zitadel/v2/application_api/datasource.go rename to zitadel/application_api/datasource.go index bec0f92e..08a91496 100644 --- a/zitadel/v2/application_api/datasource.go +++ b/zitadel/application_api/datasource.go @@ -3,7 +3,7 @@ package application_api import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/application_api/funcs.go b/zitadel/application_api/funcs.go similarity index 98% rename from zitadel/v2/application_api/funcs.go rename to zitadel/application_api/funcs.go index 63b9e3f5..efb610e7 100644 --- a/zitadel/v2/application_api/funcs.go +++ b/zitadel/application_api/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/application_api/resource.go b/zitadel/application_api/resource.go similarity index 96% rename from zitadel/v2/application_api/resource.go rename to zitadel/application_api/resource.go index aa70a290..a95443e3 100644 --- a/zitadel/v2/application_api/resource.go +++ b/zitadel/application_api/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/application_api/resource_test.go b/zitadel/application_api/resource_test.go similarity index 86% rename from zitadel/v2/application_api/resource_test.go rename to zitadel/application_api/resource_test.go index f5183113..cd482699 100644 --- a/zitadel/v2/application_api/resource_test.go +++ b/zitadel/application_api/resource_test.go @@ -8,10 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" ) func TestAccAppAPI(t *testing.T) { diff --git a/zitadel/v2/application_key/const.go b/zitadel/application_key/const.go similarity index 100% rename from zitadel/v2/application_key/const.go rename to zitadel/application_key/const.go diff --git a/zitadel/v2/application_key/funcs.go b/zitadel/application_key/funcs.go similarity index 98% rename from zitadel/v2/application_key/funcs.go rename to zitadel/application_key/funcs.go index a37feb3c..afeb9a88 100644 --- a/zitadel/v2/application_key/funcs.go +++ b/zitadel/application_key/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/timestamppb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/application_key/resource.go b/zitadel/application_key/resource.go similarity index 96% rename from zitadel/v2/application_key/resource.go rename to zitadel/application_key/resource.go index 8a94fa51..3a3f412f 100644 --- a/zitadel/v2/application_key/resource.go +++ b/zitadel/application_key/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/application_key/resource_test.go b/zitadel/application_key/resource_test.go similarity index 84% rename from zitadel/v2/application_key/resource_test.go rename to zitadel/application_key/resource_test.go index 0dd84d79..ead74857 100644 --- a/zitadel/v2/application_key/resource_test.go +++ b/zitadel/application_key/resource_test.go @@ -8,11 +8,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api/application_api_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_key" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_api/application_api_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" ) func TestAccAppKey(t *testing.T) { diff --git a/zitadel/v2/application_oidc/const.go b/zitadel/application_oidc/const.go similarity index 100% rename from zitadel/v2/application_oidc/const.go rename to zitadel/application_oidc/const.go diff --git a/zitadel/v2/application_oidc/datasource.go b/zitadel/application_oidc/datasource.go similarity index 97% rename from zitadel/v2/application_oidc/datasource.go rename to zitadel/application_oidc/datasource.go index b6c4f3f9..00cc3fc2 100644 --- a/zitadel/v2/application_oidc/datasource.go +++ b/zitadel/application_oidc/datasource.go @@ -3,7 +3,7 @@ package application_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/application_oidc/funcs.go b/zitadel/application_oidc/funcs.go similarity index 99% rename from zitadel/v2/application_oidc/funcs.go rename to zitadel/application_oidc/funcs.go index d3ed6972..59c95968 100644 --- a/zitadel/v2/application_oidc/funcs.go +++ b/zitadel/application_oidc/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/application_oidc/resource.go b/zitadel/application_oidc/resource.go similarity index 98% rename from zitadel/v2/application_oidc/resource.go rename to zitadel/application_oidc/resource.go index e48047c6..d83f4603 100644 --- a/zitadel/v2/application_oidc/resource.go +++ b/zitadel/application_oidc/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/app" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/application_oidc/resource_test.go b/zitadel/application_oidc/resource_test.go similarity index 86% rename from zitadel/v2/application_oidc/resource_test.go rename to zitadel/application_oidc/resource_test.go index 1440f895..6b02d07b 100644 --- a/zitadel/v2/application_oidc/resource_test.go +++ b/zitadel/application_oidc/resource_test.go @@ -8,10 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" ) func TestAccAppOIDC(t *testing.T) { diff --git a/zitadel/v2/default_domain_claimed_message_text/resource.go b/zitadel/default_domain_claimed_message_text/resource.go similarity index 99% rename from zitadel/v2/default_domain_claimed_message_text/resource.go rename to zitadel/default_domain_claimed_message_text/resource.go index 34294858..ff51fee5 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource.go +++ b/zitadel/default_domain_claimed_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_domain_claimed_message_text/resource_test.go b/zitadel/default_domain_claimed_message_text/resource_test.go similarity index 91% rename from zitadel/v2/default_domain_claimed_message_text/resource_test.go rename to zitadel/default_domain_claimed_message_text/resource_test.go index 57caa00c..9c5028a2 100644 --- a/zitadel/v2/default_domain_claimed_message_text/resource_test.go +++ b/zitadel/default_domain_claimed_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_domain_claimed_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultDomainClaimedMessageText(t *testing.T) { diff --git a/zitadel/v2/default_domain_policy/const.go b/zitadel/default_domain_policy/const.go similarity index 100% rename from zitadel/v2/default_domain_policy/const.go rename to zitadel/default_domain_policy/const.go diff --git a/zitadel/v2/default_domain_policy/funcs.go b/zitadel/default_domain_policy/funcs.go similarity index 97% rename from zitadel/v2/default_domain_policy/funcs.go rename to zitadel/default_domain_policy/funcs.go index a27ad7a6..512f0158 100644 --- a/zitadel/v2/default_domain_policy/funcs.go +++ b/zitadel/default_domain_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_domain_policy/resource.go b/zitadel/default_domain_policy/resource.go similarity index 92% rename from zitadel/v2/default_domain_policy/resource.go rename to zitadel/default_domain_policy/resource.go index 4671b49c..065be12c 100644 --- a/zitadel/v2/default_domain_policy/resource.go +++ b/zitadel/default_domain_policy/resource.go @@ -3,7 +3,7 @@ package default_domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_domain_policy/resource_test.go b/zitadel/default_domain_policy/resource_test.go similarity index 88% rename from zitadel/v2/default_domain_policy/resource_test.go rename to zitadel/default_domain_policy/resource_test.go index 386b3685..4dc91761 100644 --- a/zitadel/v2/default_domain_policy/resource_test.go +++ b/zitadel/default_domain_policy/resource_test.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultDomainPolicy(t *testing.T) { diff --git a/zitadel/v2/default_init_message_text/resource.go b/zitadel/default_init_message_text/resource.go similarity index 98% rename from zitadel/v2/default_init_message_text/resource.go rename to zitadel/default_init_message_text/resource.go index c8cdb1c8..e5868165 100644 --- a/zitadel/v2/default_init_message_text/resource.go +++ b/zitadel/default_init_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_init_message_text/resource_test.go b/zitadel/default_init_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_init_message_text/resource_test.go rename to zitadel/default_init_message_text/resource_test.go index 10b198ba..e950c7bd 100644 --- a/zitadel/v2/default_init_message_text/resource_test.go +++ b/zitadel/default_init_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_init_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultInitMessageText(t *testing.T) { diff --git a/zitadel/v2/default_label_policy/const.go b/zitadel/default_label_policy/const.go similarity index 100% rename from zitadel/v2/default_label_policy/const.go rename to zitadel/default_label_policy/const.go diff --git a/zitadel/v2/default_label_policy/funcs.go b/zitadel/default_label_policy/funcs.go similarity index 98% rename from zitadel/v2/default_label_policy/funcs.go rename to zitadel/default_label_policy/funcs.go index 3bd7a164..9256e1a6 100644 --- a/zitadel/v2/default_label_policy/funcs.go +++ b/zitadel/default_label_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_label_policy/resource.go b/zitadel/default_label_policy/resource.go similarity index 98% rename from zitadel/v2/default_label_policy/resource.go rename to zitadel/default_label_policy/resource.go index ede42ca8..6a8f3f68 100644 --- a/zitadel/v2/default_label_policy/resource.go +++ b/zitadel/default_label_policy/resource.go @@ -3,7 +3,7 @@ package default_label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_label_policy/resource_test.go b/zitadel/default_label_policy/resource_test.go similarity index 93% rename from zitadel/v2/default_label_policy/resource_test.go rename to zitadel/default_label_policy/resource_test.go index 11402748..6d3c97eb 100644 --- a/zitadel/v2/default_label_policy/resource_test.go +++ b/zitadel/default_label_policy/resource_test.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultLabelPolicy(t *testing.T) { diff --git a/zitadel/v2/default_lockout_policy/const.go b/zitadel/default_lockout_policy/const.go similarity index 100% rename from zitadel/v2/default_lockout_policy/const.go rename to zitadel/default_lockout_policy/const.go diff --git a/zitadel/v2/default_lockout_policy/funcs.go b/zitadel/default_lockout_policy/funcs.go similarity index 97% rename from zitadel/v2/default_lockout_policy/funcs.go rename to zitadel/default_lockout_policy/funcs.go index c8215701..739f4f57 100644 --- a/zitadel/v2/default_lockout_policy/funcs.go +++ b/zitadel/default_lockout_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_lockout_policy/resource.go b/zitadel/default_lockout_policy/resource.go similarity index 91% rename from zitadel/v2/default_lockout_policy/resource.go rename to zitadel/default_lockout_policy/resource.go index 0b296ae6..e86e03cf 100644 --- a/zitadel/v2/default_lockout_policy/resource.go +++ b/zitadel/default_lockout_policy/resource.go @@ -3,7 +3,7 @@ package default_lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_lockout_policy/resource_test.go b/zitadel/default_lockout_policy/resource_test.go similarity index 87% rename from zitadel/v2/default_lockout_policy/resource_test.go rename to zitadel/default_lockout_policy/resource_test.go index a66eafcf..c3c5047a 100644 --- a/zitadel/v2/default_lockout_policy/resource_test.go +++ b/zitadel/default_lockout_policy/resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultLockoutPolicy(t *testing.T) { diff --git a/zitadel/v2/default_login_policy/const.go b/zitadel/default_login_policy/const.go similarity index 100% rename from zitadel/v2/default_login_policy/const.go rename to zitadel/default_login_policy/const.go diff --git a/zitadel/v2/default_login_policy/funcs.go b/zitadel/default_login_policy/funcs.go similarity index 99% rename from zitadel/v2/default_login_policy/funcs.go rename to zitadel/default_login_policy/funcs.go index 345a5f37..1a4eb9e2 100644 --- a/zitadel/v2/default_login_policy/funcs.go +++ b/zitadel/default_login_policy/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_login_policy/resource.go b/zitadel/default_login_policy/resource.go similarity index 98% rename from zitadel/v2/default_login_policy/resource.go rename to zitadel/default_login_policy/resource.go index 54774a6e..a8a383c3 100644 --- a/zitadel/v2/default_login_policy/resource.go +++ b/zitadel/default_login_policy/resource.go @@ -3,7 +3,7 @@ package default_login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_login_policy/resource_test.go b/zitadel/default_login_policy/resource_test.go similarity index 79% rename from zitadel/v2/default_login_policy/resource_test.go rename to zitadel/default_login_policy/resource_test.go index f955c639..14b4d0aa 100644 --- a/zitadel/v2/default_login_policy/resource_test.go +++ b/zitadel/default_login_policy/resource_test.go @@ -8,11 +8,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad/idp_azure_ad_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_google/idp_google_test_dep" ) func TestAccDefaultLoginPolicy(t *testing.T) { diff --git a/zitadel/v2/default_login_texts/resource.go b/zitadel/default_login_texts/resource.go similarity index 98% rename from zitadel/v2/default_login_texts/resource.go rename to zitadel/default_login_texts/resource.go index 37aab426..eabf46f6 100644 --- a/zitadel/v2/default_login_texts/resource.go +++ b/zitadel/default_login_texts/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_login_texts/resource_test.go b/zitadel/default_login_texts/resource_test.go similarity index 91% rename from zitadel/v2/default_login_texts/resource_test.go rename to zitadel/default_login_texts/resource_test.go index f9ca5647..a6bb1b92 100644 --- a/zitadel/v2/default_login_texts/resource_test.go +++ b/zitadel/default_login_texts/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_texts" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_login_texts" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultLoginTexts(t *testing.T) { diff --git a/zitadel/v2/default_notification_policy/const.go b/zitadel/default_notification_policy/const.go similarity index 100% rename from zitadel/v2/default_notification_policy/const.go rename to zitadel/default_notification_policy/const.go diff --git a/zitadel/v2/default_notification_policy/funcs.go b/zitadel/default_notification_policy/funcs.go similarity index 97% rename from zitadel/v2/default_notification_policy/funcs.go rename to zitadel/default_notification_policy/funcs.go index 42906f19..4443ec59 100644 --- a/zitadel/v2/default_notification_policy/funcs.go +++ b/zitadel/default_notification_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_notification_policy/resource.go b/zitadel/default_notification_policy/resource.go similarity index 89% rename from zitadel/v2/default_notification_policy/resource.go rename to zitadel/default_notification_policy/resource.go index 091499be..ae8dbc02 100644 --- a/zitadel/v2/default_notification_policy/resource.go +++ b/zitadel/default_notification_policy/resource.go @@ -3,7 +3,7 @@ package default_notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_notification_policy/resource_test.go b/zitadel/default_notification_policy/resource_test.go similarity index 90% rename from zitadel/v2/default_notification_policy/resource_test.go rename to zitadel/default_notification_policy/resource_test.go index 5ac1c180..636af87e 100644 --- a/zitadel/v2/default_notification_policy/resource_test.go +++ b/zitadel/default_notification_policy/resource_test.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultNotificationPolicy(t *testing.T) { diff --git a/zitadel/v2/default_oidc_settings/const.go b/zitadel/default_oidc_settings/const.go similarity index 100% rename from zitadel/v2/default_oidc_settings/const.go rename to zitadel/default_oidc_settings/const.go diff --git a/zitadel/v2/default_oidc_settings/datasource.go b/zitadel/default_oidc_settings/datasource.go similarity index 100% rename from zitadel/v2/default_oidc_settings/datasource.go rename to zitadel/default_oidc_settings/datasource.go diff --git a/zitadel/v2/default_oidc_settings/funcs.go b/zitadel/default_oidc_settings/funcs.go similarity index 98% rename from zitadel/v2/default_oidc_settings/funcs.go rename to zitadel/default_oidc_settings/funcs.go index 02993763..1465ea38 100644 --- a/zitadel/v2/default_oidc_settings/funcs.go +++ b/zitadel/default_oidc_settings/funcs.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_oidc_settings/resource.go b/zitadel/default_oidc_settings/resource.go similarity index 93% rename from zitadel/v2/default_oidc_settings/resource.go rename to zitadel/default_oidc_settings/resource.go index 73fa27f2..70e2bb10 100644 --- a/zitadel/v2/default_oidc_settings/resource.go +++ b/zitadel/default_oidc_settings/resource.go @@ -3,7 +3,7 @@ package default_oidc_settings import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_oidc_settings/resource_test.go b/zitadel/default_oidc_settings/resource_test.go similarity index 86% rename from zitadel/v2/default_oidc_settings/resource_test.go rename to zitadel/default_oidc_settings/resource_test.go index a164a537..bb215903 100644 --- a/zitadel/v2/default_oidc_settings/resource_test.go +++ b/zitadel/default_oidc_settings/resource_test.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_oidc_settings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultOIDCSettings(t *testing.T) { diff --git a/zitadel/v2/default_password_change_message_text/resource.go b/zitadel/default_password_change_message_text/resource.go similarity index 99% rename from zitadel/v2/default_password_change_message_text/resource.go rename to zitadel/default_password_change_message_text/resource.go index d76eb47d..2ac3b630 100644 --- a/zitadel/v2/default_password_change_message_text/resource.go +++ b/zitadel/default_password_change_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_password_change_message_text/resource_test.go b/zitadel/default_password_change_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_password_change_message_text/resource_test.go rename to zitadel/default_password_change_message_text/resource_test.go index 8d149e49..60d37d96 100644 --- a/zitadel/v2/default_password_change_message_text/resource_test.go +++ b/zitadel/default_password_change_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_change_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_change_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultPasswordChangeMessageText(t *testing.T) { diff --git a/zitadel/v2/default_password_complexity_policy/const.go b/zitadel/default_password_complexity_policy/const.go similarity index 100% rename from zitadel/v2/default_password_complexity_policy/const.go rename to zitadel/default_password_complexity_policy/const.go diff --git a/zitadel/v2/default_password_complexity_policy/funcs.go b/zitadel/default_password_complexity_policy/funcs.go similarity index 97% rename from zitadel/v2/default_password_complexity_policy/funcs.go rename to zitadel/default_password_complexity_policy/funcs.go index 6c690c9b..c29a8daf 100644 --- a/zitadel/v2/default_password_complexity_policy/funcs.go +++ b/zitadel/default_password_complexity_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_password_complexity_policy/resource.go b/zitadel/default_password_complexity_policy/resource.go similarity index 94% rename from zitadel/v2/default_password_complexity_policy/resource.go rename to zitadel/default_password_complexity_policy/resource.go index dbf7d213..6ec20337 100644 --- a/zitadel/v2/default_password_complexity_policy/resource.go +++ b/zitadel/default_password_complexity_policy/resource.go @@ -3,7 +3,7 @@ package default_password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_password_complexity_policy/resource_test.go b/zitadel/default_password_complexity_policy/resource_test.go similarity index 87% rename from zitadel/v2/default_password_complexity_policy/resource_test.go rename to zitadel/default_password_complexity_policy/resource_test.go index c1244a16..f7166d91 100644 --- a/zitadel/v2/default_password_complexity_policy/resource_test.go +++ b/zitadel/default_password_complexity_policy/resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultPasswordComplexityPolicy(t *testing.T) { diff --git a/zitadel/v2/default_password_reset_message_text/resource.go b/zitadel/default_password_reset_message_text/resource.go similarity index 99% rename from zitadel/v2/default_password_reset_message_text/resource.go rename to zitadel/default_password_reset_message_text/resource.go index b92d1ea7..f2b81d55 100644 --- a/zitadel/v2/default_password_reset_message_text/resource.go +++ b/zitadel/default_password_reset_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_password_reset_message_text/resource_test.go b/zitadel/default_password_reset_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_password_reset_message_text/resource_test.go rename to zitadel/default_password_reset_message_text/resource_test.go index cfe61bb6..c9d179f2 100644 --- a/zitadel/v2/default_password_reset_message_text/resource_test.go +++ b/zitadel/default_password_reset_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultPassswordResetMessageText(t *testing.T) { diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource.go b/zitadel/default_passwordless_registration_message_text/resource.go similarity index 99% rename from zitadel/v2/default_passwordless_registration_message_text/resource.go rename to zitadel/default_passwordless_registration_message_text/resource.go index e7ac0df8..76eba735 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource.go +++ b/zitadel/default_passwordless_registration_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go b/zitadel/default_passwordless_registration_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_passwordless_registration_message_text/resource_test.go rename to zitadel/default_passwordless_registration_message_text/resource_test.go index fb54b4e2..8164be16 100644 --- a/zitadel/v2/default_passwordless_registration_message_text/resource_test.go +++ b/zitadel/default_passwordless_registration_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_passwordless_registration_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultPasswordlessRegistrationMessageText(t *testing.T) { diff --git a/zitadel/v2/default_privacy_policy/const.go b/zitadel/default_privacy_policy/const.go similarity index 100% rename from zitadel/v2/default_privacy_policy/const.go rename to zitadel/default_privacy_policy/const.go diff --git a/zitadel/v2/default_privacy_policy/funcs.go b/zitadel/default_privacy_policy/funcs.go similarity index 97% rename from zitadel/v2/default_privacy_policy/funcs.go rename to zitadel/default_privacy_policy/funcs.go index 2caaf970..e3e8b533 100644 --- a/zitadel/v2/default_privacy_policy/funcs.go +++ b/zitadel/default_privacy_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/default_privacy_policy/resource.go b/zitadel/default_privacy_policy/resource.go similarity index 92% rename from zitadel/v2/default_privacy_policy/resource.go rename to zitadel/default_privacy_policy/resource.go index ef95f1b6..6944dff5 100644 --- a/zitadel/v2/default_privacy_policy/resource.go +++ b/zitadel/default_privacy_policy/resource.go @@ -3,7 +3,7 @@ package default_privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/default_privacy_policy/resource_test.go b/zitadel/default_privacy_policy/resource_test.go similarity index 86% rename from zitadel/v2/default_privacy_policy/resource_test.go rename to zitadel/default_privacy_policy/resource_test.go index 0ddd0873..b36c2d56 100644 --- a/zitadel/v2/default_privacy_policy/resource_test.go +++ b/zitadel/default_privacy_policy/resource_test.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_privacy_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultPrivacyPolicy(t *testing.T) { diff --git a/zitadel/v2/default_verify_email_message_text/resource.go b/zitadel/default_verify_email_message_text/resource.go similarity index 99% rename from zitadel/v2/default_verify_email_message_text/resource.go rename to zitadel/default_verify_email_message_text/resource.go index 02be0702..1e0fa702 100644 --- a/zitadel/v2/default_verify_email_message_text/resource.go +++ b/zitadel/default_verify_email_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_verify_email_message_text/resource_test.go b/zitadel/default_verify_email_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_verify_email_message_text/resource_test.go rename to zitadel/default_verify_email_message_text/resource_test.go index b8ef00ec..49b58448 100644 --- a/zitadel/v2/default_verify_email_message_text/resource_test.go +++ b/zitadel/default_verify_email_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_email_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultVerifyEmailMessageText(t *testing.T) { diff --git a/zitadel/v2/default_verify_phone_message_text/resource.go b/zitadel/default_verify_phone_message_text/resource.go similarity index 99% rename from zitadel/v2/default_verify_phone_message_text/resource.go rename to zitadel/default_verify_phone_message_text/resource.go index 0627b881..b6e44e87 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource.go +++ b/zitadel/default_verify_phone_message_text/resource.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/default_verify_phone_message_text/resource_test.go b/zitadel/default_verify_phone_message_text/resource_test.go similarity index 90% rename from zitadel/v2/default_verify_phone_message_text/resource_test.go rename to zitadel/default_verify_phone_message_text/resource_test.go index c04a2879..02bf80e1 100644 --- a/zitadel/v2/default_verify_phone_message_text/resource_test.go +++ b/zitadel/default_verify_phone_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_phone_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_verify_phone_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDefaultVerifyPhoneMessageText(t *testing.T) { diff --git a/zitadel/v2/domain/const.go b/zitadel/domain/const.go similarity index 100% rename from zitadel/v2/domain/const.go rename to zitadel/domain/const.go diff --git a/zitadel/v2/domain/funcs.go b/zitadel/domain/funcs.go similarity index 98% rename from zitadel/v2/domain/funcs.go rename to zitadel/domain/funcs.go index d418e462..e14134f8 100644 --- a/zitadel/v2/domain/funcs.go +++ b/zitadel/domain/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/domain/resource.go b/zitadel/domain/resource.go similarity index 94% rename from zitadel/v2/domain/resource.go rename to zitadel/domain/resource.go index 8a4e774f..5a029457 100644 --- a/zitadel/v2/domain/resource.go +++ b/zitadel/domain/resource.go @@ -3,7 +3,7 @@ package domain import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/domain/resource_test.go b/zitadel/domain/resource_test.go similarity index 92% rename from zitadel/v2/domain/resource_test.go rename to zitadel/domain/resource_test.go index 42e11e5e..cb07c2c0 100644 --- a/zitadel/v2/domain/resource_test.go +++ b/zitadel/domain/resource_test.go @@ -10,8 +10,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/domain" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDomain(t *testing.T) { diff --git a/zitadel/v2/domain_claimed_message_text/resource.go b/zitadel/domain_claimed_message_text/resource.go similarity index 99% rename from zitadel/v2/domain_claimed_message_text/resource.go rename to zitadel/domain_claimed_message_text/resource.go index 6a542c57..1093d74e 100644 --- a/zitadel/v2/domain_claimed_message_text/resource.go +++ b/zitadel/domain_claimed_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/domain_claimed_message_text/resource_test.go b/zitadel/domain_claimed_message_text/resource_test.go similarity index 91% rename from zitadel/v2/domain_claimed_message_text/resource_test.go rename to zitadel/domain_claimed_message_text/resource_test.go index d120648e..92edab90 100644 --- a/zitadel/v2/domain_claimed_message_text/resource_test.go +++ b/zitadel/domain_claimed_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_domain_claimed_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDomainClaimedMessageText(t *testing.T) { diff --git a/zitadel/v2/domain_policy/const.go b/zitadel/domain_policy/const.go similarity index 100% rename from zitadel/v2/domain_policy/const.go rename to zitadel/domain_policy/const.go diff --git a/zitadel/v2/domain_policy/funcs.go b/zitadel/domain_policy/funcs.go similarity index 98% rename from zitadel/v2/domain_policy/funcs.go rename to zitadel/domain_policy/funcs.go index 174fd1bd..4b6c5fc2 100644 --- a/zitadel/v2/domain_policy/funcs.go +++ b/zitadel/domain_policy/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/domain_policy/resource.go b/zitadel/domain_policy/resource.go similarity index 92% rename from zitadel/v2/domain_policy/resource.go rename to zitadel/domain_policy/resource.go index c0f85026..52b59951 100644 --- a/zitadel/v2/domain_policy/resource.go +++ b/zitadel/domain_policy/resource.go @@ -3,7 +3,7 @@ package domain_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/domain_policy/resource_test.go b/zitadel/domain_policy/resource_test.go similarity index 89% rename from zitadel/v2/domain_policy/resource_test.go rename to zitadel/domain_policy/resource_test.go index 6f62c58c..d6f6f949 100644 --- a/zitadel/v2/domain_policy/resource_test.go +++ b/zitadel/domain_policy/resource_test.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccDomainPolicy(t *testing.T) { diff --git a/zitadel/v2/helper/client.go b/zitadel/helper/client.go similarity index 100% rename from zitadel/v2/helper/client.go rename to zitadel/helper/client.go diff --git a/zitadel/v2/helper/form.go b/zitadel/helper/form.go similarity index 100% rename from zitadel/v2/helper/form.go rename to zitadel/helper/form.go diff --git a/zitadel/v2/helper/helper.go b/zitadel/helper/helper.go similarity index 100% rename from zitadel/v2/helper/helper.go rename to zitadel/helper/helper.go diff --git a/zitadel/v2/helper/import.go b/zitadel/helper/import.go similarity index 100% rename from zitadel/v2/helper/import.go rename to zitadel/helper/import.go diff --git a/zitadel/v2/helper/import_test.go b/zitadel/helper/import_test.go similarity index 100% rename from zitadel/v2/helper/import_test.go rename to zitadel/helper/import_test.go diff --git a/zitadel/v2/helper/schema.go b/zitadel/helper/schema.go similarity index 100% rename from zitadel/v2/helper/schema.go rename to zitadel/helper/schema.go diff --git a/zitadel/v2/helper/test_utils/base_frame.go b/zitadel/helper/test_utils/base_frame.go similarity index 97% rename from zitadel/v2/helper/test_utils/base_frame.go rename to zitadel/helper/test_utils/base_frame.go index 7c74fe7b..41b4cbad 100644 --- a/zitadel/v2/helper/test_utils/base_frame.go +++ b/zitadel/helper/test_utils/base_frame.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/terraform-provider-zitadel/zitadel" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/helper/test_utils/checks.go b/zitadel/helper/test_utils/checks.go similarity index 100% rename from zitadel/v2/helper/test_utils/checks.go rename to zitadel/helper/test_utils/checks.go diff --git a/zitadel/v2/helper/test_utils/datasourcetest.go b/zitadel/helper/test_utils/datasourcetest.go similarity index 100% rename from zitadel/v2/helper/test_utils/datasourcetest.go rename to zitadel/helper/test_utils/datasourcetest.go diff --git a/zitadel/v2/helper/test_utils/dependency.go b/zitadel/helper/test_utils/dependency.go similarity index 100% rename from zitadel/v2/helper/test_utils/dependency.go rename to zitadel/helper/test_utils/dependency.go diff --git a/zitadel/v2/helper/test_utils/example.go b/zitadel/helper/test_utils/example.go similarity index 100% rename from zitadel/v2/helper/test_utils/example.go rename to zitadel/helper/test_utils/example.go diff --git a/zitadel/v2/helper/test_utils/import_id.go b/zitadel/helper/test_utils/import_id.go similarity index 96% rename from zitadel/v2/helper/test_utils/import_id.go rename to zitadel/helper/test_utils/import_id.go index 8ed19631..04798234 100644 --- a/zitadel/v2/helper/test_utils/import_id.go +++ b/zitadel/helper/test_utils/import_id.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) var ( diff --git a/zitadel/v2/helper/test_utils/instance_frame.go b/zitadel/helper/test_utils/instance_frame.go similarity index 92% rename from zitadel/v2/helper/test_utils/instance_frame.go rename to zitadel/helper/test_utils/instance_frame.go index 50e151ff..adbe3366 100644 --- a/zitadel/v2/helper/test_utils/instance_frame.go +++ b/zitadel/helper/test_utils/instance_frame.go @@ -7,7 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/admin" "github.com/zitadel/terraform-provider-zitadel/acceptance" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) type InstanceTestFrame struct { diff --git a/zitadel/v2/helper/test_utils/lifecyletest.go b/zitadel/helper/test_utils/lifecyletest.go similarity index 100% rename from zitadel/v2/helper/test_utils/lifecyletest.go rename to zitadel/helper/test_utils/lifecyletest.go diff --git a/zitadel/v2/helper/test_utils/org_frame.go b/zitadel/helper/test_utils/org_frame.go similarity index 96% rename from zitadel/v2/helper/test_utils/org_frame.go rename to zitadel/helper/test_utils/org_frame.go index 3bacf8dd..61737f2a 100644 --- a/zitadel/v2/helper/test_utils/org_frame.go +++ b/zitadel/helper/test_utils/org_frame.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/terraform-provider-zitadel/acceptance" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) type OrgTestFrame struct { diff --git a/zitadel/v2/human_user/const.go b/zitadel/human_user/const.go similarity index 100% rename from zitadel/v2/human_user/const.go rename to zitadel/human_user/const.go diff --git a/zitadel/v2/human_user/datasource.go b/zitadel/human_user/datasource.go similarity index 97% rename from zitadel/v2/human_user/datasource.go rename to zitadel/human_user/datasource.go index f9b7542b..8e774d55 100644 --- a/zitadel/v2/human_user/datasource.go +++ b/zitadel/human_user/datasource.go @@ -3,7 +3,7 @@ package human_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/human_user/funcs.go b/zitadel/human_user/funcs.go similarity index 99% rename from zitadel/v2/human_user/funcs.go rename to zitadel/human_user/funcs.go index 24690e87..75b36606 100644 --- a/zitadel/v2/human_user/funcs.go +++ b/zitadel/human_user/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/human_user/human_user_test_dep/dependency.go b/zitadel/human_user/human_user_test_dep/dependency.go similarity index 82% rename from zitadel/v2/human_user/human_user_test_dep/dependency.go rename to zitadel/human_user/human_user_test_dep/dependency.go index 9cddc7db..b22a971e 100644 --- a/zitadel/v2/human_user/human_user_test_dep/dependency.go +++ b/zitadel/human_user/human_user_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { diff --git a/zitadel/v2/human_user/resource.go b/zitadel/human_user/resource.go similarity index 98% rename from zitadel/v2/human_user/resource.go rename to zitadel/human_user/resource.go index 5d76f5da..49a61033 100644 --- a/zitadel/v2/human_user/resource.go +++ b/zitadel/human_user/resource.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/human_user/resource_test.go b/zitadel/human_user/resource_test.go similarity index 90% rename from zitadel/v2/human_user/resource_test.go rename to zitadel/human_user/resource_test.go index 22065383..7eb88793 100644 --- a/zitadel/v2/human_user/resource_test.go +++ b/zitadel/human_user/resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user" ) func TestAccHumanUser(t *testing.T) { diff --git a/zitadel/v2/idp_azure_ad/datasource.go b/zitadel/idp_azure_ad/datasource.go similarity index 94% rename from zitadel/v2/idp_azure_ad/datasource.go rename to zitadel/idp_azure_ad/datasource.go index 7cf221be..b771f848 100644 --- a/zitadel/v2/idp_azure_ad/datasource.go +++ b/zitadel/idp_azure_ad/datasource.go @@ -3,7 +3,7 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_azure_ad/funcs.go b/zitadel/idp_azure_ad/funcs.go similarity index 97% rename from zitadel/v2/idp_azure_ad/funcs.go rename to zitadel/idp_azure_ad/funcs.go index 74f1e846..c224ab35 100644 --- a/zitadel/v2/idp_azure_ad/funcs.go +++ b/zitadel/idp_azure_ad/funcs.go @@ -9,8 +9,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go b/zitadel/idp_azure_ad/idp_azure_ad_test_dep/dependency.go similarity index 83% rename from zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go rename to zitadel/idp_azure_ad/idp_azure_ad_test_dep/dependency.go index cb424374..4a8d15dd 100644 --- a/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep/dependency.go +++ b/zitadel/idp_azure_ad/idp_azure_ad_test_dep/dependency.go @@ -6,8 +6,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func Create(t *testing.T, frame test_utils.BaseTestFrame, client admin.AdminServiceClient) (string, string) { diff --git a/zitadel/v2/idp_azure_ad/resource.go b/zitadel/idp_azure_ad/resource.go similarity index 90% rename from zitadel/v2/idp_azure_ad/resource.go rename to zitadel/idp_azure_ad/resource.go index 75fe369f..6bff3ede 100644 --- a/zitadel/v2/idp_azure_ad/resource.go +++ b/zitadel/idp_azure_ad/resource.go @@ -3,8 +3,8 @@ package idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_azure_ad/resource_test.go b/zitadel/idp_azure_ad/resource_test.go similarity index 55% rename from zitadel/v2/idp_azure_ad/resource_test.go rename to zitadel/idp_azure_ad/resource_test.go index 3b9b5a39..6258d394 100644 --- a/zitadel/v2/idp_azure_ad/resource_test.go +++ b/zitadel/idp_azure_ad/resource_test.go @@ -3,8 +3,8 @@ package idp_azure_ad_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPAzureAD(t *testing.T) { diff --git a/zitadel/v2/idp_azure_ad/schema.go b/zitadel/idp_azure_ad/schema.go similarity index 95% rename from zitadel/v2/idp_azure_ad/schema.go rename to zitadel/idp_azure_ad/schema.go index 4484e261..34c75e00 100644 --- a/zitadel/v2/idp_azure_ad/schema.go +++ b/zitadel/idp_azure_ad/schema.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/idp_github/datasource.go b/zitadel/idp_github/datasource.go similarity index 93% rename from zitadel/v2/idp_github/datasource.go rename to zitadel/idp_github/datasource.go index 6f2f0136..2f491946 100644 --- a/zitadel/v2/idp_github/datasource.go +++ b/zitadel/idp_github/datasource.go @@ -3,7 +3,7 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_github/funcs.go b/zitadel/idp_github/funcs.go similarity index 95% rename from zitadel/v2/idp_github/funcs.go rename to zitadel/idp_github/funcs.go index 96330b6e..f0910b21 100644 --- a/zitadel/v2/idp_github/funcs.go +++ b/zitadel/idp_github/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_github/resource.go b/zitadel/idp_github/resource.go similarity index 88% rename from zitadel/v2/idp_github/resource.go rename to zitadel/idp_github/resource.go index 80e17809..b618664b 100644 --- a/zitadel/v2/idp_github/resource.go +++ b/zitadel/idp_github/resource.go @@ -3,8 +3,8 @@ package idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_github/resource_test.go b/zitadel/idp_github/resource_test.go similarity index 55% rename from zitadel/v2/idp_github/resource_test.go rename to zitadel/idp_github/resource_test.go index d90785a2..f4ab3df4 100644 --- a/zitadel/v2/idp_github/resource_test.go +++ b/zitadel/idp_github/resource_test.go @@ -3,8 +3,8 @@ package idp_github_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitHub(t *testing.T) { diff --git a/zitadel/v2/idp_github_es/datasource.go b/zitadel/idp_github_es/datasource.go similarity index 94% rename from zitadel/v2/idp_github_es/datasource.go rename to zitadel/idp_github_es/datasource.go index ffae1adf..21eab368 100644 --- a/zitadel/v2/idp_github_es/datasource.go +++ b/zitadel/idp_github_es/datasource.go @@ -3,7 +3,7 @@ package idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_github_es/funcs.go b/zitadel/idp_github_es/funcs.go similarity index 96% rename from zitadel/v2/idp_github_es/funcs.go rename to zitadel/idp_github_es/funcs.go index 101d17a3..150eb457 100644 --- a/zitadel/v2/idp_github_es/funcs.go +++ b/zitadel/idp_github_es/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_github_es/resource.go b/zitadel/idp_github_es/resource.go similarity index 90% rename from zitadel/v2/idp_github_es/resource.go rename to zitadel/idp_github_es/resource.go index fbcebda5..5f7a3de5 100644 --- a/zitadel/v2/idp_github_es/resource.go +++ b/zitadel/idp_github_es/resource.go @@ -3,8 +3,8 @@ package idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_github_es/resource_test.go b/zitadel/idp_github_es/resource_test.go similarity index 56% rename from zitadel/v2/idp_github_es/resource_test.go rename to zitadel/idp_github_es/resource_test.go index 57cb3c89..aa03d45b 100644 --- a/zitadel/v2/idp_github_es/resource_test.go +++ b/zitadel/idp_github_es/resource_test.go @@ -3,8 +3,8 @@ package idp_github_es_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitHubES(t *testing.T) { diff --git a/zitadel/v2/idp_github_es/schema.go b/zitadel/idp_github_es/schema.go similarity index 100% rename from zitadel/v2/idp_github_es/schema.go rename to zitadel/idp_github_es/schema.go diff --git a/zitadel/v2/idp_gitlab/datasource.go b/zitadel/idp_gitlab/datasource.go similarity index 93% rename from zitadel/v2/idp_gitlab/datasource.go rename to zitadel/idp_gitlab/datasource.go index 33025a18..4dff408d 100644 --- a/zitadel/v2/idp_gitlab/datasource.go +++ b/zitadel/idp_gitlab/datasource.go @@ -3,7 +3,7 @@ package idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_gitlab/funcs.go b/zitadel/idp_gitlab/funcs.go similarity index 95% rename from zitadel/v2/idp_gitlab/funcs.go rename to zitadel/idp_gitlab/funcs.go index 4a9ad427..7c094e6c 100644 --- a/zitadel/v2/idp_gitlab/funcs.go +++ b/zitadel/idp_gitlab/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_gitlab/resource.go b/zitadel/idp_gitlab/resource.go similarity index 88% rename from zitadel/v2/idp_gitlab/resource.go rename to zitadel/idp_gitlab/resource.go index aa20f995..8142f15f 100644 --- a/zitadel/v2/idp_gitlab/resource.go +++ b/zitadel/idp_gitlab/resource.go @@ -3,8 +3,8 @@ package idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_gitlab/resource_test.go b/zitadel/idp_gitlab/resource_test.go similarity index 55% rename from zitadel/v2/idp_gitlab/resource_test.go rename to zitadel/idp_gitlab/resource_test.go index 62a232f7..2b21c635 100644 --- a/zitadel/v2/idp_gitlab/resource_test.go +++ b/zitadel/idp_gitlab/resource_test.go @@ -3,8 +3,8 @@ package idp_gitlab_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitLab(t *testing.T) { diff --git a/zitadel/v2/idp_gitlab_self_hosted/datasource.go b/zitadel/idp_gitlab_self_hosted/datasource.go similarity index 93% rename from zitadel/v2/idp_gitlab_self_hosted/datasource.go rename to zitadel/idp_gitlab_self_hosted/datasource.go index 241ac9eb..4f5cf4cf 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/datasource.go +++ b/zitadel/idp_gitlab_self_hosted/datasource.go @@ -3,7 +3,7 @@ package idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_gitlab_self_hosted/funcs.go b/zitadel/idp_gitlab_self_hosted/funcs.go similarity index 96% rename from zitadel/v2/idp_gitlab_self_hosted/funcs.go rename to zitadel/idp_gitlab_self_hosted/funcs.go index 5163c1e0..3049f590 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/funcs.go +++ b/zitadel/idp_gitlab_self_hosted/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource.go b/zitadel/idp_gitlab_self_hosted/resource.go similarity index 89% rename from zitadel/v2/idp_gitlab_self_hosted/resource.go rename to zitadel/idp_gitlab_self_hosted/resource.go index f058a93a..ff8ec632 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource.go +++ b/zitadel/idp_gitlab_self_hosted/resource.go @@ -3,8 +3,8 @@ package idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go b/zitadel/idp_gitlab_self_hosted/resource_test.go similarity index 59% rename from zitadel/v2/idp_gitlab_self_hosted/resource_test.go rename to zitadel/idp_gitlab_self_hosted/resource_test.go index d2e3b8b0..2f547c03 100644 --- a/zitadel/v2/idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/idp_gitlab_self_hosted/resource_test.go @@ -3,8 +3,8 @@ package idp_gitlab_self_hosted_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGitLabSelfHosted(t *testing.T) { diff --git a/zitadel/v2/idp_gitlab_self_hosted/schema.go b/zitadel/idp_gitlab_self_hosted/schema.go similarity index 100% rename from zitadel/v2/idp_gitlab_self_hosted/schema.go rename to zitadel/idp_gitlab_self_hosted/schema.go diff --git a/zitadel/v2/idp_google/datasource.go b/zitadel/idp_google/datasource.go similarity index 93% rename from zitadel/v2/idp_google/datasource.go rename to zitadel/idp_google/datasource.go index 2cb293f1..8c88a694 100644 --- a/zitadel/v2/idp_google/datasource.go +++ b/zitadel/idp_google/datasource.go @@ -3,7 +3,7 @@ package idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_google/funcs.go b/zitadel/idp_google/funcs.go similarity index 95% rename from zitadel/v2/idp_google/funcs.go rename to zitadel/idp_google/funcs.go index 81081575..07d5d581 100644 --- a/zitadel/v2/idp_google/funcs.go +++ b/zitadel/idp_google/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_google/idp_google_test_dep/dependency.go b/zitadel/idp_google/idp_google_test_dep/dependency.go similarity index 78% rename from zitadel/v2/idp_google/idp_google_test_dep/dependency.go rename to zitadel/idp_google/idp_google_test_dep/dependency.go index 2742f2b8..d52cc4bb 100644 --- a/zitadel/v2/idp_google/idp_google_test_dep/dependency.go +++ b/zitadel/idp_google/idp_google_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func Create(t *testing.T, frame test_utils.BaseTestFrame, client admin.AdminServiceClient) (string, string) { diff --git a/zitadel/v2/idp_google/resource.go b/zitadel/idp_google/resource.go similarity index 88% rename from zitadel/v2/idp_google/resource.go rename to zitadel/idp_google/resource.go index f26d37e0..a888a724 100644 --- a/zitadel/v2/idp_google/resource.go +++ b/zitadel/idp_google/resource.go @@ -3,8 +3,8 @@ package idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_google/resource_test.go b/zitadel/idp_google/resource_test.go similarity index 55% rename from zitadel/v2/idp_google/resource_test.go rename to zitadel/idp_google/resource_test.go index 31fcfde9..9930612a 100644 --- a/zitadel/v2/idp_google/resource_test.go +++ b/zitadel/idp_google/resource_test.go @@ -3,8 +3,8 @@ package idp_google_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPGoogle(t *testing.T) { diff --git a/zitadel/v2/idp_ldap/datasource.go b/zitadel/idp_ldap/datasource.go similarity index 96% rename from zitadel/v2/idp_ldap/datasource.go rename to zitadel/idp_ldap/datasource.go index db08001e..2be14e26 100644 --- a/zitadel/v2/idp_ldap/datasource.go +++ b/zitadel/idp_ldap/datasource.go @@ -3,7 +3,7 @@ package idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/idp_ldap/funcs.go b/zitadel/idp_ldap/funcs.go similarity index 98% rename from zitadel/v2/idp_ldap/funcs.go rename to zitadel/idp_ldap/funcs.go index 7fdcac79..7c7f4617 100644 --- a/zitadel/v2/idp_ldap/funcs.go +++ b/zitadel/idp_ldap/funcs.go @@ -10,8 +10,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_ldap/resource.go b/zitadel/idp_ldap/resource.go similarity index 94% rename from zitadel/v2/idp_ldap/resource.go rename to zitadel/idp_ldap/resource.go index 404a5de0..911e0133 100644 --- a/zitadel/v2/idp_ldap/resource.go +++ b/zitadel/idp_ldap/resource.go @@ -3,8 +3,8 @@ package idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/idp_ldap/resource_test.go b/zitadel/idp_ldap/resource_test.go similarity index 54% rename from zitadel/v2/idp_ldap/resource_test.go rename to zitadel/idp_ldap/resource_test.go index 867127a0..10afb269 100644 --- a/zitadel/v2/idp_ldap/resource_test.go +++ b/zitadel/idp_ldap/resource_test.go @@ -3,8 +3,8 @@ package idp_ldap_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils/idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils/idp_test_utils" ) func TestAccInstanceIdPLDAP(t *testing.T) { diff --git a/zitadel/v2/idp_ldap/schema.go b/zitadel/idp_ldap/schema.go similarity index 100% rename from zitadel/v2/idp_ldap/schema.go rename to zitadel/idp_ldap/schema.go diff --git a/zitadel/v2/idp_utils/funcs.go b/zitadel/idp_utils/funcs.go similarity index 95% rename from zitadel/v2/idp_utils/funcs.go rename to zitadel/idp_utils/funcs.go index 6f8d50c1..e1d732f9 100644 --- a/zitadel/v2/idp_utils/funcs.go +++ b/zitadel/idp_utils/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/idp_utils/idp_test_utils/checks.go b/zitadel/idp_utils/idp_test_utils/checks.go similarity index 93% rename from zitadel/v2/idp_utils/idp_test_utils/checks.go rename to zitadel/idp_utils/idp_test_utils/checks.go index 60aa1d4b..89766c39 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/checks.go +++ b/zitadel/idp_utils/idp_test_utils/checks.go @@ -9,7 +9,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func CheckCreationAllowed(frame test_utils.InstanceTestFrame) func(bool) resource.TestCheckFunc { diff --git a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go b/zitadel/idp_utils/idp_test_utils/lifecyletest.go similarity index 85% rename from zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go rename to zitadel/idp_utils/idp_test_utils/lifecyletest.go index 0ee39b53..78703447 100644 --- a/zitadel/v2/idp_utils/idp_test_utils/lifecyletest.go +++ b/zitadel/idp_utils/idp_test_utils/lifecyletest.go @@ -4,9 +4,9 @@ import ( "strings" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func RunInstanceIDPLifecyleTest(t *testing.T, resourceName, secretAttribute string) { diff --git a/zitadel/v2/idp_utils/schema.go b/zitadel/idp_utils/schema.go similarity index 100% rename from zitadel/v2/idp_utils/schema.go rename to zitadel/idp_utils/schema.go diff --git a/zitadel/v2/init_message_text/resource.go b/zitadel/init_message_text/resource.go similarity index 99% rename from zitadel/v2/init_message_text/resource.go rename to zitadel/init_message_text/resource.go index 626897eb..ee290ecf 100644 --- a/zitadel/v2/init_message_text/resource.go +++ b/zitadel/init_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/init_message_text/resource_test.go b/zitadel/init_message_text/resource_test.go similarity index 91% rename from zitadel/v2/init_message_text/resource_test.go rename to zitadel/init_message_text/resource_test.go index f1ab0d14..b74f4ad1 100644 --- a/zitadel/v2/init_message_text/resource_test.go +++ b/zitadel/init_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/init_message_text" ) func TestAccInitMessageText(t *testing.T) { diff --git a/zitadel/v2/instance_member/const.go b/zitadel/instance_member/const.go similarity index 100% rename from zitadel/v2/instance_member/const.go rename to zitadel/instance_member/const.go diff --git a/zitadel/v2/instance_member/funcs.go b/zitadel/instance_member/funcs.go similarity index 98% rename from zitadel/v2/instance_member/funcs.go rename to zitadel/instance_member/funcs.go index a5f1efb2..02d3a784 100644 --- a/zitadel/v2/instance_member/funcs.go +++ b/zitadel/instance_member/funcs.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/instance_member/resource.go b/zitadel/instance_member/resource.go similarity index 93% rename from zitadel/v2/instance_member/resource.go rename to zitadel/instance_member/resource.go index e0eda8a3..44fa26d5 100644 --- a/zitadel/v2/instance_member/resource.go +++ b/zitadel/instance_member/resource.go @@ -3,7 +3,7 @@ package instance_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/instance_member/resource_test.go b/zitadel/instance_member/resource_test.go similarity index 87% rename from zitadel/v2/instance_member/resource_test.go rename to zitadel/instance_member/resource_test.go index 4e9da677..c816b06f 100644 --- a/zitadel/v2/instance_member/resource_test.go +++ b/zitadel/instance_member/resource_test.go @@ -10,10 +10,10 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/instance_member" ) func TestAccInstanceMember(t *testing.T) { diff --git a/zitadel/v2/label_policy/const.go b/zitadel/label_policy/const.go similarity index 100% rename from zitadel/v2/label_policy/const.go rename to zitadel/label_policy/const.go diff --git a/zitadel/v2/label_policy/funcs.go b/zitadel/label_policy/funcs.go similarity index 99% rename from zitadel/v2/label_policy/funcs.go rename to zitadel/label_policy/funcs.go index f35d1fa0..09d8f346 100644 --- a/zitadel/v2/label_policy/funcs.go +++ b/zitadel/label_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/label_policy/resource.go b/zitadel/label_policy/resource.go similarity index 98% rename from zitadel/v2/label_policy/resource.go rename to zitadel/label_policy/resource.go index f6b0f2fc..cefcc592 100644 --- a/zitadel/v2/label_policy/resource.go +++ b/zitadel/label_policy/resource.go @@ -3,7 +3,7 @@ package label_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/label_policy/resource_test.go b/zitadel/label_policy/resource_test.go similarity index 93% rename from zitadel/v2/label_policy/resource_test.go rename to zitadel/label_policy/resource_test.go index f51ae599..13ab2297 100644 --- a/zitadel/v2/label_policy/resource_test.go +++ b/zitadel/label_policy/resource_test.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/label_policy" ) func TestAccLabelPolicy(t *testing.T) { diff --git a/zitadel/v2/lockout_policy/const.go b/zitadel/lockout_policy/const.go similarity index 100% rename from zitadel/v2/lockout_policy/const.go rename to zitadel/lockout_policy/const.go diff --git a/zitadel/v2/lockout_policy/funcs.go b/zitadel/lockout_policy/funcs.go similarity index 97% rename from zitadel/v2/lockout_policy/funcs.go rename to zitadel/lockout_policy/funcs.go index 12ce128f..a214d5db 100644 --- a/zitadel/v2/lockout_policy/funcs.go +++ b/zitadel/lockout_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/lockout_policy/resource.go b/zitadel/lockout_policy/resource.go similarity index 91% rename from zitadel/v2/lockout_policy/resource.go rename to zitadel/lockout_policy/resource.go index 5c25fb9a..26c1e3f6 100644 --- a/zitadel/v2/lockout_policy/resource.go +++ b/zitadel/lockout_policy/resource.go @@ -3,7 +3,7 @@ package lockout_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/lockout_policy/resource_test.go b/zitadel/lockout_policy/resource_test.go similarity index 91% rename from zitadel/v2/lockout_policy/resource_test.go rename to zitadel/lockout_policy/resource_test.go index dc919f71..e4a3546f 100644 --- a/zitadel/v2/lockout_policy/resource_test.go +++ b/zitadel/lockout_policy/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccLockoutPolicy(t *testing.T) { diff --git a/zitadel/v2/login_policy/const.go b/zitadel/login_policy/const.go similarity index 100% rename from zitadel/v2/login_policy/const.go rename to zitadel/login_policy/const.go diff --git a/zitadel/v2/login_policy/funcs.go b/zitadel/login_policy/funcs.go similarity index 99% rename from zitadel/v2/login_policy/funcs.go rename to zitadel/login_policy/funcs.go index c411a3d7..c431e7a0 100644 --- a/zitadel/v2/login_policy/funcs.go +++ b/zitadel/login_policy/funcs.go @@ -13,7 +13,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/policy" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/login_policy/resource.go b/zitadel/login_policy/resource.go similarity index 98% rename from zitadel/v2/login_policy/resource.go rename to zitadel/login_policy/resource.go index fe536d79..aeb7bb38 100644 --- a/zitadel/v2/login_policy/resource.go +++ b/zitadel/login_policy/resource.go @@ -3,7 +3,7 @@ package login_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/login_policy/resource_test.go b/zitadel/login_policy/resource_test.go similarity index 80% rename from zitadel/v2/login_policy/resource_test.go rename to zitadel/login_policy/resource_test.go index 7f63d693..fe87ae27 100644 --- a/zitadel/v2/login_policy/resource_test.go +++ b/zitadel/login_policy/resource_test.go @@ -8,11 +8,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad/idp_azure_ad_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google/idp_google_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad/idp_azure_ad_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_google/idp_google_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/login_policy" ) func TestAccLoginPolicy(t *testing.T) { diff --git a/zitadel/v2/login_texts/resource.go b/zitadel/login_texts/resource.go similarity index 99% rename from zitadel/v2/login_texts/resource.go rename to zitadel/login_texts/resource.go index 28af04a8..ba0ff030 100644 --- a/zitadel/v2/login_texts/resource.go +++ b/zitadel/login_texts/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/login_texts/resource_test.go b/zitadel/login_texts/resource_test.go similarity index 91% rename from zitadel/v2/login_texts/resource_test.go rename to zitadel/login_texts/resource_test.go index 394ba86d..868cbeab 100644 --- a/zitadel/v2/login_texts/resource_test.go +++ b/zitadel/login_texts/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_texts" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/login_texts" ) func TestAccLoginTexts(t *testing.T) { diff --git a/zitadel/v2/machine_key/const.go b/zitadel/machine_key/const.go similarity index 100% rename from zitadel/v2/machine_key/const.go rename to zitadel/machine_key/const.go diff --git a/zitadel/v2/machine_key/funcs.go b/zitadel/machine_key/funcs.go similarity index 97% rename from zitadel/v2/machine_key/funcs.go rename to zitadel/machine_key/funcs.go index 5d7e59a9..b018cd2f 100644 --- a/zitadel/v2/machine_key/funcs.go +++ b/zitadel/machine_key/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/timestamppb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/machine_key/resource.go b/zitadel/machine_key/resource.go similarity index 95% rename from zitadel/v2/machine_key/resource.go rename to zitadel/machine_key/resource.go index 69ebddef..472310b6 100644 --- a/zitadel/v2/machine_key/resource.go +++ b/zitadel/machine_key/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/authn" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/machine_key/resource_test.go b/zitadel/machine_key/resource_test.go similarity index 86% rename from zitadel/v2/machine_key/resource_test.go rename to zitadel/machine_key/resource_test.go index 5eac0251..ad2ebc04 100644 --- a/zitadel/v2/machine_key/resource_test.go +++ b/zitadel/machine_key/resource_test.go @@ -8,10 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_user/machine_user_test_dep" ) func TestAccMachineKey(t *testing.T) { diff --git a/zitadel/v2/machine_user/const.go b/zitadel/machine_user/const.go similarity index 100% rename from zitadel/v2/machine_user/const.go rename to zitadel/machine_user/const.go diff --git a/zitadel/v2/machine_user/datasource.go b/zitadel/machine_user/datasource.go similarity index 95% rename from zitadel/v2/machine_user/datasource.go rename to zitadel/machine_user/datasource.go index 709085b5..3b07ae86 100644 --- a/zitadel/v2/machine_user/datasource.go +++ b/zitadel/machine_user/datasource.go @@ -3,7 +3,7 @@ package machine_user import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/machine_user/funcs.go b/zitadel/machine_user/funcs.go similarity index 98% rename from zitadel/v2/machine_user/funcs.go rename to zitadel/machine_user/funcs.go index 55f6af52..dbad970d 100644 --- a/zitadel/v2/machine_user/funcs.go +++ b/zitadel/machine_user/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/machine_user/machine_user_test_dep/dependency.go b/zitadel/machine_user/machine_user_test_dep/dependency.go similarity index 77% rename from zitadel/v2/machine_user/machine_user_test_dep/dependency.go rename to zitadel/machine_user/machine_user_test_dep/dependency.go index 3313f1df..a32a2527 100644 --- a/zitadel/v2/machine_user/machine_user_test_dep/dependency.go +++ b/zitadel/machine_user/machine_user_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_user" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { diff --git a/zitadel/v2/machine_user/resource.go b/zitadel/machine_user/resource.go similarity index 97% rename from zitadel/v2/machine_user/resource.go rename to zitadel/machine_user/resource.go index 29e0329c..208d97de 100644 --- a/zitadel/v2/machine_user/resource.go +++ b/zitadel/machine_user/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/machine_user/resource_test.go b/zitadel/machine_user/resource_test.go similarity index 89% rename from zitadel/v2/machine_user/resource_test.go rename to zitadel/machine_user/resource_test.go index 40e3a94e..42d484fd 100644 --- a/zitadel/v2/machine_user/resource_test.go +++ b/zitadel/machine_user/resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_user" ) func TestAccMachineUser(t *testing.T) { diff --git a/zitadel/v2/notification_policy/const.go b/zitadel/notification_policy/const.go similarity index 100% rename from zitadel/v2/notification_policy/const.go rename to zitadel/notification_policy/const.go diff --git a/zitadel/v2/notification_policy/funcs.go b/zitadel/notification_policy/funcs.go similarity index 98% rename from zitadel/v2/notification_policy/funcs.go rename to zitadel/notification_policy/funcs.go index 847d9bb2..7d8092f4 100644 --- a/zitadel/v2/notification_policy/funcs.go +++ b/zitadel/notification_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/notification_policy/resource.go b/zitadel/notification_policy/resource.go similarity index 90% rename from zitadel/v2/notification_policy/resource.go rename to zitadel/notification_policy/resource.go index e3db8751..339a8e4c 100644 --- a/zitadel/v2/notification_policy/resource.go +++ b/zitadel/notification_policy/resource.go @@ -3,7 +3,7 @@ package notification_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/notification_policy/resource_test.go b/zitadel/notification_policy/resource_test.go similarity index 90% rename from zitadel/v2/notification_policy/resource_test.go rename to zitadel/notification_policy/resource_test.go index edc49f75..40c16736 100644 --- a/zitadel/v2/notification_policy/resource_test.go +++ b/zitadel/notification_policy/resource_test.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccNotificationPolicy(t *testing.T) { diff --git a/zitadel/v2/org/const.go b/zitadel/org/const.go similarity index 100% rename from zitadel/v2/org/const.go rename to zitadel/org/const.go diff --git a/zitadel/v2/org/datasource.go b/zitadel/org/datasource.go similarity index 98% rename from zitadel/v2/org/datasource.go rename to zitadel/org/datasource.go index a6aca9b9..80fcf297 100644 --- a/zitadel/v2/org/datasource.go +++ b/zitadel/org/datasource.go @@ -7,7 +7,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org/datasource_test.go b/zitadel/org/datasource_test.go similarity index 94% rename from zitadel/v2/org/datasource_test.go rename to zitadel/org/datasource_test.go index 569cf42f..d40092af 100644 --- a/zitadel/v2/org/datasource_test.go +++ b/zitadel/org/datasource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org" ) func TestAccOrgDatasource_ID(t *testing.T) { diff --git a/zitadel/v2/org/funcs.go b/zitadel/org/funcs.go similarity index 98% rename from zitadel/v2/org/funcs.go rename to zitadel/org/funcs.go index 306497d8..c7879c28 100644 --- a/zitadel/v2/org/funcs.go +++ b/zitadel/org/funcs.go @@ -11,7 +11,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org/org_test_dep/dependency.go b/zitadel/org/org_test_dep/dependency.go similarity index 77% rename from zitadel/v2/org/org_test_dep/dependency.go rename to zitadel/org/org_test_dep/dependency.go index fc0b1405..4f8b8944 100644 --- a/zitadel/v2/org/org_test_dep/dependency.go +++ b/zitadel/org/org_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame, resourceName string) (string, string, *test_utils.OrgTestFrame) { diff --git a/zitadel/v2/org/remote_test.go b/zitadel/org/remote_test.go similarity index 92% rename from zitadel/v2/org/remote_test.go rename to zitadel/org/remote_test.go index 22c49aa1..5a8ee48d 100644 --- a/zitadel/v2/org/remote_test.go +++ b/zitadel/org/remote_test.go @@ -8,7 +8,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func checkRemoteProperty(frame *test_utils.OrgTestFrame, id func(state *terraform.State) string) func(string) resource.TestCheckFunc { diff --git a/zitadel/v2/org/resource.go b/zitadel/org/resource.go similarity index 93% rename from zitadel/v2/org/resource.go rename to zitadel/org/resource.go index ebc42e4b..d43da0cf 100644 --- a/zitadel/v2/org/resource.go +++ b/zitadel/org/resource.go @@ -3,7 +3,7 @@ package org import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org/resource_test.go b/zitadel/org/resource_test.go similarity index 84% rename from zitadel/v2/org/resource_test.go rename to zitadel/org/resource_test.go index ed86b11b..8ecbae2a 100644 --- a/zitadel/v2/org/resource_test.go +++ b/zitadel/org/resource_test.go @@ -5,9 +5,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org" ) func TestAccOrg(t *testing.T) { diff --git a/zitadel/v2/org_idp_azure_ad/datasource.go b/zitadel/org_idp_azure_ad/datasource.go similarity index 85% rename from zitadel/v2/org_idp_azure_ad/datasource.go rename to zitadel/org_idp_azure_ad/datasource.go index 58b67aaa..e059b15c 100644 --- a/zitadel/v2/org_idp_azure_ad/datasource.go +++ b/zitadel/org_idp_azure_ad/datasource.go @@ -3,9 +3,9 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_azure_ad/funcs.go b/zitadel/org_idp_azure_ad/funcs.go similarity index 95% rename from zitadel/v2/org_idp_azure_ad/funcs.go rename to zitadel/org_idp_azure_ad/funcs.go index fbe6c430..1f785355 100644 --- a/zitadel/v2/org_idp_azure_ad/funcs.go +++ b/zitadel/org_idp_azure_ad/funcs.go @@ -8,9 +8,9 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_azure_ad/resource.go b/zitadel/org_idp_azure_ad/resource.go similarity index 82% rename from zitadel/v2/org_idp_azure_ad/resource.go rename to zitadel/org_idp_azure_ad/resource.go index 2039676c..ed6285ef 100644 --- a/zitadel/v2/org_idp_azure_ad/resource.go +++ b/zitadel/org_idp_azure_ad/resource.go @@ -3,10 +3,10 @@ package org_idp_azure_ad import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_azure_ad/resource_test.go b/zitadel/org_idp_azure_ad/resource_test.go similarity index 54% rename from zitadel/v2/org_idp_azure_ad/resource_test.go rename to zitadel/org_idp_azure_ad/resource_test.go index afe372ca..77ab1615 100644 --- a/zitadel/v2/org_idp_azure_ad/resource_test.go +++ b/zitadel/org_idp_azure_ad/resource_test.go @@ -3,8 +3,8 @@ package org_idp_azure_ad_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPAzureAD(t *testing.T) { diff --git a/zitadel/v2/org_idp_github/datasource.go b/zitadel/org_idp_github/datasource.go similarity index 88% rename from zitadel/v2/org_idp_github/datasource.go rename to zitadel/org_idp_github/datasource.go index a4d0411a..72985200 100644 --- a/zitadel/v2/org_idp_github/datasource.go +++ b/zitadel/org_idp_github/datasource.go @@ -3,8 +3,8 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_github/funcs.go b/zitadel/org_idp_github/funcs.go similarity index 96% rename from zitadel/v2/org_idp_github/funcs.go rename to zitadel/org_idp_github/funcs.go index b71f7178..83d89348 100644 --- a/zitadel/v2/org_idp_github/funcs.go +++ b/zitadel/org_idp_github/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_github/resource.go b/zitadel/org_idp_github/resource.go similarity index 84% rename from zitadel/v2/org_idp_github/resource.go rename to zitadel/org_idp_github/resource.go index 3fe1bda7..04dd5f9e 100644 --- a/zitadel/v2/org_idp_github/resource.go +++ b/zitadel/org_idp_github/resource.go @@ -3,9 +3,9 @@ package org_idp_github import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_github/resource_test.go b/zitadel/org_idp_github/resource_test.go similarity index 53% rename from zitadel/v2/org_idp_github/resource_test.go rename to zitadel/org_idp_github/resource_test.go index 4761f629..fae18984 100644 --- a/zitadel/v2/org_idp_github/resource_test.go +++ b/zitadel/org_idp_github/resource_test.go @@ -3,8 +3,8 @@ package org_idp_github_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitHub(t *testing.T) { diff --git a/zitadel/v2/org_idp_github_es/datasource.go b/zitadel/org_idp_github_es/datasource.go similarity index 86% rename from zitadel/v2/org_idp_github_es/datasource.go rename to zitadel/org_idp_github_es/datasource.go index df95536b..12cd5eda 100644 --- a/zitadel/v2/org_idp_github_es/datasource.go +++ b/zitadel/org_idp_github_es/datasource.go @@ -3,9 +3,9 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_github_es/funcs.go b/zitadel/org_idp_github_es/funcs.go similarity index 95% rename from zitadel/v2/org_idp_github_es/funcs.go rename to zitadel/org_idp_github_es/funcs.go index c859fd6d..972483b1 100644 --- a/zitadel/v2/org_idp_github_es/funcs.go +++ b/zitadel/org_idp_github_es/funcs.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_github_es/resource.go b/zitadel/org_idp_github_es/resource.go similarity index 83% rename from zitadel/v2/org_idp_github_es/resource.go rename to zitadel/org_idp_github_es/resource.go index 4e7a863b..5f06cd0a 100644 --- a/zitadel/v2/org_idp_github_es/resource.go +++ b/zitadel/org_idp_github_es/resource.go @@ -3,10 +3,10 @@ package org_idp_github_es import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_github_es/resource_test.go b/zitadel/org_idp_github_es/resource_test.go similarity index 54% rename from zitadel/v2/org_idp_github_es/resource_test.go rename to zitadel/org_idp_github_es/resource_test.go index 57f08216..a14bf1e2 100644 --- a/zitadel/v2/org_idp_github_es/resource_test.go +++ b/zitadel/org_idp_github_es/resource_test.go @@ -3,8 +3,8 @@ package org_idp_github_es_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitHubES(t *testing.T) { diff --git a/zitadel/v2/org_idp_gitlab/datasource.go b/zitadel/org_idp_gitlab/datasource.go similarity index 88% rename from zitadel/v2/org_idp_gitlab/datasource.go rename to zitadel/org_idp_gitlab/datasource.go index 1ebd258f..fbfc468d 100644 --- a/zitadel/v2/org_idp_gitlab/datasource.go +++ b/zitadel/org_idp_gitlab/datasource.go @@ -3,8 +3,8 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_gitlab/funcs.go b/zitadel/org_idp_gitlab/funcs.go similarity index 96% rename from zitadel/v2/org_idp_gitlab/funcs.go rename to zitadel/org_idp_gitlab/funcs.go index 1782421c..818dc84f 100644 --- a/zitadel/v2/org_idp_gitlab/funcs.go +++ b/zitadel/org_idp_gitlab/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_gitlab/resource.go b/zitadel/org_idp_gitlab/resource.go similarity index 84% rename from zitadel/v2/org_idp_gitlab/resource.go rename to zitadel/org_idp_gitlab/resource.go index e996bba4..a63c98b3 100644 --- a/zitadel/v2/org_idp_gitlab/resource.go +++ b/zitadel/org_idp_gitlab/resource.go @@ -3,9 +3,9 @@ package org_idp_gitlab import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_gitlab/resource_test.go b/zitadel/org_idp_gitlab/resource_test.go similarity index 53% rename from zitadel/v2/org_idp_gitlab/resource_test.go rename to zitadel/org_idp_gitlab/resource_test.go index 4d2f063e..2a289ddb 100644 --- a/zitadel/v2/org_idp_gitlab/resource_test.go +++ b/zitadel/org_idp_gitlab/resource_test.go @@ -3,8 +3,8 @@ package org_idp_gitlab_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitLab(t *testing.T) { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go b/zitadel/org_idp_gitlab_self_hosted/datasource.go similarity index 83% rename from zitadel/v2/org_idp_gitlab_self_hosted/datasource.go rename to zitadel/org_idp_gitlab_self_hosted/datasource.go index aa652cf2..6d90e7d2 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/datasource.go +++ b/zitadel/org_idp_gitlab_self_hosted/datasource.go @@ -3,9 +3,9 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go b/zitadel/org_idp_gitlab_self_hosted/funcs.go similarity index 94% rename from zitadel/v2/org_idp_gitlab_self_hosted/funcs.go rename to zitadel/org_idp_gitlab_self_hosted/funcs.go index 1b7b9716..efbc4d98 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/funcs.go +++ b/zitadel/org_idp_gitlab_self_hosted/funcs.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go b/zitadel/org_idp_gitlab_self_hosted/resource.go similarity index 81% rename from zitadel/v2/org_idp_gitlab_self_hosted/resource.go rename to zitadel/org_idp_gitlab_self_hosted/resource.go index 97cbad62..cd184c46 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource.go +++ b/zitadel/org_idp_gitlab_self_hosted/resource.go @@ -3,10 +3,10 @@ package org_idp_gitlab_self_hosted import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go b/zitadel/org_idp_gitlab_self_hosted/resource_test.go similarity index 57% rename from zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go rename to zitadel/org_idp_gitlab_self_hosted/resource_test.go index 7d09c32b..429b1643 100644 --- a/zitadel/v2/org_idp_gitlab_self_hosted/resource_test.go +++ b/zitadel/org_idp_gitlab_self_hosted/resource_test.go @@ -3,8 +3,8 @@ package org_idp_gitlab_self_hosted_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGitLabSelfHosted(t *testing.T) { diff --git a/zitadel/v2/org_idp_google/datasource.go b/zitadel/org_idp_google/datasource.go similarity index 88% rename from zitadel/v2/org_idp_google/datasource.go rename to zitadel/org_idp_google/datasource.go index 223dcd8d..4a7feeff 100644 --- a/zitadel/v2/org_idp_google/datasource.go +++ b/zitadel/org_idp_google/datasource.go @@ -3,8 +3,8 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_google/funcs.go b/zitadel/org_idp_google/funcs.go similarity index 96% rename from zitadel/v2/org_idp_google/funcs.go rename to zitadel/org_idp_google/funcs.go index 696063d5..a009b597 100644 --- a/zitadel/v2/org_idp_google/funcs.go +++ b/zitadel/org_idp_google/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go b/zitadel/org_idp_google/org_idp_google_test_dep/dependency.go similarity index 77% rename from zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go rename to zitadel/org_idp_google/org_idp_google_test_dep/dependency.go index 7eeeb512..06a5ba66 100644 --- a/zitadel/v2/org_idp_google/org_idp_google_test_dep/dependency.go +++ b/zitadel/org_idp_google/org_idp_google_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func Create(t *testing.T, frame *test_utils.InstanceTestFrame) (string, string) { diff --git a/zitadel/v2/org_idp_google/resource.go b/zitadel/org_idp_google/resource.go similarity index 84% rename from zitadel/v2/org_idp_google/resource.go rename to zitadel/org_idp_google/resource.go index a2679001..219365fb 100644 --- a/zitadel/v2/org_idp_google/resource.go +++ b/zitadel/org_idp_google/resource.go @@ -3,9 +3,9 @@ package org_idp_google import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_google/resource_test.go b/zitadel/org_idp_google/resource_test.go similarity index 53% rename from zitadel/v2/org_idp_google/resource_test.go rename to zitadel/org_idp_google/resource_test.go index 6f4f98a6..222b0933 100644 --- a/zitadel/v2/org_idp_google/resource_test.go +++ b/zitadel/org_idp_google/resource_test.go @@ -3,8 +3,8 @@ package org_idp_google_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPGoogle(t *testing.T) { diff --git a/zitadel/v2/org_idp_jwt/const.go b/zitadel/org_idp_jwt/const.go similarity index 100% rename from zitadel/v2/org_idp_jwt/const.go rename to zitadel/org_idp_jwt/const.go diff --git a/zitadel/v2/org_idp_jwt/datasource.go b/zitadel/org_idp_jwt/datasource.go similarity index 96% rename from zitadel/v2/org_idp_jwt/datasource.go rename to zitadel/org_idp_jwt/datasource.go index a0d18746..379e6218 100644 --- a/zitadel/v2/org_idp_jwt/datasource.go +++ b/zitadel/org_idp_jwt/datasource.go @@ -3,7 +3,7 @@ package org_idp_jwt import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_jwt/funcs.go b/zitadel/org_idp_jwt/funcs.go similarity index 98% rename from zitadel/v2/org_idp_jwt/funcs.go rename to zitadel/org_idp_jwt/funcs.go index 8bb49e4a..2c57295a 100644 --- a/zitadel/v2/org_idp_jwt/funcs.go +++ b/zitadel/org_idp_jwt/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_jwt/resource.go b/zitadel/org_idp_jwt/resource.go similarity index 93% rename from zitadel/v2/org_idp_jwt/resource.go rename to zitadel/org_idp_jwt/resource.go index a64f662c..a8265ea3 100644 --- a/zitadel/v2/org_idp_jwt/resource.go +++ b/zitadel/org_idp_jwt/resource.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/idp" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_jwt/resource_test.go b/zitadel/org_idp_jwt/resource_test.go similarity index 88% rename from zitadel/v2/org_idp_jwt/resource_test.go rename to zitadel/org_idp_jwt/resource_test.go index 78d8e643..bcba7a44 100644 --- a/zitadel/v2/org_idp_jwt/resource_test.go +++ b/zitadel/org_idp_jwt/resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_jwt" ) func TestAccOrgIDPJWT(t *testing.T) { diff --git a/zitadel/v2/org_idp_ldap/datasource.go b/zitadel/org_idp_ldap/datasource.go similarity index 92% rename from zitadel/v2/org_idp_ldap/datasource.go rename to zitadel/org_idp_ldap/datasource.go index d7ccb66d..308b0fd6 100644 --- a/zitadel/v2/org_idp_ldap/datasource.go +++ b/zitadel/org_idp_ldap/datasource.go @@ -3,9 +3,9 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_ldap/funcs.go b/zitadel/org_idp_ldap/funcs.go similarity index 97% rename from zitadel/v2/org_idp_ldap/funcs.go rename to zitadel/org_idp_ldap/funcs.go index f950ec0b..55965a1b 100644 --- a/zitadel/v2/org_idp_ldap/funcs.go +++ b/zitadel/org_idp_ldap/funcs.go @@ -10,9 +10,9 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/durationpb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_ldap/resource.go b/zitadel/org_idp_ldap/resource.go similarity index 90% rename from zitadel/v2/org_idp_ldap/resource.go rename to zitadel/org_idp_ldap/resource.go index cec7e2b7..d140d1ce 100644 --- a/zitadel/v2/org_idp_ldap/resource.go +++ b/zitadel/org_idp_ldap/resource.go @@ -3,10 +3,10 @@ package org_idp_ldap import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_ldap/resource_test.go b/zitadel/org_idp_ldap/resource_test.go similarity index 53% rename from zitadel/v2/org_idp_ldap/resource_test.go rename to zitadel/org_idp_ldap/resource_test.go index bb53d30a..9562ee77 100644 --- a/zitadel/v2/org_idp_ldap/resource_test.go +++ b/zitadel/org_idp_ldap/resource_test.go @@ -3,8 +3,8 @@ package org_idp_ldap_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIdPLDAP(t *testing.T) { diff --git a/zitadel/v2/org_idp_oidc/datasource.go b/zitadel/org_idp_oidc/datasource.go similarity index 89% rename from zitadel/v2/org_idp_oidc/datasource.go rename to zitadel/org_idp_oidc/datasource.go index 223b000b..8b00dca2 100644 --- a/zitadel/v2/org_idp_oidc/datasource.go +++ b/zitadel/org_idp_oidc/datasource.go @@ -3,8 +3,8 @@ package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/org_idp_oidc/funcs.go b/zitadel/org_idp_oidc/funcs.go similarity index 96% rename from zitadel/v2/org_idp_oidc/funcs.go rename to zitadel/org_idp_oidc/funcs.go index bd31e2e2..7fb1ad76 100644 --- a/zitadel/v2/org_idp_oidc/funcs.go +++ b/zitadel/org_idp_oidc/funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_oidc/resource.go b/zitadel/org_idp_oidc/resource.go similarity index 85% rename from zitadel/v2/org_idp_oidc/resource.go rename to zitadel/org_idp_oidc/resource.go index e477d5de..d3b6f87c 100644 --- a/zitadel/v2/org_idp_oidc/resource.go +++ b/zitadel/org_idp_oidc/resource.go @@ -3,9 +3,9 @@ package org_idp_oidc import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_idp_oidc/resource_test.go b/zitadel/org_idp_oidc/resource_test.go similarity index 53% rename from zitadel/v2/org_idp_oidc/resource_test.go rename to zitadel/org_idp_oidc/resource_test.go index 272e1a8b..978fc490 100644 --- a/zitadel/v2/org_idp_oidc/resource_test.go +++ b/zitadel/org_idp_oidc/resource_test.go @@ -3,8 +3,8 @@ package org_idp_oidc_test import ( "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_utils/org_idp_test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_utils/org_idp_test_utils" ) func TestAccOrgIDPOIDC(t *testing.T) { diff --git a/zitadel/v2/org_idp_oidc/schema.go b/zitadel/org_idp_oidc/schema.go similarity index 100% rename from zitadel/v2/org_idp_oidc/schema.go rename to zitadel/org_idp_oidc/schema.go diff --git a/zitadel/v2/org_idp_utils/funcs.go b/zitadel/org_idp_utils/funcs.go similarity index 91% rename from zitadel/v2/org_idp_utils/funcs.go rename to zitadel/org_idp_utils/funcs.go index b3484da4..03d41a10 100644 --- a/zitadel/v2/org_idp_utils/funcs.go +++ b/zitadel/org_idp_utils/funcs.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go b/zitadel/org_idp_utils/org_idp_test_utils/checks.go similarity index 93% rename from zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go rename to zitadel/org_idp_utils/org_idp_test_utils/checks.go index 568f84fe..f76df16a 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/checks.go +++ b/zitadel/org_idp_utils/org_idp_test_utils/checks.go @@ -9,7 +9,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func CheckCreationAllowed(frame test_utils.OrgTestFrame) func(bool) resource.TestCheckFunc { diff --git a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go b/zitadel/org_idp_utils/org_idp_test_utils/lifecyletest.go similarity index 85% rename from zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go rename to zitadel/org_idp_utils/org_idp_test_utils/lifecyletest.go index 6a68759d..32304f2b 100644 --- a/zitadel/v2/org_idp_utils/org_idp_test_utils/lifecyletest.go +++ b/zitadel/org_idp_utils/org_idp_test_utils/lifecyletest.go @@ -4,9 +4,9 @@ import ( "strings" "testing" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_utils" ) func RunOrgLifecyleTest(t *testing.T, resourceName, secretAttribute string) { diff --git a/zitadel/v2/org_member/const.go b/zitadel/org_member/const.go similarity index 100% rename from zitadel/v2/org_member/const.go rename to zitadel/org_member/const.go diff --git a/zitadel/v2/org_member/funcs.go b/zitadel/org_member/funcs.go similarity index 98% rename from zitadel/v2/org_member/funcs.go rename to zitadel/org_member/funcs.go index 3de26ba2..8e8ecd7f 100644 --- a/zitadel/v2/org_member/funcs.go +++ b/zitadel/org_member/funcs.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/org_member/resource.go b/zitadel/org_member/resource.go similarity index 93% rename from zitadel/v2/org_member/resource.go rename to zitadel/org_member/resource.go index a52377f3..ae5de7b1 100644 --- a/zitadel/v2/org_member/resource.go +++ b/zitadel/org_member/resource.go @@ -3,7 +3,7 @@ package org_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/org_member/resource_test.go b/zitadel/org_member/resource_test.go similarity index 87% rename from zitadel/v2/org_member/resource_test.go rename to zitadel/org_member/resource_test.go index 1e3cb880..e4883c3a 100644 --- a/zitadel/v2/org_member/resource_test.go +++ b/zitadel/org_member/resource_test.go @@ -10,10 +10,10 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_member" ) func TestAccOrgMember(t *testing.T) { diff --git a/zitadel/v2/password_change_message_text/resource.go b/zitadel/password_change_message_text/resource.go similarity index 99% rename from zitadel/v2/password_change_message_text/resource.go rename to zitadel/password_change_message_text/resource.go index ee8d3619..3e5938fc 100644 --- a/zitadel/v2/password_change_message_text/resource.go +++ b/zitadel/password_change_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/password_change_message_text/resource_test.go b/zitadel/password_change_message_text/resource_test.go similarity index 91% rename from zitadel/v2/password_change_message_text/resource_test.go rename to zitadel/password_change_message_text/resource_test.go index 3ceb9bd2..6198c4b0 100644 --- a/zitadel/v2/password_change_message_text/resource_test.go +++ b/zitadel/password_change_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_change_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/password_change_message_text" ) func TestAccPasswordChangeMessageText(t *testing.T) { diff --git a/zitadel/v2/password_complexity_policy/const.go b/zitadel/password_complexity_policy/const.go similarity index 100% rename from zitadel/v2/password_complexity_policy/const.go rename to zitadel/password_complexity_policy/const.go diff --git a/zitadel/v2/password_complexity_policy/funcs.go b/zitadel/password_complexity_policy/funcs.go similarity index 98% rename from zitadel/v2/password_complexity_policy/funcs.go rename to zitadel/password_complexity_policy/funcs.go index d5cf7a71..a57e8f2e 100644 --- a/zitadel/v2/password_complexity_policy/funcs.go +++ b/zitadel/password_complexity_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/password_complexity_policy/resource.go b/zitadel/password_complexity_policy/resource.go similarity index 95% rename from zitadel/v2/password_complexity_policy/resource.go rename to zitadel/password_complexity_policy/resource.go index 0737a724..af3161df 100644 --- a/zitadel/v2/password_complexity_policy/resource.go +++ b/zitadel/password_complexity_policy/resource.go @@ -3,7 +3,7 @@ package password_complexity_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/password_complexity_policy/resource_test.go b/zitadel/password_complexity_policy/resource_test.go similarity index 91% rename from zitadel/v2/password_complexity_policy/resource_test.go rename to zitadel/password_complexity_policy/resource_test.go index 596a975c..73be9299 100644 --- a/zitadel/v2/password_complexity_policy/resource_test.go +++ b/zitadel/password_complexity_policy/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func TestAccPasswordComplexityPolicy(t *testing.T) { diff --git a/zitadel/v2/password_reset_message_text/resource.go b/zitadel/password_reset_message_text/resource.go similarity index 99% rename from zitadel/v2/password_reset_message_text/resource.go rename to zitadel/password_reset_message_text/resource.go index a6084d0d..a80f857e 100644 --- a/zitadel/v2/password_reset_message_text/resource.go +++ b/zitadel/password_reset_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/password_reset_message_text/resource_test.go b/zitadel/password_reset_message_text/resource_test.go similarity index 91% rename from zitadel/v2/password_reset_message_text/resource_test.go rename to zitadel/password_reset_message_text/resource_test.go index ff0d5b85..785c65cf 100644 --- a/zitadel/v2/password_reset_message_text/resource_test.go +++ b/zitadel/password_reset_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/password_reset_message_text" ) func TestAccPasswordResetMessageText(t *testing.T) { diff --git a/zitadel/v2/passwordless_registration_message_text/resource.go b/zitadel/passwordless_registration_message_text/resource.go similarity index 99% rename from zitadel/v2/passwordless_registration_message_text/resource.go rename to zitadel/passwordless_registration_message_text/resource.go index b2429f87..0812baa5 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource.go +++ b/zitadel/passwordless_registration_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/passwordless_registration_message_text/resource_test.go b/zitadel/passwordless_registration_message_text/resource_test.go similarity index 91% rename from zitadel/v2/passwordless_registration_message_text/resource_test.go rename to zitadel/passwordless_registration_message_text/resource_test.go index 9d9c504a..6433b094 100644 --- a/zitadel/v2/passwordless_registration_message_text/resource_test.go +++ b/zitadel/passwordless_registration_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/passwordless_registration_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/passwordless_registration_message_text" ) func TestAccPasswordlessRegistrationMessageText(t *testing.T) { diff --git a/zitadel/v2/pat/const.go b/zitadel/pat/const.go similarity index 100% rename from zitadel/v2/pat/const.go rename to zitadel/pat/const.go diff --git a/zitadel/v2/pat/funcs.go b/zitadel/pat/funcs.go similarity index 97% rename from zitadel/v2/pat/funcs.go rename to zitadel/pat/funcs.go index 0868a1b5..70b65231 100644 --- a/zitadel/v2/pat/funcs.go +++ b/zitadel/pat/funcs.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "google.golang.org/protobuf/types/known/timestamppb" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/pat/resource.go b/zitadel/pat/resource.go similarity index 94% rename from zitadel/v2/pat/resource.go rename to zitadel/pat/resource.go index 20247ba9..b5ac883d 100644 --- a/zitadel/v2/pat/resource.go +++ b/zitadel/pat/resource.go @@ -3,7 +3,7 @@ package pat import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/pat/resource_test.go b/zitadel/pat/resource_test.go similarity index 86% rename from zitadel/v2/pat/resource_test.go rename to zitadel/pat/resource_test.go index f13725fc..dd24a877 100644 --- a/zitadel/v2/pat/resource_test.go +++ b/zitadel/pat/resource_test.go @@ -8,10 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user/machine_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_user/machine_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/pat" ) func TestAccPersonalAccessToken(t *testing.T) { diff --git a/zitadel/v2/privacy_policy/const.go b/zitadel/privacy_policy/const.go similarity index 100% rename from zitadel/v2/privacy_policy/const.go rename to zitadel/privacy_policy/const.go diff --git a/zitadel/v2/privacy_policy/funcs.go b/zitadel/privacy_policy/funcs.go similarity index 98% rename from zitadel/v2/privacy_policy/funcs.go rename to zitadel/privacy_policy/funcs.go index 65d2012c..e240ade0 100644 --- a/zitadel/v2/privacy_policy/funcs.go +++ b/zitadel/privacy_policy/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/privacy_policy/resource.go b/zitadel/privacy_policy/resource.go similarity index 93% rename from zitadel/v2/privacy_policy/resource.go rename to zitadel/privacy_policy/resource.go index ffe7a67b..6b2d8a7d 100644 --- a/zitadel/v2/privacy_policy/resource.go +++ b/zitadel/privacy_policy/resource.go @@ -3,7 +3,7 @@ package privacy_policy import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/privacy_policy/resource_test.go b/zitadel/privacy_policy/resource_test.go similarity index 86% rename from zitadel/v2/privacy_policy/resource_test.go rename to zitadel/privacy_policy/resource_test.go index f8cf18bf..3748b408 100644 --- a/zitadel/v2/privacy_policy/resource_test.go +++ b/zitadel/privacy_policy/resource_test.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/privacy_policy" ) func TestAccPrivacyPolicy(t *testing.T) { diff --git a/zitadel/v2/project/const.go b/zitadel/project/const.go similarity index 100% rename from zitadel/v2/project/const.go rename to zitadel/project/const.go diff --git a/zitadel/v2/project/datasource.go b/zitadel/project/datasource.go similarity index 95% rename from zitadel/v2/project/datasource.go rename to zitadel/project/datasource.go index a2dc974d..1ffa655b 100644 --- a/zitadel/v2/project/datasource.go +++ b/zitadel/project/datasource.go @@ -3,7 +3,7 @@ package project import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/project/funcs.go b/zitadel/project/funcs.go similarity index 98% rename from zitadel/v2/project/funcs.go rename to zitadel/project/funcs.go index ca869e27..7d7a763e 100644 --- a/zitadel/v2/project/funcs.go +++ b/zitadel/project/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/project/project_test_dep/dependency.go b/zitadel/project/project_test_dep/dependency.go similarity index 74% rename from zitadel/v2/project/project_test_dep/dependency.go rename to zitadel/project/project_test_dep/dependency.go index 9bf740c0..d255f873 100644 --- a/zitadel/v2/project/project_test_dep/dependency.go +++ b/zitadel/project/project_test_dep/dependency.go @@ -5,8 +5,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame) (string, string) { diff --git a/zitadel/v2/project/resource.go b/zitadel/project/resource.go similarity index 97% rename from zitadel/v2/project/resource.go rename to zitadel/project/resource.go index a1110f36..a8ef35c3 100644 --- a/zitadel/v2/project/resource.go +++ b/zitadel/project/resource.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/project/resource_test.go b/zitadel/project/resource_test.go similarity index 88% rename from zitadel/v2/project/resource_test.go rename to zitadel/project/resource_test.go index c5b7d8f2..47b13cb1 100644 --- a/zitadel/v2/project/resource_test.go +++ b/zitadel/project/resource_test.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project" ) func TestAccProject(t *testing.T) { diff --git a/zitadel/v2/project_grant/const.go b/zitadel/project_grant/const.go similarity index 100% rename from zitadel/v2/project_grant/const.go rename to zitadel/project_grant/const.go diff --git a/zitadel/v2/project_grant/funcs.go b/zitadel/project_grant/funcs.go similarity index 98% rename from zitadel/v2/project_grant/funcs.go rename to zitadel/project_grant/funcs.go index c673b068..97f1d2f0 100644 --- a/zitadel/v2/project_grant/funcs.go +++ b/zitadel/project_grant/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/project_grant/project_grant_test_dep/dependency.go b/zitadel/project_grant/project_grant_test_dep/dependency.go similarity index 85% rename from zitadel/v2/project_grant/project_grant_test_dep/dependency.go rename to zitadel/project_grant/project_grant_test_dep/dependency.go index d7f485fe..5b5a0239 100644 --- a/zitadel/v2/project_grant/project_grant_test_dep/dependency.go +++ b/zitadel/project_grant/project_grant_test_dep/dependency.go @@ -5,7 +5,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID, grantedOrgID string) string { diff --git a/zitadel/v2/project_grant/resource.go b/zitadel/project_grant/resource.go similarity index 94% rename from zitadel/v2/project_grant/resource.go rename to zitadel/project_grant/resource.go index 654e543d..3147177d 100644 --- a/zitadel/v2/project_grant/resource.go +++ b/zitadel/project_grant/resource.go @@ -3,7 +3,7 @@ package project_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/project_grant/resource_test.go b/zitadel/project_grant/resource_test.go similarity index 82% rename from zitadel/v2/project_grant/resource_test.go rename to zitadel/project_grant/resource_test.go index 4cb2727f..21401235 100644 --- a/zitadel/v2/project_grant/resource_test.go +++ b/zitadel/project_grant/resource_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role/project_role_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org/org_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_role/project_role_test_dep" ) func TestAccProjectGrant(t *testing.T) { diff --git a/zitadel/v2/project_grant_member/const.go b/zitadel/project_grant_member/const.go similarity index 100% rename from zitadel/v2/project_grant_member/const.go rename to zitadel/project_grant_member/const.go diff --git a/zitadel/v2/project_grant_member/funcs.go b/zitadel/project_grant_member/funcs.go similarity index 98% rename from zitadel/v2/project_grant_member/funcs.go rename to zitadel/project_grant_member/funcs.go index 16e62d04..08f0aa3f 100644 --- a/zitadel/v2/project_grant_member/funcs.go +++ b/zitadel/project_grant_member/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/project_grant_member/resource.go b/zitadel/project_grant_member/resource.go similarity index 95% rename from zitadel/v2/project_grant_member/resource.go rename to zitadel/project_grant_member/resource.go index 908a4cf1..31e69e90 100644 --- a/zitadel/v2/project_grant_member/resource.go +++ b/zitadel/project_grant_member/resource.go @@ -3,7 +3,7 @@ package project_grant_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/project_grant_member/resource_test.go b/zitadel/project_grant_member/resource_test.go similarity index 84% rename from zitadel/v2/project_grant_member/resource_test.go rename to zitadel/project_grant_member/resource_test.go index 49d878cb..2757b035 100644 --- a/zitadel/v2/project_grant_member/resource_test.go +++ b/zitadel/project_grant_member/resource_test.go @@ -11,13 +11,13 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org/org_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant/project_grant_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org/org_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant/project_grant_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant_member" ) func TestAccProjectGrantMember(t *testing.T) { diff --git a/zitadel/v2/project_member/const.go b/zitadel/project_member/const.go similarity index 100% rename from zitadel/v2/project_member/const.go rename to zitadel/project_member/const.go diff --git a/zitadel/v2/project_member/funcs.go b/zitadel/project_member/funcs.go similarity index 98% rename from zitadel/v2/project_member/funcs.go rename to zitadel/project_member/funcs.go index 5272ec6b..ada573bd 100644 --- a/zitadel/v2/project_member/funcs.go +++ b/zitadel/project_member/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/project_member/resource.go b/zitadel/project_member/resource.go similarity index 94% rename from zitadel/v2/project_member/resource.go rename to zitadel/project_member/resource.go index 23f02e8d..e7c11134 100644 --- a/zitadel/v2/project_member/resource.go +++ b/zitadel/project_member/resource.go @@ -3,7 +3,7 @@ package project_member import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/project_member/resource_test.go b/zitadel/project_member/resource_test.go similarity index 83% rename from zitadel/v2/project_member/resource_test.go rename to zitadel/project_member/resource_test.go index d7f16c7e..2aaa04fc 100644 --- a/zitadel/v2/project_member/resource_test.go +++ b/zitadel/project_member/resource_test.go @@ -10,12 +10,12 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_member" ) func TestAccProjectMember(t *testing.T) { diff --git a/zitadel/v2/project_role/const.go b/zitadel/project_role/const.go similarity index 100% rename from zitadel/v2/project_role/const.go rename to zitadel/project_role/const.go diff --git a/zitadel/v2/project_role/datasource.go b/zitadel/project_role/datasource.go similarity index 93% rename from zitadel/v2/project_role/datasource.go rename to zitadel/project_role/datasource.go index 34adf292..5ee1a13e 100644 --- a/zitadel/v2/project_role/datasource.go +++ b/zitadel/project_role/datasource.go @@ -3,7 +3,7 @@ package project_role import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/project_role/funcs.go b/zitadel/project_role/funcs.go similarity index 98% rename from zitadel/v2/project_role/funcs.go rename to zitadel/project_role/funcs.go index 5adbdc44..e0991025 100644 --- a/zitadel/v2/project_role/funcs.go +++ b/zitadel/project_role/funcs.go @@ -10,7 +10,7 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/object" project2 "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/project_role/project_role_test_dep/dependency.go b/zitadel/project_role/project_role_test_dep/dependency.go similarity index 80% rename from zitadel/v2/project_role/project_role_test_dep/dependency.go rename to zitadel/project_role/project_role_test_dep/dependency.go index 79b7fe1e..de359bc2 100644 --- a/zitadel/v2/project_role/project_role_test_dep/dependency.go +++ b/zitadel/project_role/project_role_test_dep/dependency.go @@ -6,8 +6,8 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_role" ) func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID string, key ...string) string { diff --git a/zitadel/v2/project_role/resource.go b/zitadel/project_role/resource.go similarity index 94% rename from zitadel/v2/project_role/resource.go rename to zitadel/project_role/resource.go index dcc7cc21..dd2848fd 100644 --- a/zitadel/v2/project_role/resource.go +++ b/zitadel/project_role/resource.go @@ -3,7 +3,7 @@ package project_role import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/project_role/resource_test.go b/zitadel/project_role/resource_test.go similarity index 88% rename from zitadel/v2/project_role/resource_test.go rename to zitadel/project_role/resource_test.go index 369ccd5c..38366a20 100644 --- a/zitadel/v2/project_role/resource_test.go +++ b/zitadel/project_role/resource_test.go @@ -10,10 +10,10 @@ import ( "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/project" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_role" ) func TestAccProjectRole(t *testing.T) { diff --git a/zitadel/provider.go b/zitadel/provider.go index 54f53954..f58d25f8 100644 --- a/zitadel/provider.go +++ b/zitadel/provider.go @@ -13,75 +13,75 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" zitadel_go "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_api" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_key" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/application_oidc" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_claimed_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_domain_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_init_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_label_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_lockout_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_login_texts" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_notification_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_oidc_settings" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_change_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_complexity_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_password_reset_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_passwordless_registration_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_privacy_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_email_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/default_verify_phone_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_claimed_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/domain_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_azure_ad" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_gitlab_self_hosted" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_google" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/init_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/instance_member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/label_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/lockout_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/login_texts" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_key" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/machine_user" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/notification_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_azure_ad" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_github_es" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_gitlab_self_hosted" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_google" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_jwt" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_ldap" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_idp_oidc" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/org_member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_change_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_complexity_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/password_reset_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/passwordless_registration_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/pat" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/privacy_policy" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_grant_member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_member" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_email_message_text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_phone_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/action" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_api" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/application_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_domain_claimed_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_login_texts" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_notification_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_oidc_settings" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_change_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_passwordless_registration_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/default_verify_phone_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/domain" + "github.com/zitadel/terraform-provider-zitadel/zitadel/domain_claimed_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/domain_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_github" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_google" + "github.com/zitadel/terraform-provider-zitadel/zitadel/idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/init_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/instance_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/label_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/lockout_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/login_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/login_texts" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_key" + "github.com/zitadel/terraform-provider-zitadel/zitadel/machine_user" + "github.com/zitadel/terraform-provider-zitadel/zitadel/notification_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_azure_ad" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_github" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_github_es" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_gitlab" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_gitlab_self_hosted" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_google" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_jwt" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_ldap" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_idp_oidc" + "github.com/zitadel/terraform-provider-zitadel/zitadel/org_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/password_change_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/password_complexity_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/password_reset_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/passwordless_registration_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/pat" + "github.com/zitadel/terraform-provider-zitadel/zitadel/privacy_policy" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_grant_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_member" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_role" + "github.com/zitadel/terraform-provider-zitadel/zitadel/sms_provider_twilio" + "github.com/zitadel/terraform-provider-zitadel/zitadel/smtp_config" + "github.com/zitadel/terraform-provider-zitadel/zitadel/trigger_actions" + "github.com/zitadel/terraform-provider-zitadel/zitadel/user_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/verify_phone_message_text" ) var _ provider.Provider = (*providerPV6)(nil) diff --git a/zitadel/v2/sms_provider_twilio/const.go b/zitadel/sms_provider_twilio/const.go similarity index 100% rename from zitadel/v2/sms_provider_twilio/const.go rename to zitadel/sms_provider_twilio/const.go diff --git a/zitadel/v2/sms_provider_twilio/funcs.go b/zitadel/sms_provider_twilio/funcs.go similarity index 98% rename from zitadel/v2/sms_provider_twilio/funcs.go rename to zitadel/sms_provider_twilio/funcs.go index c91f8bea..3d89be17 100644 --- a/zitadel/v2/sms_provider_twilio/funcs.go +++ b/zitadel/sms_provider_twilio/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/sms_provider_twilio/resource.go b/zitadel/sms_provider_twilio/resource.go similarity index 93% rename from zitadel/v2/sms_provider_twilio/resource.go rename to zitadel/sms_provider_twilio/resource.go index cb204ad4..b13d4657 100644 --- a/zitadel/v2/sms_provider_twilio/resource.go +++ b/zitadel/sms_provider_twilio/resource.go @@ -3,7 +3,7 @@ package sms_provider_twilio import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/sms_provider_twilio/resource_test.go b/zitadel/sms_provider_twilio/resource_test.go similarity index 88% rename from zitadel/v2/sms_provider_twilio/resource_test.go rename to zitadel/sms_provider_twilio/resource_test.go index cf1e0564..82ef2654 100644 --- a/zitadel/v2/sms_provider_twilio/resource_test.go +++ b/zitadel/sms_provider_twilio/resource_test.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/sms_provider_twilio" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/sms_provider_twilio" ) func TestAccSMSProviderTwilio(t *testing.T) { diff --git a/zitadel/v2/smtp_config/const.go b/zitadel/smtp_config/const.go similarity index 100% rename from zitadel/v2/smtp_config/const.go rename to zitadel/smtp_config/const.go diff --git a/zitadel/v2/smtp_config/funcs.go b/zitadel/smtp_config/funcs.go similarity index 98% rename from zitadel/v2/smtp_config/funcs.go rename to zitadel/smtp_config/funcs.go index 5abd551c..3276e27f 100644 --- a/zitadel/v2/smtp_config/funcs.go +++ b/zitadel/smtp_config/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/admin" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/smtp_config/resource.go b/zitadel/smtp_config/resource.go similarity index 95% rename from zitadel/v2/smtp_config/resource.go rename to zitadel/smtp_config/resource.go index 78723221..7e0e9405 100644 --- a/zitadel/v2/smtp_config/resource.go +++ b/zitadel/smtp_config/resource.go @@ -3,7 +3,7 @@ package smtp_config import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/smtp_config/resource_test.go b/zitadel/smtp_config/resource_test.go similarity index 91% rename from zitadel/v2/smtp_config/resource_test.go rename to zitadel/smtp_config/resource_test.go index ae54cb63..36624d7e 100644 --- a/zitadel/v2/smtp_config/resource_test.go +++ b/zitadel/smtp_config/resource_test.go @@ -11,9 +11,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/smtp_config" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/smtp_config" ) func TestAccSMTPConfig(t *testing.T) { diff --git a/zitadel/v2/trigger_actions/const.go b/zitadel/trigger_actions/const.go similarity index 100% rename from zitadel/v2/trigger_actions/const.go rename to zitadel/trigger_actions/const.go diff --git a/zitadel/v2/trigger_actions/datasource.go b/zitadel/trigger_actions/datasource.go similarity index 92% rename from zitadel/v2/trigger_actions/datasource.go rename to zitadel/trigger_actions/datasource.go index cce4919b..345639d3 100644 --- a/zitadel/v2/trigger_actions/datasource.go +++ b/zitadel/trigger_actions/datasource.go @@ -3,7 +3,7 @@ package trigger_actions import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetDatasource() *schema.Resource { diff --git a/zitadel/v2/trigger_actions/funcs.go b/zitadel/trigger_actions/funcs.go similarity index 98% rename from zitadel/v2/trigger_actions/funcs.go rename to zitadel/trigger_actions/funcs.go index b8bfbc0d..27a81289 100644 --- a/zitadel/v2/trigger_actions/funcs.go +++ b/zitadel/trigger_actions/funcs.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/trigger_actions/resource.go b/zitadel/trigger_actions/resource.go similarity index 97% rename from zitadel/v2/trigger_actions/resource.go rename to zitadel/trigger_actions/resource.go index 20107129..507aa873 100644 --- a/zitadel/v2/trigger_actions/resource.go +++ b/zitadel/trigger_actions/resource.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/trigger_actions/resource_test.go b/zitadel/trigger_actions/resource_test.go similarity index 89% rename from zitadel/v2/trigger_actions/resource_test.go rename to zitadel/trigger_actions/resource_test.go index 16401c91..ee58a21d 100644 --- a/zitadel/v2/trigger_actions/resource_test.go +++ b/zitadel/trigger_actions/resource_test.go @@ -10,10 +10,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/action/action_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/trigger_actions" + "github.com/zitadel/terraform-provider-zitadel/zitadel/action/action_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/trigger_actions" ) func TestAccTriggerActions(t *testing.T) { diff --git a/zitadel/v2/user_grant/const.go b/zitadel/user_grant/const.go similarity index 100% rename from zitadel/v2/user_grant/const.go rename to zitadel/user_grant/const.go diff --git a/zitadel/v2/user_grant/funcs.go b/zitadel/user_grant/funcs.go similarity index 98% rename from zitadel/v2/user_grant/funcs.go rename to zitadel/user_grant/funcs.go index 9587ced1..d37d8b3e 100644 --- a/zitadel/v2/user_grant/funcs.go +++ b/zitadel/user_grant/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/zitadel/v2/user_grant/resource.go b/zitadel/user_grant/resource.go similarity index 94% rename from zitadel/v2/user_grant/resource.go rename to zitadel/user_grant/resource.go index 474a4461..aaf62e3d 100644 --- a/zitadel/v2/user_grant/resource.go +++ b/zitadel/user_grant/resource.go @@ -3,7 +3,7 @@ package user_grant import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) func GetResource() *schema.Resource { diff --git a/zitadel/v2/user_grant/resource_test.go b/zitadel/user_grant/resource_test.go similarity index 81% rename from zitadel/v2/user_grant/resource_test.go rename to zitadel/user_grant/resource_test.go index 77bf4601..0d6a882e 100644 --- a/zitadel/v2/user_grant/resource_test.go +++ b/zitadel/user_grant/resource_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/human_user/human_user_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project/project_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/project_role/project_role_test_dep" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/user_grant" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/human_user/human_user_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project/project_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/project_role/project_role_test_dep" + "github.com/zitadel/terraform-provider-zitadel/zitadel/user_grant" ) func TestAccUserGrant(t *testing.T) { diff --git a/zitadel/v2/verify_email_message_text/resource.go b/zitadel/verify_email_message_text/resource.go similarity index 99% rename from zitadel/v2/verify_email_message_text/resource.go rename to zitadel/verify_email_message_text/resource.go index 3cf3242c..fdebb55d 100644 --- a/zitadel/v2/verify_email_message_text/resource.go +++ b/zitadel/verify_email_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/verify_email_message_text/resource_test.go b/zitadel/verify_email_message_text/resource_test.go similarity index 91% rename from zitadel/v2/verify_email_message_text/resource_test.go rename to zitadel/verify_email_message_text/resource_test.go index 9ad71f60..df61c6be 100644 --- a/zitadel/v2/verify_email_message_text/resource_test.go +++ b/zitadel/verify_email_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_email_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/verify_email_message_text" ) func TestAccVerifyEmailMessageText(t *testing.T) { diff --git a/zitadel/v2/verify_phone_message_text/resource.go b/zitadel/verify_phone_message_text/resource.go similarity index 99% rename from zitadel/v2/verify_phone_message_text/resource.go rename to zitadel/verify_phone_message_text/resource.go index dbd75af7..3e005e9b 100644 --- a/zitadel/v2/verify_phone_message_text/resource.go +++ b/zitadel/verify_phone_message_text/resource.go @@ -15,7 +15,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "github.com/zitadel/terraform-provider-zitadel/gen/github.com/zitadel/zitadel/pkg/grpc/text" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper" ) const ( diff --git a/zitadel/v2/verify_phone_message_text/resource_test.go b/zitadel/verify_phone_message_text/resource_test.go similarity index 91% rename from zitadel/v2/verify_phone_message_text/resource_test.go rename to zitadel/verify_phone_message_text/resource_test.go index 1e053154..a4615529 100644 --- a/zitadel/v2/verify_phone_message_text/resource_test.go +++ b/zitadel/verify_phone_message_text/resource_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/zitadel/zitadel-go/v2/pkg/client/zitadel/management" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/helper/test_utils" - "github.com/zitadel/terraform-provider-zitadel/zitadel/v2/verify_phone_message_text" + "github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils" + "github.com/zitadel/terraform-provider-zitadel/zitadel/verify_phone_message_text" ) func TestAccVerifyPhoneMessageText(t *testing.T) { From 8a7c29e618183e8146d47f8e2643b5ff778d1454 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 18:12:33 +0200 Subject: [PATCH 258/260] gen docs --- docs/resources/default_login_policy.md | 2 +- docs/resources/login_policy.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/default_login_policy.md b/docs/resources/default_login_policy.md index 03cade57..b678eb28 100644 --- a/docs/resources/default_login_policy.md +++ b/docs/resources/default_login_policy.md @@ -46,7 +46,7 @@ resource "zitadel_default_login_policy" "default" { - `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in -- `force_mfa_local_only` (Boolean) if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login. +- `force_mfa_local_only` (Boolean) if activated, ZITADEL only enforces MFA on local authentications. On authentications through MFA, ZITADEL won't prompt for MFA. - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) diff --git a/docs/resources/login_policy.md b/docs/resources/login_policy.md index 7db2ac86..3baff4f2 100644 --- a/docs/resources/login_policy.md +++ b/docs/resources/login_policy.md @@ -47,7 +47,7 @@ resource "zitadel_login_policy" "default" { - `default_redirect_uri` (String) defines where the user will be redirected to if the login is started without app context (e.g. from mail) - `external_login_check_lifetime` (String) - `force_mfa` (Boolean) defines if a user MUST use a multi factor to log in -- `force_mfa_local_only` (Boolean) if activated, only local authenticated users are forced to use MFA. Authentication through IDPs won't prompt a MFA step in the login. +- `force_mfa_local_only` (Boolean) if activated, ZITADEL only enforces MFA on local authentications. On authentications through MFA, ZITADEL won't prompt for MFA. - `hide_password_reset` (Boolean) defines if password reset link should be shown in the login screen - `ignore_unknown_usernames` (Boolean) defines if unknown username on login screen directly return an error or always display the password screen - `mfa_init_skip_lifetime` (String) From f358f32be8505b4a243474c8a3bb0fe15fd9c2d3 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 18:16:33 +0200 Subject: [PATCH 259/260] update readme --- README.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff413bfb..99ff16a7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ -# WIP terraform-provider-zitadel +# ZITADEL Terraform Provider -The ZITADEL terraform provider enables you to manage reproducible ZITADEL resources declaratively +## A Better Identity and Access Management Solution +ZITADEL combines the best of Auth0 and Keycloak. +It is built for the serverless era. + +Learn more about ZITADEL by checking out the [source repository on GitHub](https://github.com/zitadel/zitadel) + +## About this Terraform Provider + +This is the official ZITADEL Terraform provider. +It lets you declare ZITADEL resources declaratively and apply the resources to any ZITADEL instance. +Importing existing resources to the Terraform state is supported. + +## Usage + +[Follow the Guide in our Docs](https://zitadel.com/docs/guides/manage/terraform/basics). +Note that you need to create an authorized service user to access the ZITADEL APIs through the provider, as noted in the prerequisites. + +## Contributing + +If you find a bug or want to request a new feature, please open an [issue](https://github.com/zitadel/terraform-provider-zitadel/issues). +Contributions to the provider are very welcome, please follow the general guidance in the [Contribution Guide](https://github.com/zitadel/terraform-provider-zitadel/blob/main/CONTRIBUTING.md). + +## Contributors + + + + From c22d3cd93b26518f91f40dad4e514cc388fc3152 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Thu, 24 Aug 2023 18:17:51 +0200 Subject: [PATCH 260/260] fix tests --- zitadel/helper/test_utils/example.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zitadel/helper/test_utils/example.go b/zitadel/helper/test_utils/example.go index b4e1f750..daaf4cd3 100644 --- a/zitadel/helper/test_utils/example.go +++ b/zitadel/helper/test_utils/example.go @@ -21,7 +21,7 @@ const ( func ReadExample(t *testing.T, folder examplesFolder, exampleType string) (string, hcl.Attributes) { fileName := strings.Replace(exampleType, "zitadel_", "", 1) + ".tf" - filePath := path.Join("..", "..", "..", "examples", "provider", string(folder), fileName) + filePath := path.Join("..", "..", "examples", "provider", string(folder), fileName) content, err := os.ReadFile(filePath) if err != nil { t.Fatalf("error reading example file: %v", err)